Skip to content

core-js 3 missing .js extension when 'type': 'module' #12378

@bytestream

Description

@bytestream

Bug Report

  • I would like to work on a fix!

Current behavior

'type': 'module' is used in package.json and when corejs: 3 is specified in babel.config.js webpack complains about missing .js extension despite it existing in src/page.js. If I comment out corejs: 3 then the error goes away.

ERROR in ./src/page.js 1:0-37
Module not found: Error: Can't resolve 'core-js/modules/es.weak-set' in '/home/kieran/PhpstormProjects/babel-test/src'
Did you mean 'es.weak-set.js'?
BREAKING CHANGE: The request 'core-js/modules/es.weak-set' failed to resolve only because it was resolved as fully specified
(probably because the origin is a '*.mjs' file or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.

I would be incredibly grateful if someone could put me out my misery.

Input Code

https://github.com/bytestream/babel-test

Expected behavior

I expect the code to transpile when using corejs 3.

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

  • Filename: babel.config.js
module.exports = {
    presets: [
        [
            '@babel/preset-env',
            {
                'useBuiltIns': 'entry',
                'corejs': 3, // <--- problematic line
            }
        ]
    ],
    plugins: [
        // Don't allow polyfills to pollute global namespace.
        '@babel/plugin-transform-runtime',
        // Support for the experimental syntax 'classPrivateProperties'
        '@babel/plugin-proposal-class-properties',
        // Support for the experimental syntax 'classPrivateMethods'
        '@babel/plugin-proposal-private-methods',
    ]
};

Environment

$ npx envinfo --preset babel

  System:
    OS: Linux 4.9 Debian GNU/Linux 9 (stretch) 9 (stretch)
  Binaries:
    Node: 12.19.0 - /usr/bin/node
    Yarn: 1.22.4 - /usr/bin/yarn
    npm: 6.14.8 - /usr/bin/npm
  npmPackages:
    @babel/core: ^7.12.3 => 7.12.3 
    @babel/plugin-proposal-class-properties: ^7.12.1 => 7.12.1 
    @babel/plugin-proposal-private-methods: ^7.12.1 => 7.12.1 
    @babel/plugin-transform-runtime: ^7.12.1 => 7.12.1 
    @babel/preset-env: ^7.12.1 => 7.12.1 
    @babel/runtime-corejs3: ^7.12.5 => 7.12.5 
    babel-loader: ^8.2.1 => 8.2.1 
    webpack: ^5.6.0 => 5.6.0 

Possible Solution

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    i: needs triageoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions