Skip to content

Experimental modules warning does not show when using dynamic import #30601

@guybedford

Description

@guybedford

As reported by @coreyfarrell here -

Interesting note, the following code executed by CJS does not produce any warning or error in node.js 13.2.0:

import('./nyc.config.mjs')
	.then(console.log)
	.catch(e => console.error(e.message));

When using dynamic import the experimental modules implementation is effectively used "lazily". Even when loaded at this point the warning should still be displayed.

Currently the warning is implemented at https://github.com/nodejs/node/blob/master/lib/internal/process/esm_loader.js#L45.

When calling the first dynamic import through https://github.com/nodejs/node/blob/master/lib/internal/process/esm_loader.js#L26 we should also be able to ensure the warning is provided.

Metadata

Metadata

Assignees

No one assigned

    Labels

    esmIssues and PRs related to the ECMAScript Modules implementation.good first issueIssues that are suitable for first-time contributors.help wantedIssues that need assistance from volunteers or PRs that need help to proceed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions