-
Notifications
You must be signed in to change notification settings - Fork 788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bug: import statements from dist-custom-elements getting passed to commonjs and errors in SSR Applications like NextJS. #3176
Comments
@roman-telia Thanks for the issue! I don't seem to have access to that reproduction url - would you be able to give me access (or create a separate public repo)? |
Hi rwaskiewicz, I have created a GitHub repository as a public one, as you requested. https://github.com/roman-telia/Next-vocads-playground |
Hey @roman-telia, apologies for taking so long to get back to you. I'm having trouble replicating this working with I took a look at the reproduction case, but unfortunately I can't use it as I don't believe I have access to the design system it's using. It looks like a locally generated tarball is being used here, which makes recreating the reproduction case on my system a little difficult. To try to work around that, I spun up a NextJS application and Stencil component library:
With the Stencil library, I replaced my output targets with import { Config } from '@stencil/core';
export const config: Config = {
namespace: 'my-lib',
outputTargets: [
{
type: 'dist-custom-elements-bundle',
}
],
}; I then built and tarball'ed my library - import '../styles/globals.css'
import type { AppProps } from 'next/app'
// @ts-ignore
import {MyComponent} from 'my-lib/dist/components/my-component';
function MyApp({ Component, pageProps }: AppProps) {
customElements.define('my-component', MyComponent);
return <Component {...pageProps} />
}
export default MyApp And get the same error you reported when I try to build the Next app with
I'm surely missing something here. Can you please advise? |
This is something that my team has been experiencing for some time when using the We have our "main" library that uses both the Next we are using the React output target to generate a React library that consumes the Onto the crux of the issue: Because the Unlike with the |
Duplicate of #5831 |
Prerequisites
Stencil Version
2.11.0
Current Behavior
after we updated from dist-custom-elements-bundle to dist-custom-elements we are running into issues with NextJS when using our commonjs react wrappers in NextJS app, when running next js or building it throws error that can't use import statement outside of a module.
Expected Behavior
It should work the same way as before with dist-custom-elements-bundle, that there wasn't imported es6 module files in commonjs react output.
Steps to Reproduce
create build output, install new package version in Next js project, try to run the next app after installing latest package and you will get this error.
Code Reproduction URL
https://github.com/roman-telia/Next-vocads-playground
Additional Information
No response
The text was updated successfully, but these errors were encountered: