Skip to content

Imply ES6 module package, when package.json contanis 'module':... #34027

@dilyanpalauzov

Description

@dilyanpalauzov

In my package.json I have 'type':'module' and in my code I write import babel from '@rollup/plugin-babel. The package.json of the latter contains "main": "dist/index.js", "module": "dist/index.es.js" but there is no 'type':'module'. In turn nodejs concludes that @rollup/plugin-babel is commonjs and there is no way to use the default import from dist/index.es.js. This means I have to write babel.default in my code and I cannot use import {babel} from '@rollup/plugin-html.

• When NodeJS imports a package(.json) that contains 'main' and 'module' fields, but no 'type' field, from a package containing 'type':'module', implicitly conclude that the imported package is an ES6 module.

Metadata

Metadata

Assignees

No one assigned

    Labels

    esmIssues and PRs related to the ECMAScript Modules implementation.feature requestIssues that request new features to be added to Node.js.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions