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

Rollup v2.0.0 #3347

Merged
merged 19 commits into from Mar 6, 2020
Merged

Rollup v2.0.0 #3347

merged 19 commits into from Mar 6, 2020

Conversation

lukastaegert
Copy link
Member

@lukastaegert lukastaegert commented Jan 20, 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:
See list of contained PRs at the bottom

Description

This is the release branch for Rollup@2.
See https://github.com/rollup/rollup/projects/2 for the current state of the new release.

At the moment, the following changes are contained in this branch:

Breaking Changes

  • Rollup now requires at least Node 10 to run, or a sufficiently modern browser ([v2.0.0] Update minimum required Node version to 10 #3346)

  • The file structure of Rollup's ESM builds has changed:

    • The main ESM entry point is now at rollup/dist/es/rollup.js instead of rollup/dist/rollup.es.js
    • The ESM browser build is at rollup/dist/es/rollup.browser.js instead of rollup/dist/rollup.browser.es.js

    In general, the ESM builds now follow the same naming scheme as the CJS builds but are located in the rollup/dist/es subfolder instead of rollup/dist ([v2.0.0] Bundle acorn, allow node ESM import fo Rollup, update dependencies #3391)

  • The "watch.chokidar" option no longer accepts a boolean value but only an object of parameters that is passed to the bundled Chokidar instance. Chokidar installations by the user will be ignored in favour of the bundled instance ([v2.0.0] Bundle chokidar #3331)

  • Modules that are completely tree-shaken will no longer be listed as part of any chunks in generateBundle

  • The experimentalOptimizeChunks and chunkGroupingSize options have been removed

  • acorn plugins can only be used if they accept a passed-in acorn instance instead of importing it themselves. See Request: give token types and etc to plugins acornjs/acorn#870 (comment) for what needs to be done to make plugins compatible that do not support this yet ([v2.0.0] Bundle acorn, allow node ESM import fo Rollup, update dependencies #3391)

  • Emitted chunks now have the TypeScript type UInt8Array instead of Buffer. A Buffer can still be used, though ([v2.0.0] Remove @types dependencies #3395)

  • The TypeScript types no longer use ESTree types for AST nodes but a very generic type that does not contain information specific to certain node types ([v2.0.0] Remove @types dependencies #3395)

  • The signature of the writeBundle plugin hook has been changed to match generateBundle: The bundle object is now passed as second parameter instead of first and the first parameter is the output options ([v2.0.0] Change writeBundle signature to match generateBundle #3361)

  • The following plugin hooks have been removed:

    • ongenerate: use generateBundle instead
    • onwrite: use writeBundle instead
    • transformBundle: use renderChunk instead
    • transformChunk: use renderChunk instead
  • You can no longer access this.watcher on the plugin context.

  • The transform hook can no longer return dependencies.

  • The treeshake.pureExternalModules option will now show a deprecation warning when used: use treeshake.moduleSideEffects: 'no-external' instead

  • Using import.meta.ROLLUP_ASSET_URL_<..> and import.meta.ROLLUP_CHUNK_URL_<..> in code will now show warnings: use import.meta.ROLLUP_FILE_URL_<..> instead

  • The resolveAssetUrl hook will now show a deprecation warning when used: use resolveFileUrl instead

  • The following plugin context functions will show warnings when used:

    • this.emitAsset: use this.emitFile
    • this.emitChunk: use this.emitFile
    • this.getAssetFileName: use this.getFileName
    • this.getChunkFileName: use this.getFileName
    • this.isExternal: use this.resolve
    • this.resolveId: use this.resolve
  • Directly adding properties to the bundle object in the generateBundle is deprecated will show a warning (removing properties is allowed, though): Use this.emitFile

  • Accessing chunk.isAsset on the bundle is deprecated: Use chunk.type === 'asset' instead

  • The error code for a missing name property when targeting UMD has been changed to MISSING_NAME_OPTION_FOR_IIFE_EXPORT to emphasize this is needed for the IIFE part of UMD (more explained error code for name-less umd bundle  #3393)

Features

Bug Fixes

Pull Requests

@lukastaegert lukastaegert added this to In progress in Release 2.0.0 via automation Jan 20, 2020
@codecov
Copy link

codecov bot commented Jan 20, 2020

Codecov Report

Merging #3347 into master will increase coverage by 1.71%.
The diff coverage is 98.28%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3347      +/-   ##
==========================================
+ Coverage   93.29%   95.00%   +1.71%     
==========================================
  Files         172      171       -1     
  Lines        6114     5831     -283     
  Branches     1823     1722     -101     
==========================================
- Hits         5704     5540     -164     
+ Misses        218      157      -61     
+ Partials      192      134      -58     
Impacted Files Coverage Δ
src/Graph.ts 97.35% <0.00%> (+4.40%) ⬆️
src/ModuleLoader.ts 98.52% <0.00%> (-0.01%) ⬇️
browser/crypto.ts
src/utils/chunkAssignment.ts 100.00% <0.00%> (ø)
src/watch/fileWatcher.ts 96.42% <0.00%> (ø)
src/watch/watch-proxy.ts 100.00% <0.00%> (ø)
src/watch/fsevents-importer.ts 40.00% <0.00%> (ø)
src/utils/parseOptions.ts 100.00% <0.00%> (ø)
src/utils/mergeOptions.ts 100.00% <0.00%> (+7.95%) ⬆️
cli/run/batchWarnings.ts 97.63% <0.00%> (+2.36%) ⬆️
... and 2 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 f458cbf...4610f4d. Read the comment docs.

@rollup-bot
Copy link
Collaborator

rollup-bot commented Feb 8, 2020

Thank you for your contribution! ❤️

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

npm install rollup/rollup#release-2.0.0

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

@lukastaegert lukastaegert force-pushed the release-2.0.0 branch 2 times, most recently from f950ad5 to a5c193d Compare February 14, 2020 05:52
@lukastaegert lukastaegert moved this from In progress to Ready for merge in Release 2.0.0 Feb 19, 2020
@lukastaegert lukastaegert changed the title [WIP] Rollup v2.0.0 Rollup v2.0.0 Feb 19, 2020
@lukastaegert lukastaegert marked this pull request as ready for review February 19, 2020 06:00
@lukastaegert lukastaegert force-pushed the release-2.0.0 branch 2 times, most recently from 91cff8f to bbfe4a5 Compare February 19, 2020 06:46
@Andarist
Copy link
Member

q: wasnt "es" format supposed to be renamed to "esm"? or you have decided not to proceed with this one?

@lukastaegert
Copy link
Member Author

Yes it was. The problem is that this caused an inconsistency with plugins that still receive "es" as format specifier, which was confusing to say the least. Asking around for opinions, I agree with the following reasoning:

  • CJS modules are called cjs
  • AMD modules are called amd
  • SystemJS modules are called system
  • Why should ES modules be called esm and not es?

So it is much more consistent with the other format specifiers. Nevertheless this is not a breaking change: esm will continue to work as an alias and is not marked for deprecation, and module is supported as well.

@kzc
Copy link
Contributor

kzc commented Feb 20, 2020

I'm not convinced that bundling acorn and magic-string is a good idea. If there's a bug in one of those packages (as is currently the case with magic-string) there's no way for a user to supply an alternate package with a fix via yarn resolutions or other methods. The users would have to wait for the upstream package fix followed by a new rollup release.

@lukastaegert
Copy link
Member Author

I see your point and we might revert this policy at some point. At the moment, bundling provides some slight size and parsing time advantages and allows for consistent behaviour between Node and browser builds.

I usually try to be quick on updating merged dependencies, so unless you want to use a Github build this should not be too big an issue. Let's see how this pans out.

@NotWoods
Copy link
Member

NotWoods commented Mar 2, 2020

Can you update compilerOptions.target in the tsconfig.json file to "es2018"? That'll tell Typescript to any syntax that can run in Node 10 and save us a few bytes.

@lukastaegert
Copy link
Member Author

Thanks for checking, this has actually already been done in one of the PRs included here:

"target": "es2018"

lukastaegert and others added 10 commits March 6, 2020 10:37
* Update CI to only run on Node 10 and 12, add engines to package.json

* Update TypeScript target

* Remove Bublé as a transpilation option from tests (it is still needed in sourcemap tests)

* Remove minNodeVersion form tests

* Reformat package.json
* Create a separate chunk for watch mode via a dynamic import

* Bundle chokidar

* Handle conditional fsevents import

* Only run tests on Node 10 and 12 as we want to do this anyway and chokidar depends on utils.promisify

* Improve chunking

* Refactor and simplify watcher

* Make watcher a proper parameter

* Only unwatch and watch on Linux systems

* No longer run JS files through TypeScript for improved bundling performance
* Remove active deprecations

* Make inactive deprecations active

* Improve coverage

* Improve coverage

* Refine transformer

* Improve coverage

* Refactoring option normalization

* Improve coverage
* Respect moduleSideEffects when inlining empty imports

* Make dependencies a Set

* Also handle side-effect free reexports correctly without generating separate chunks

* Infer side-effect free modules and hoist side-effects

* Simplify some logic

* Better encapsulate chunk assignment

* Get rid of colouring hashes

* Improve coverage

* Store the build output as artifact and post an automated comment
* [v2.0.0] Update minimum required Node version to 10 (#3346)

* Update CI to only run on Node 10 and 12, add engines to package.json

* Update TypeScript target

* Remove Bublé as a transpilation option from tests (it is still needed in sourcemap tests)

* Remove minNodeVersion form tests

* Reformat package.json

* [v2.0.0] Bundle chokidar (#3331)

* Create a separate chunk for watch mode via a dynamic import

* Bundle chokidar

* Handle conditional fsevents import

* Only run tests on Node 10 and 12 as we want to do this anyway and chokidar depends on utils.promisify

* Improve chunking

* Refactor and simplify watcher

* Make watcher a proper parameter

* Only unwatch and watch on Linux systems

* No longer run JS files through TypeScript for improved bundling performance

* [v2.0.0] Remove active deprecations (#3352)

* Remove active deprecations

* Make inactive deprecations active

* Improve coverage

* Improve coverage

* Refine transformer

* Improve coverage

* Refactoring option normalization

* Improve coverage

* Remove experimentalOptimizeChunks

* Remove more unused code
…encies (#3391)

* Support Node ESM

* Bundle acorn again, adjust directory structure and support Node ESM

* Update dependencies

* Collect licenses from all artifacts

* Switch to colorette instead of turbocolor

* Support Node ESM through conditional exports

* Fix test
lukastaegert and others added 5 commits March 6, 2020 10:41
* Replace Buffer with UInt8Array and get rid of Node types dependency

* Git rid of ESTree dependency by using a specialized version of acorn's Node type

* Fix test and adjust documentation
* more explained error code for name-less umd bundle

* Align error code with IIFE warning

* Fix missing auth token issue. I guess we need to rethink how we post these messages as of course it makes sense CircleCI does not expose the token for different repo PRs for security reasons. Babel is using an AWS Lambda here, maybe something like that.

Co-authored-by: Lukas Taegert-Atkinson <lukas.taegert-atkinson@tngtech.com>
@lukastaegert lukastaegert merged commit 0c4a5db into master Mar 6, 2020
Release 2.0.0 automation moved this from Ready for merge to Done Mar 6, 2020
@lukastaegert lukastaegert deleted the release-2.0.0 branch March 6, 2020 13:35
@wessberg
Copy link
Contributor

wessberg commented Mar 11, 2020

Hey Lukas. Great work, and congratulations on the v2 milestone :-)

Please let me know if you'd like me to create a new issue in relation to the following question. I'd like to understand if you have any plans for bringing back chunk grouping? For production applications built with Rollup with hundreds or thousands of chunks due to heavy use of code splitting, you might end up with many chunks weighing less than 1 kilobyte. My team is relying heavily on Rollup, but we're currently serving so many chunks to our users, most of which are less than or around 1kb in size, that it hurts performance. I've been following progress of the experimentalChunkOptimization flag with the hopes that it might help us due to the chunk grouping feature. However, I've also noticed that the feature didn't really work (hence the experimental nature of the feature, and I'm guessing that may be the reason why you removed it), but I think it would be extremely valuable, at least to me and my team, and generally for those who rely on Rollup for building applications in a progressive and performance-sensitive way.

@lukastaegert
Copy link
Member Author

So to give you some idea, these are the topics I want to work on next:

  • Reduce the number of facade chunks. Facade chunks are reexport chunks that are generated whenever a chunk that contains an entry point would also contain additional exports. The plan is to add an option to configure Rollup more for web apps, which would get rid of facades for static entries. And later add an option to allow for "tainted" namespaces in dynamic imports, i.e. namespaces that contain additional exports. This would get rid of many facades for dynamic imports.
  • Fix hashing by completely reworking how it is done.
  • Refactor chunking so that it is no longer part of the "build" phase but moved to the "output generation" phase. This is a profound refactoring but would be a necessary step in order to implement a better "optimizeChunks". At that point, I would also consider adding a plugin API to allow plugins to directly control the chunking procedure. Depending how it is done, "optimizeChunks" could also become a plugin then.

However, it would take quite a bit of time to get there. For the time being, I would also have a look at manualChunks, which can basically be used to hand merge chunks. If all static entry points are always loaded together, one easy optimization could be to make all of them manual chunks. As a rule of thumb, an entry that is always loaded initially can always be made a manual chunk without risk. Manual chunks work like a flood fill paint, adding all statically imported modules to a chunk, unless they are already part of another manual chunk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Release 2.0.0
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

7 participants