rollup / rollup/rollup

Feature Request: Give plugins access to import specifiers in chunk

Open
#4,368 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

t³ ✨ enhancement t⁸ ⋅ triage
Dominant language
JavaScript
Stars
26.3k
Forks
1.8k
Avg merge
2d 11h
Merged PRs (30d)
20

Description

Feature Use Case

Writing plugins that needs to know the original specifiers of imports in a chunk.

Feature Proposal

I am working on a plugin that operates on chunk.imports, which is an array of resolved filepaths like /path/to/my/module.

I need to know the specifier that Rollup resolved to that module, e.g. ../module. This can't caclulated because it could be infinitely many things, i.e. for path/to/my/module/sub, it could be:

  • ..
  • ../../module
  • ../../../my/module
  • ../../../../to/my/module
  • etc.

Only Rollup knows what the specifier was pre-resolution, and I would like to get that information in the chunk object since it will make operating on imports a lot easier.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how Rollup constructs the chunk.imports array and where import specifiers are resolved before they become file paths. Determine an API shape for preserving the original specifier and define tests that verify plugins can read it from the chunk object.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.