-
Notifications
You must be signed in to change notification settings - Fork 59
Open
Description
Right now, inline-style-prefixer cannot be used as an esmodule in node. The module field of the package.json is never read by node (ref) and manually importing inline-style-prefixer/es does not work either since:
"type": "module"is not defined on the package.json so we can't use the "import" syntax- imports don't contain file extensions (as in
import createPrefixer from './createPrefixer.js'instead ofimport createPrefixer from './createPrefixer'), which is required by the esm specification (ref)
To fix this, we could:
- use a babel plugin to add file extensions for the esm build, something like: babel-plugin-add-import-extension
- add
"type": "module"to the package.json - add a
exportsfield in package.json to ask node to include the esm version "imports" call and keep the cjs version on "require"
I have not written a PR yet for that because I fear adding the exports field might be a breaking change. I wonder if we should use something like nodejs/help#3993 (comment)
I also wonder if keeping a cjs version is still relevant today, or if an esmodule is enough.
For context on why I want an ES module, you can see necolas/react-native-web#2668 or vikejs/vike#1637 (reply in thread)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels