Skip to content
This repository was archived by the owner on Sep 2, 2023. It is now read-only.
This repository was archived by the owner on Sep 2, 2023. It is now read-only.

Import file specifier proposal implementation #256

Closed
@GeoffreyBooth

Description

@GeoffreyBooth

Hi folks,

In the last two meetings I asked the group for any additional notes on the import file specifier proposal, and I haven’t received any. I hope that means we should be ready to merge in @guybedford’s implementation of it. That’s in a PR here: nodejs/ecmascript-modules#28.

This PR does not include the package exports proposal, as there’s ongoing discussion regarding whether that proposal should cover CommonJS. So instead of using "exports" as the “package.json ESM-signifying field” that the import file specifier looks for, this branch looks for "type": "esm" per this proposal. This is temporary; the shape of the package.json configuration is expected to change when the package exports implementation is merged in, and likely again when support for loaders is added, at the least. I encourage the group to allow merging in this PR as is, with the understanding that the package.json UX will change in the future. Also note that Phase 4 is intended for user feedback and UX revisions.

Relative to the current “minimal kernel” new implementation, this PR adds support for:

  • import of either ESM or CommonJS bare specifiers: import 'lodash', including supporting "main" for ESM packages.

  • Deep import of files within either ESM of CommonJS packages: import shuffle from 'lodash/lib/shuffle.mjs'.

  • import of .js files as ESM within ESM-designated package scopes: import './startup.js'.

  • Initial entry point of a .js file within an ESM package scope: node app.js.

The “package scope” concept, support for .js as ESM within ESM package scopes, and CommonJS interoperability are all important features that I’d like to get merged into our new implementation sooner than later so that other features (such as loaders) can build upon them. I would encourage people to consider if any objections they have to this PR might be acceptably addressed in follow-up PRs rather than blocking this one, so that we can continue our progress toward trying to release the new implementation either flagged or unflagged by April.

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