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
Webpack error: cannot dynamically import styles #3634
Comments
Same goes for dynamically importing languages:
Here webpack fails with:
|
highlight.js version 11 does not allow dynamic imports of languages and styles with webpack due to an exports field in package.json. See: highlightjs/highlight.js#3634
highlight.js version 11 does not allow dynamic imports of languages and styles with webpack due to an exports field in package.json. See: highlightjs/highlight.js#3634
highlight.js version 11 does not allow dynamic imports of languages and styles with webpack due to an exports field in package.json. See: highlightjs/highlight.js#3634
I'm current considering this a bug in webpack (until someone can link me to an issue filed against webpack that says otherwise). We already do wildcard exports for these paths.. It seems so far to only be webpack can't figure it out when the paths are dynamic... https://github.com/highlightjs/highlight.js/blob/main/tools/build_node.js#L104_ Closing as a dup of #3384. Please file an issue against webpack and link to this issue. |
Thanks for pointing that out! |
Describe the issue/behavior that seems buggy
When trying to dynamically import a theme, webpack fails with an error saying that
./styles
is not in the exported field of package.json.Sample Code or Instructions to Reproduce
With a webpack setup try to import a style in an async methods like so:
Webpack fails with this error:
This does work though:
Removing the
exports
field inpackage.json
also lets me to import the styles dynamically.Expected behavior
I expect to be able to import anything within highlight.js dynamically.
The text was updated successfully, but these errors were encountered: