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

Make Fractal support ES modules #1024

Open
julkue opened this issue May 13, 2021 · 1 comment
Open

Make Fractal support ES modules #1024

julkue opened this issue May 13, 2021 · 1 comment

Comments

@julkue
Copy link

julkue commented May 13, 2021

What problem would this feature solve?

Currently, it doesn't seem to be possible to use ES modules in the project that is used as the Fractal components library. However, at least repositories from sindresorhus are forcing a migration, see this.

What the feature should look like?

Currently, when the Components Library uses "type": "module" in package.json, the following error will be thrown by Node.js (v14+):

[0] Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: P:\cando-cx-frontend\components-library\build\fractal.js
[0] require() of ES modules is not supported.
[0] require() of P:\cando-cx-frontend\components-library\build\fractal.js from P:\cando-cx-frontend\components-library\node_modules\@frctl\fractal\bin\fractal.js is
 an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
[0] Instead rename P:\cando-cx-frontend\components-library\build\fractal.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" fr
om P:\cando-cx-frontend\components-library\package.json.
@mihkeleidast
Copy link
Member

Can you create a minimal repo that shows this issue? Not sure I can understand what is going on here otherwise.

We currently still support Node 10 (will drop once some other work is completed), so can't move to ESM ourselves just yet but there should be some level of cross-compatibility I believe.

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

No branches or pull requests

2 participants