Skip to content
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

Cannot use as an ES module #232

Open
zoriya opened this issue May 16, 2024 · 0 comments
Open

Cannot use as an ES module #232

zoriya opened this issue May 16, 2024 · 0 comments

Comments

@zoriya
Copy link

zoriya commented May 16, 2024

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant