🌐 AI搜索 & 代理 主页
Skip to content

Conversation

@lukastaegert
Copy link
Member

@lukastaegert lukastaegert commented Apr 15, 2020

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:
Resolves #3358

Description

This will add a new input option preserveEntrySignatures that will configure if facades are created or otherwise how freely entry point exports can be created. Possible values:

  • "strict": This corresponds to the current behaviour. Entry chunks will expose exactly the exports of the corresponding entry modules. If this is not possible because additional bindings need to be exported from the chunk, a facade chunk will be created. This is the default and is the recommended setting for libraries.
  • "allow-extension": Entry chunks will expose all exports of the corresponding entry modules. If additional bindings need to be exported as well for some other chunk, they will be added to the entry chunk and extend the signature. If exports are minified, those additional exports will be minified. This settings can be used for libraries if less chunks are desired and a strict facade is not required.
  • false: By default, not exports will be exposed by entry chunks, and exported variables will only be included in the bundle if they are actually used by the code. If bindings need to be exported for some other chunk, they will be added just as if this were an internal chunk. This is the recommended setting if the entry points are to be put into script tags.

When emitting chunks via this.emitFile in the plugin API, it is possible to override this setting for individual chunks by supply a new preserveSignature option with the same values.

Additionally, this adds an option minifyInternalExports: true|false that allows to control for all formats if internal exports are minified to single-letter names.

There are still some things to do:

  • See how this interacts with preserveModules. By default, I would throw an error if false is used with preserveModules for now.
  • Add documentation
  • Show a meaningful warning that explains this option and points to the documentation if no value is specified for this option and an empty facade would be created
  • See how this interacts with chunks emitted by plugins. They should probably be either exempt from this setting or they can specify their own value per-chunk.
  • Add an option to control if internal exports are minified (nice to have)

@rollup-bot
Copy link
Collaborator

rollup-bot commented Apr 15, 2020

Thank you for your contribution! ❤️

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

npm install rollup/rollup#preserve-entry-signatures

or load it into the REPL:
https://rollupjs.org/repl/?circleci=10612

@codecov
Copy link

codecov bot commented Apr 15, 2020

Codecov Report

Merging #3498 into master will increase coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3498      +/-   ##
==========================================
+ Coverage   96.08%   96.12%   +0.03%     
==========================================
  Files         175      176       +1     
  Lines        5956     5983      +27     
  Branches     1752     1761       +9     
==========================================
+ Hits         5723     5751      +28     
  Misses        118      118              
+ Partials      115      114       -1     
Impacted Files Coverage Δ
cli/cli.ts 71.42% <ø> (ø)
src/utils/base64.ts 100.00% <ø> (ø)
src/utils/parseOptions.ts 100.00% <ø> (ø)
cli/run/index.ts 100.00% <100.00%> (ø)
cli/run/watch-cli.ts 87.50% <100.00%> (ø)
src/Chunk.ts 99.77% <100.00%> (-0.01%) ⬇️
src/Graph.ts 98.72% <100.00%> (+0.05%) ⬆️
src/Module.ts 98.87% <100.00%> (+0.01%) ⬆️
src/ModuleLoader.ts 99.06% <100.00%> (ø)
src/rollup/rollup.ts 100.00% <100.00%> (ø)
... and 4 more

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 c0c206e...7d5b6b3. Read the comment docs.

@lukastaegert lukastaegert force-pushed the preserve-entry-signatures branch 2 times, most recently from 57d8d99 to 9199d6d Compare April 16, 2020 19:33
@lukastaegert lukastaegert force-pushed the preserve-entry-signatures branch from 9199d6d to 6fadc58 Compare April 16, 2020 19:46
@lukastaegert lukastaegert force-pushed the preserve-entry-signatures branch 3 times, most recently from 61f9449 to f9b277d Compare April 18, 2020 21:16
@lukastaegert lukastaegert force-pushed the preserve-entry-signatures branch from f9b277d to 0a9ce4d Compare April 18, 2020 21:22
@lukastaegert lukastaegert force-pushed the preserve-entry-signatures branch 3 times, most recently from 0dcf873 to 2713c6d Compare April 20, 2020 19:52
@lukastaegert lukastaegert force-pushed the preserve-entry-signatures branch from 2713c6d to 6d27557 Compare April 20, 2020 20:04
@LarsDenBakker
Copy link
Contributor

I tried this out on a few different projects, and it's working as expected. 👍

@lukastaegert lukastaegert marked this pull request as ready for review April 20, 2020 21:30
@lukastaegert
Copy link
Member Author

This is now ready from my side, will probably release it tomorrow.

@lukastaegert lukastaegert merged commit de47e4c into master Apr 21, 2020
@lukastaegert lukastaegert deleted the preserve-entry-signatures branch April 21, 2020 18:40
@lukastaegert lukastaegert changed the title [WIP] Add option to configure if entry signatures are preserved Add option to configure if entry signatures are preserved Apr 21, 2020
lukastaegert added a commit that referenced this pull request Apr 21, 2020
* Refactor some code

* Implement support for preserveEntrySignatures false and 'allow-extension'

* Throw an error if preserveEntrySignatures is set to false for preserveModules

* Add basic documentation

* Show a meaningful warning if an empty facade chunk is created for a user-defined chunk and preserveEntrySignatures has not been set

* Make config file watching more stable

* Add ability to override signature preservation for plugins

* Extend documentation

* Try to improve watch test stability

* Add option to control minification of internal exports
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.

Redundant files with only import statements are produced in 1.30.1

4 participants