-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Closed
Labels
Description
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:
test() {
const theme = "github";
import(`highlight.js/styles/${theme}.css`);
}
Webpack fails with this error:
ERROR in ./src/pat/syntax-highlight/syntax-highlight.js 35:4-46
Module not found: Error: Package path ./styles is not exported from package /home/_thet/data/dev/syslab/REPOS/patternslib/Patterns/node_modules/highlight.js (see exports field in /home/_thet/data/dev/syslab/REPOS/patternslib/Patterns/node_modules/highlight.js/package.json)
@ ./src/patterns.js 54:0-49
@ ./src/index.js 5:0-20
webpack 5.74.0 compiled with 1 error in 769 ms
This does work though:
test() {
import(`highlight.js/styles/github.css`);
}
Removing the exports
field in package.json
also lets me to import the styles dynamically.
Expected behavior
I expect to be able to import anything within highlight.js dynamically.