Skip to content
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] @stencil/core not building #3281

Open
4 tasks done
cmditch opened this issue May 6, 2021 · 1 comment
Open
4 tasks done

[BUG] @stencil/core not building #3281

cmditch opened this issue May 6, 2021 · 1 comment

Comments

@cmditch
Copy link

cmditch commented May 6, 2021

Bug Report Quick Checklist

  • I am on the latest version of Snowpack & all plugins.
  • I use package manager yarn
  • I run Snowpack on OS Mac
  • I run Snowpack on Node.js v12+

Describe the bug

Snowpack does not seem to play nice with @stencil/core
Seeing the error below when import stencil from '@stencil/core/internal/client' exists within code. This is a necessary import for Stencil custom elements.

Error: [16:19:08] [snowpack] Cannot find module ''../../../common/shadow-css-bb8fe40a.js'' from '/Users/cmditch/sandbox/snowpack-stencil/node_modules/@stencil/core/internal/client/index.js'

To Reproduce

git clone git@github.com:cmditch/snowpack-stencil-error.git
cd snowpack-stencil-error
yarn
yarn snowpack dev

Expected behavior

A build w/o errors.

Anything else?

When I load a stencil component via a <script> tag over the wire it works, but if I try to build it using snowpack it does not work. Stencil docs have an example of how to bundle a component w/ rollup here, so it seems like Stencil and rollup can play nice. Perhaps it's the way snowpack is configuring rollup.

Lastly, oddly enough the file/path ../../../common/shadow-css-bb8fe40a.js does not even exist within node_modules/@stencil/core. It's also not clear where this filename is being generated within their source.

@rossng
Copy link

rossng commented Jul 10, 2021

Looks like it's being caused by this dynamic import in the Stencil code.

In the @stencil/core package, that has been compiled to something like:

    !BUILD.hydrateServerSide && BUILD.shadowDom && BUILD.shadowDomShim && 8 & o.$flags$ && (n = await import("./shadow-css.js").then((e => e.scopeCss(n, l, !1)))), 

I think this is the same root cause as #3094. Looks like esbuild doesn't natively support dynamic imports yet, so Snowpack would have to work around this but doesn't quite do it right atm. Though it's possible I've missed something and this is actually coming from Rollup - not 100% sure.

It appears that the Stencil team is also aware of this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants