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 of import 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
exports field 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)
Right now,
inline-style-prefixercannot be used as an esmodule in node. Themodulefield of the package.json is never read by node (ref) and manually importinginline-style-prefixer/esdoes not work either since:"type": "module"is not defined on the package.json so we can't use the "import" syntaximport createPrefixer from './createPrefixer.js'instead ofimport createPrefixer from './createPrefixer'), which is required by the esm specification (ref)To fix this, we could:
"type": "module"to the package.jsonexportsfield 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
exportsfield 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)