Skip to content

Error importing ES module in v4.26 #905

@massimo-artizzu-gfy

Description

@massimo-artizzu-gfy

We have a legacy Angular 12 project, running on Node 12, that depends on browserslist, and since this Friday our pipeline breaks because it tries to use v4.26.0 instead of the previous v4.25.4, which did not depend on baseline-browser-mapping.

We got the following log:

An unhandled exception occurred: Must use import to load ES Module: /home/jenkins/#####/PROJECT/#####/node_modules/baseline-browser-mapping/dist/index.js
18:43:15 | require() of ES modules is not supported.
18:43:15 | require() of /home/jenkins/#####/PROJECT/#####/node_modules/baseline-browser-mapping/dist/index.js from /home/jenkins/#####/PROJECT/#####/node_modules/browserslist/index.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.
18:43:15 | Instead rename /home/jenkins/#####/PROJECT/#####/node_modules/baseline-browser-mapping/dist/index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /home/jenkins/#####/PROJECT/#####/node_modules/baseline-browser-mapping/package.json.

If it can't be fixed, it's best to delay this dependency to the next major version of browserslist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions