mAAdhaTTah / babel-plugin-prismjs

A babel plugin to use PrismJS with standard bundlers.
157 stars 9 forks source link

Always specify file extensions in import statements #330

Open queengooborg opened 2 years ago

queengooborg commented 2 years ago

Upon migrating my codebase to ESM, I ran into an issue with Prism imports:

ERROR in ./editor/js/css-examples-libs.js 1:0-50
Module not found: Error: Can't resolve 'prismjs/components/prism-core' in '/Users/queengooborg/Developer/Gooborg/mdn-bob/editor/js'
Did you mean 'prism-core.js'?
BREAKING CHANGE: The request 'prismjs/components/prism-core' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.

This seems to be due to the fact that the plugin specifies imports without the file extension. To prevent this issue, the file extension should always be specified.