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

Ignore queries and hashes in file names when preserving modules #4374

Merged
merged 2 commits into from Feb 2, 2022

Conversation

lukastaegert
Copy link
Member

@lukastaegert lukastaegert commented Jan 30, 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

This is something that came up in the course of working on rollup/plugins#1038. Basically when

  • Using a proxy for an entry point, e.g. we resolve /main.js to /main.js?entry-proxy, which in turn imports /main.js,
  • Use preserve modules,

then the actual entry point would have the file name main.js_entry-proxy.js instead of main.js. This will be very confusing to the user. This issue does not turn up when not preserving modules as in that case, we ignore the "extension" .js?entry-proxy and rewrite it as .js instead 😉

I pondered how best to solve this and I found the easiest might be to just ignore queries and hashes when generating output file names for preserveModules. That means plugins still have the freedom to proxy to entirely different file names, but as long as they stick to a naming pattern <original-id>?<plugin-suffix>, Rollup will generate "correct" file names.

@github-actions
Copy link

github-actions bot commented Jan 30, 2022

Thank you for your contribution! ❤️

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

npm install rollup/rollup#preserve-modules-query

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

@codecov
Copy link

codecov bot commented Jan 30, 2022

Codecov Report

Merging #4374 (249281d) into master (d57cfa0) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #4374   +/-   ##
=======================================
  Coverage   98.72%   98.72%           
=======================================
  Files         205      205           
  Lines        7311     7320    +9     
  Branches     2083     2083           
=======================================
+ Hits         7218     7227    +9     
  Misses         34       34           
  Partials       59       59           
Impacted Files Coverage Δ
src/utils/traverseStaticDependencies.ts 100.00% <ø> (ø)
src/Chunk.ts 100.00% <100.00%> (ø)
src/ExternalModule.ts 100.00% <100.00%> (ø)
src/Graph.ts 100.00% <100.00%> (ø)
src/Module.ts 100.00% <100.00%> (ø)
src/ModuleLoader.ts 100.00% <100.00%> (ø)
src/utils/sanitizeFileName.ts 80.00% <100.00%> (+5.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 e0b1060...249281d. Read the comment docs.

@lukastaegert lukastaegert enabled auto-merge (squash) February 2, 2022 06:01
@lukastaegert lukastaegert merged commit f420a01 into master Feb 2, 2022
@lukastaegert lukastaegert deleted the preserve-modules-query branch February 2, 2022 06:02
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