Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a shallow copy when returning meta from resolveId #4347

Merged
merged 2 commits into from Jan 14, 2022

Conversation

lukastaegert
Copy link
Member

@lukastaegert lukastaegert commented Jan 13, 2022

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

List any relevant issue numbers:

Description

When returning a meta object from a resolveId hook, Rollup would use this object as the meta property of a module. As it turned out, this is not only inconsistent with the load and transform hooks (where the object is merged shallowly) but also causes unexpected behaviour. E.g., the meta object returned from a resolveId hook can not be safely reused for other modules. But more importantly, it is unsafe to cache the return value of this.resolve as the associated meta property can change later on. This is fixed here.

The issue turned up in rollup/plugins#1038

@github-actions
Copy link

github-actions bot commented Jan 13, 2022

Thank you for your contribution! ❤️

You can try out this pull request locally by installing Rollup via

npm install rollup/rollup#copy-resolve-id-meta

or load it into the REPL:
https://rollupjs.org/repl/?pr=4347

@codecov
Copy link

codecov bot commented Jan 13, 2022

Codecov Report

Merging #4347 (9946323) into master (1d2ea22) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #4347   +/-   ##
=======================================
  Coverage   98.43%   98.43%           
=======================================
  Files         206      206           
  Lines        7350     7350           
  Branches     2088     2088           
=======================================
  Hits         7235     7235           
  Misses         55       55           
  Partials       60       60           
Impacted Files Coverage Δ
src/Module.ts 100.00% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1d2ea22...9946323. Read the comment docs.

@lukastaegert lukastaegert merged commit 9e947fc into master Jan 14, 2022
@lukastaegert lukastaegert deleted the copy-resolve-id-meta branch January 14, 2022 05:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant