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

Webpack5 ESM strict mode #12058

Closed
ocdi opened this issue Sep 14, 2020 · 14 comments · Fixed by #10853
Closed

Webpack5 ESM strict mode #12058

ocdi opened this issue Sep 14, 2020 · 14 comments · Fixed by #10853
Labels
area: modules i: bug outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@ocdi
Copy link

ocdi commented Sep 14, 2020

Bug Report

Webpack5 beta.30 has enabled strict mode on the ESM modules imports https://github.com/webpack/webpack/releases/tag/v5.0.0-beta.30

webpack/webpack#11467 has noted people with code problems, however @babel/runtime appears to have code that doesn't follow the strict "type": "module" requirements, as expected for node / webpack.

.\node_modules\@babel\runtime\helpers\esm\package.json has "type": "module" being set and libraries that depend on @babel/runtime with ESM modules are broken as a result.

I expect the code generator should be outputting with the file extensions to satisfy the requirements of ESM modules

https://nodejs.org/api/esm.html#esm_differences_between_es_modules_and_commonjs

Current behavior

@babel/runtime/helpers/esm/*.js contains extensionless imports for dependencies.

Expected behavior

@babel/runtime/helpers/esm/*.js to contain fully specified extensions for imports

Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)

N/A - this is npm published module

Environment

  System:
    OS: Windows 10 10.0.19042
  Binaries:
    Node: 12.18.3 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.14.8 - C:\s\SwiftFox\node_modules\.bin\npm.CMD
  Monorepos:
    Yarn Workspaces: 1.22.5
  npmPackages:
    @babel/core: 7.11.4 => 7.11.4
    babel-loader: 8.1.0 => 8.1.0
    eslint: 7.7.0 => 7.7.0
    webpack: 5.0.0-beta.30 => 5.0.0-beta.30
@babel-bot
Copy link
Collaborator

Hey @ocdi! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite."

@sokra
Copy link
Member

sokra commented Sep 14, 2020

btw this is not an webpack-only error. If you run import("@babel/runtime-corejs3/helpers/esm/defineProperty.js") in node.js you get an error too:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '...\node_modules\@babel\runtime-corejs3\core-js\object\define-property' imported from ...\node_modules\@babel\runtime-corejs3\helpers\esm\defineProperty.js

@shpyo
Copy link

shpyo commented Sep 14, 2020

True, this is causing my issue:


14-Sep-2020 10:46:41 | ERROR in ./node_modules/@babel/runtime/helpers/esm/inherits.js 1:0-46
-- | --
14-Sep-2020 10:46:41 | Module not found: Error: Can't resolve './setPrototypeOf' in '/code/node_modules/@babel/runtime/helpers/esm'

@JLHwung
Copy link
Contributor

JLHwung commented Sep 14, 2020

Duplicate of #8462

@JLHwung JLHwung marked this as a duplicate of #8462 Sep 14, 2020
@JLHwung
Copy link
Contributor

JLHwung commented Sep 14, 2020

This issue will be fixed by #10853, please leave a review comment there, thanks.

@alexander-akait
Copy link
Contributor

@JLHwung Can we prioritize the problem?

@JLHwung
Copy link
Contributor

JLHwung commented Sep 14, 2020

@evilebottnawi I will ship it asap once that PR is approved. Can you leave a review?

@felixfbecker
Copy link

Webpack 5 is now released so this would be good to release asap as many people will run into it now

@manuelbieh
Copy link

Indeed. Came here via Google. Ran into it right away. Guess I won't remain the only one. Affected modules:

./setPrototypeOf
./defineProperty
../../helpers/esm/typeof
./assertThisInitialized

Any hints on how I can solve this? I see a merged PR from 26 days ago but it was for Next.js, not for Babel.

@nicolo-ribaudo
Copy link
Member

We plan to release 7.12, which fixes this issue, the upcoming week.

@arpu
Copy link

arpu commented Oct 12, 2020

same problem here any workaround available before Release?

@mwmcode
Copy link

mwmcode commented Oct 12, 2020

@arpu the package mentioned here might help #8462 (comment)

@piecyk
Copy link

piecyk commented Oct 12, 2020

@arpu till then you can add rule for resolving those modules

webpack/webpack#11467 (comment)

@SokichiFujita
Copy link

babel 7.12.0 resolved the errors with webpack v5. nice.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: modules i: bug outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.