Skip to content

Fix ESModule issue when upgrading React from 17 to 18 - #521

Draft
pvieiraguimaraes wants to merge 3 commits into
masterfrom
fix/esmodule-issue
Draft

pvieiraguimaraes wants to merge 3 commits into
masterfrom
fix/esmodule-issue

Conversation

@pvieiraguimaraes

Copy link
Copy Markdown
Contributor

If applied, this pull request will fix ESModule issue when upgrading React from 17 to 18

Notes:

This is a working in progress and is not ready yet.

Currently blocked in this issue which we might need to investigate

/Users/pedroguimaraes/Codelitt/projects/agnostic-design-system/node_modules/@storybook/core-common/dist/cjs/utils/interpret-require.js:64
  var result = require(filePath);
               ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/pedroguimaraes/Codelitt/projects/agnostic-design-system/.storybook/main.js from /Users/pedroguimaraes/Codelitt/projects/agnostic-design-system/node_modules/@storybook/core-common/dist/cjs/utils/interpret-require.js not supported.
main.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
Instead rename main.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /Users/pedroguimaraes/Codelitt/projects/agnostic-design-system/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant