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

[v2.0.0] Bundle chokidar #3331

Merged
merged 9 commits into from Jan 20, 2020
Merged

[v2.0.0] Bundle chokidar #3331

merged 9 commits into from Jan 20, 2020

Conversation

lukastaegert
Copy link
Member

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 #2988

Description

This is the first PR in preparation of the 2.0.0 release: https://github.com/rollup/rollup/projects/2
This will likely receive some additional polishing and testing before it will be merged to the new release-2.0.0 branch. There may be pre-releases from the branch if there is interest once the first changes are merged.

This will make Chokidar the only watcher used by Rollup and bundle it. Also, the code was slightly restructured so that all watch mode related code is in separate chunks that are only loaded on demand via dynamic import (or conditional require in the CJS build). This means that

  • When running Rollup, the two biggest bundled dependencies chokidar and micromatch are only loaded and parsed when watch mode is used
  • JavaScript API users of Rollup that bundle Rollup into their own project do not run risk of bundling these dependencies as the dynamic imports can easily be treeshaken

Bundling chokidar itself was mainly painless. However, its fsevents dependency cannot be bundled as it contains native code. Therefore, it became an optional dependency of Rollup. There is a check in place to make sure its version range matches that of chokidar.

In order to handle the optional require of fsevents in the Rollup code, I created a loader file, patched the chokidar code to load the loader file instead of fsevents and in that loader file, again used a dynamic import to load fsevents. As the watcher itself is already loaded via a dynamic import, I chained these imports so that chokidar will now behave the same no matter if fsevents is present and valid or missing.

@codecov
Copy link

codecov bot commented Jan 13, 2020

Codecov Report

❗ No coverage uploaded for pull request base (release-2.0.0@72f1ade). Click here to learn what that means.
The diff coverage is 94.44%.

Impacted file tree graph

@@               Coverage Diff                @@
##             release-2.0.0    #3331   +/-   ##
================================================
  Coverage                 ?   93.49%           
================================================
  Files                    ?      173           
  Lines                    ?     6013           
  Branches                 ?     1787           
================================================
  Hits                     ?     5622           
  Misses                   ?      211           
  Partials                 ?      180
Impacted Files Coverage Δ
src/Graph.ts 92.94% <ø> (ø)
src/utils/PluginContext.ts 100% <ø> (ø)
src/utils/PluginDriver.ts 100% <ø> (ø)
src/rollup/rollup.ts 96.95% <100%> (ø)
src/watch/watch.ts 97.97% <100%> (ø)
src/watch/watch-proxy.ts 100% <100%> (ø)
src/watch/fsevents-importer.ts 40% <40%> (ø)
src/watch/fileWatcher.ts 96.42% <96.42%> (ø)

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 72f1ade...6db5c94. Read the comment docs.

@lukastaegert lukastaegert force-pushed the bundle-chokidar branch 5 times, most recently from a29affd to 13012e4 Compare January 17, 2020 15:26
@lukastaegert
Copy link
Member Author

Ok, this was quite a piece of work. Apparently, there is an issue in chokidar when a file is "updated" by unlinking and then writing it again in that on certain OSs, specifically our Linux images, the file is no longer watched after that. I fixed it by "unwatch"ing and immediately "add"ing again any changed file.

I also completely rewrote and simplified the watcher code to fully take advantage of chokidar. Hopefully this will reduce memory consumption and improve the experience for everyone!

This is now ready from my side.

@lukastaegert
Copy link
Member Author

I created paulmillr/chokidar#972 to track the issue in chokidar I discovered. This should not block release, though, as a workaround is in place.

@paulmillr
Copy link

@lukastaegert I suggest to only do unwatch and add if os.platform() is linux — only. Otherwise you'll see unnecessary performance degradation.

@lukastaegert lukastaegert added this to In progress in Release 2.0.0 via automation Jan 19, 2020
@lukastaegert lukastaegert moved this from In progress to Ready for merge in Release 2.0.0 Jan 19, 2020
@lukastaegert lukastaegert merged commit 607e787 into release-2.0.0 Jan 20, 2020
Release 2.0.0 automation moved this from Ready for merge to Done Jan 20, 2020
@lukastaegert lukastaegert deleted the bundle-chokidar branch January 20, 2020 10:02
@lukastaegert lukastaegert mentioned this pull request Jan 20, 2020
9 tasks
lukastaegert added a commit that referenced this pull request Jan 21, 2020
* 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
lukastaegert added a commit that referenced this pull request Jan 28, 2020
* 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
lukastaegert added a commit that referenced this pull request Feb 4, 2020
* 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
lukastaegert added a commit that referenced this pull request Feb 8, 2020
* 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
lukastaegert added a commit that referenced this pull request Feb 14, 2020
* 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
lukastaegert added a commit that referenced this pull request Feb 14, 2020
* [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
lukastaegert added a commit that referenced this pull request Feb 19, 2020
* 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
lukastaegert added a commit that referenced this pull request Feb 19, 2020
* [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
lukastaegert added a commit that referenced this pull request Feb 26, 2020
* 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
lukastaegert added a commit that referenced this pull request Feb 26, 2020
* [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
lukastaegert added a commit that referenced this pull request Mar 6, 2020
* 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
lukastaegert added a commit that referenced this pull request Mar 6, 2020
* [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
lukastaegert added a commit that referenced this pull request Mar 6, 2020
* 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
lukastaegert added a commit that referenced this pull request Mar 6, 2020
* [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
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

2 participants