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.

Feature: Specifier resolution customization #110

Description

@GeoffreyBooth

ESM supports intra-package absolute specifiers (/top-level-dir/module.js) relative to a package root to avoid long unreadable ../../../top-level-dir/module.js chains. This is currently possible in CommonJS.

ESM supports alternative resolution when running tests in order to achieve convention-driven mocking: import './x' prefers ./x.test.js if it exists, rather than the usual ./x.js. This is currently possible in CommonJS.

@-prefixed bare-specifiers that refer to dependencies via an out-of-band manifest file (that defines the mapping similar to package-name-maps) can be loaded by Node without a build step.

If I forget to list all my dependencies in package.json, I could run my Node app in a strict asserting mode where name resolution will fail if my code accidentally imports:

  • bare-specifiers not explicitly listed as dependencies (this can be achieved today for the top level project by installing dependencies with the npm option --global-style at the cost of having one layer of nesting of installed modules)
  • relative-specifiers that wander into dependencies, i.e. node_modules

I can write a small sample module on a web-based JavaScript editor like JS Bin that can import modules from NPM (e.g. the unpkg use case).

I can deploy an app into production, but serve common modules like RxJs from a CDN.

I can depend on a dev build during development and a prod build in production.

Use case 23, 24, 26, 27, 29, 30, 31, 33. See also #109 for compatibility with browsers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions