Skip to content

Fetch dependencies by import rather than source to allow for different id resolutions via plugin. #1301

@tehvgg

Description

@tehvgg

EDIT: Proposal update in next comment.

The resolveId() method of the plugin model exposes the importee and importer path strings.
If an importNames variable was also exposed, it would expand the possibilities of plugins using the method.

// importNames examples
resolveId (importee, importer, importNames) {
  // Default import
  // import SomeModule from "SomeModule";
  importNames === "SomeModule";
  // Named imports
  // import { SubModuleA, SubModuleB } from "SomeModule";
  importNames === [ "SubModuleA", "SubModuleB" ];
}

I wrote a plugin that specifically needs access to the import names to dedupe imports by forcing them to come from a single source. The plugin sits in between multi-entry and node-resolve. There is more info in the README of the plugin I linked.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions