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

Lazily install sharp only when needed #6816

Merged
merged 1 commit into from Aug 31, 2021
Merged

Lazily install sharp only when needed #6816

merged 1 commit into from Aug 31, 2021

Conversation

devongovett
Copy link
Member

Fixes T-1107.

This moves @parcel/transformer-image to be a dependency of the default config rather than installed on demand. Since url: is no longer required for images, any time you had an image this was installed, even if you didn't have any query params. Now sharp is required lazily from within the image transformer to avoid it being installed unless needed.

To do this with caching in mind, I used a Proxy to intercept require calls on the package manager and add them as dev deps of the transformation request.

@height
Copy link

height bot commented Aug 29, 2021

This pull request has been linked to and will mark 1 task as "Done" when merged:

💡Tip: You can link multiple Height tasks to a pull request.

@parcel-benchmark
Copy link

Benchmark Results

Kitchen Sink ✅

Timings

Description Time Difference
Cold 2.02s -6.00ms
Cached 306.00ms -6.00ms

Cold Bundles

Bundle Size Difference Time Difference
dist/legacy/parcel.7cdb0fad.webp 102.94kb +0.00b 646.00ms +43.00ms ⚠️
dist/legacy/parcel.7cdb0fad.webp 102.94kb +0.00b 647.00ms +43.00ms ⚠️
dist/modern/parcel.7cdb0fad.webp 102.94kb +0.00b 647.00ms +43.00ms ⚠️

Cached Bundles

Bundle Size Difference Time Difference
dist/legacy/parcel.7cdb0fad.webp 102.94kb +0.00b 670.00ms +66.00ms ⚠️
dist/legacy/parcel.7cdb0fad.webp 102.94kb +0.00b 671.00ms +66.00ms ⚠️
dist/modern/parcel.7cdb0fad.webp 102.94kb +0.00b 670.00ms +66.00ms ⚠️

React HackerNews ✅

Timings

Description Time Difference
Cold 10.15s -145.00ms
Cached 447.00ms -41.00ms 🚀

Cold Bundles

No bundle changes detected.

Cached Bundles

No bundle changes detected.

AtlasKit Editor ✅

Timings

Description Time Difference
Cold 1.15m +220.00ms
Cached 1.75s +57.00ms

Cold Bundles

Bundle Size Difference Time Difference
dist/index.8c8b3b51.js 1.77mb -2.00b 🚀 20.03s -37.00ms
dist/index.d54c25c2.js 694.58kb +11.00b ⚠️ 53.17s +167.00ms
dist/heading4.62b9719b.js 1.25kb +0.00b 33.15s +11.63s ⚠️

Cached Bundles

Bundle Size Difference Time Difference
dist/index.1516121a.js 1.77mb +0.00b 20.01s -1.11s 🚀
dist/index.3821a6ef.js 694.58kb +15.00b ⚠️ 53.49s -696.00ms
dist/component.1770ae14.js 37.33kb +0.00b 20.01s -1.11s 🚀
dist/component.97a60d93.js 24.93kb +0.00b 20.01s -1.11s 🚀
dist/component.2de9ac3a.js 6.81kb +0.00b 19.78s -1.12s 🚀
dist/16.7b42ca8a.js 2.33kb +0.00b 20.01s -1.11s 🚀
dist/date.c0482a02.js 1.85kb +0.00b 20.01s -1.11s 🚀
dist/images.c21e6480.js 1.79kb +0.00b 21.51s -1.20s 🚀
dist/16.f3960d82.js 1.72kb +0.00b 19.78s -1.12s 🚀
dist/16.3aec39cf.js 1.66kb +0.00b 19.77s -1.12s 🚀
dist/list-number.e0420e0c.js 1.58kb +0.00b 21.51s -1.20s 🚀
dist/status.f223f976.js 1.58kb +0.00b 21.51s -1.20s 🚀
dist/code.cd95a955.js 1.50kb +0.00b 20.00s -1.11s 🚀
dist/heading3.33ac6e42.js 1.48kb +0.00b 21.51s -1.20s 🚀
dist/link.7487dc5e.js 1.42kb +0.00b 21.51s -1.20s 🚀
dist/16.332fbe28.js 1.37kb +0.00b 19.78s -1.12s 🚀
dist/emoji.03d3d99b.js 1.34kb +0.00b 21.51s -1.20s 🚀
dist/16.79a0250b.js 1.33kb +0.00b 19.77s -1.12s 🚀
dist/16.a877725f.js 1.33kb +0.00b 19.77s -1.12s 🚀
dist/16.0eecfc6b.js 1.30kb +0.00b 19.78s -1.12s 🚀
dist/heading2.d374048d.js 1.30kb +0.00b 21.51s -1.20s 🚀
dist/16.01994bf0.js 1.30kb +0.00b 19.78s -1.12s 🚀
dist/16.00ba62db.js 1.27kb +0.00b 19.78s -1.12s 🚀
dist/heading4.62b9719b.js 1.25kb +0.00b 21.51s -1.20s 🚀
dist/16.8e758d30.js 1.22kb +0.00b 19.78s -1.12s 🚀
dist/16.0555a5c0.js 1.19kb +0.00b 19.77s -1.12s 🚀
dist/16.b114a692.js 1.18kb +0.00b 19.78s -1.12s 🚀
dist/mention.37efe6c4.js 1.18kb +0.00b 21.51s -1.20s 🚀
dist/16.e21a2218.js 1.18kb +0.00b 19.78s -1.12s 🚀
dist/layout.01a386bd.js 1.16kb +0.00b 21.51s -1.20s 🚀
dist/heading1.a1828016.js 1.15kb +0.00b 21.51s -1.20s 🚀
dist/divider.601227e8.js 1.14kb +0.00b 21.51s -1.20s 🚀
dist/quote.bb9e77b1.js 1.14kb +0.00b 21.51s -1.20s 🚀
dist/16.922eddd1.js 1.13kb +0.00b 19.78s -1.12s 🚀
dist/16.e92739d9.js 1.13kb +0.00b 19.77s -1.12s 🚀
dist/16.92a42544.js 1.12kb +0.00b 19.77s -1.12s 🚀
dist/16.e5c3bc4c.js 1.12kb +0.00b 19.78s -1.12s 🚀
dist/16.0358f7c7.js 1.12kb +0.00b 19.78s -1.12s 🚀
dist/action.9e337641.js 1.12kb +0.00b 20.01s -1.11s 🚀
dist/16.455c97fa.js 1.12kb +0.00b 19.78s -1.12s 🚀
dist/component.edb11b95.js 1.11kb +0.00b 20.01s -1.11s 🚀
dist/decision.9b91a34d.js 1.10kb +0.00b 21.51s -1.20s 🚀
dist/panel-warning.2ec3e2eb.js 1.10kb +0.00b 21.51s -1.20s 🚀
dist/16.b221eda2.js 1.08kb +0.00b 19.77s -1.12s 🚀
dist/list.13abafe4.js 1.07kb +0.00b 21.51s -1.20s 🚀
dist/16.cc9a820b.js 1.04kb +0.00b 19.78s -1.12s 🚀
dist/panel-error.9e60042f.js 1024.00b +0.00b 21.51s -1.20s 🚀
dist/panel.d9a0dff6.js 1015.00b +0.00b 21.51s -1.20s 🚀
dist/table.10221eb5.js 1007.00b +0.00b 21.51s -1.20s 🚀
dist/panel-success.6b7c55df.js 963.00b +0.00b 21.51s -1.20s 🚀
dist/panel-note.1f570859.js 959.00b +0.00b 21.51s -1.20s 🚀

Three.js ✅

Timings

Description Time Difference
Cold 7.21s -297.00ms
Cached 382.00ms -19.00ms

Cold Bundles

No bundle changes detected.

Cached Bundles

No bundle changes detected.

Click here to view a detailed benchmark overview.

Copy link
Member

@DeMoorJasper DeMoorJasper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

I thought there was originally a reason we didn't lazily install it though, pretty sure it was even based on feedback from users, sharp is a pretty large package and installs native code so maybe it was freezing the process for multiple minutes for some users

@devongovett
Copy link
Member Author

Hmm, well at least it will only be installed if actually used... let's see how it goes.

@devongovett devongovett merged commit 24b2a8b into v2 Aug 31, 2021
@devongovett devongovett deleted the lazy-sharp branch August 31, 2021 05:16
lettertwo added a commit that referenced this pull request Sep 10, 2021
* v2: (69 commits)
  Use yarnpkg registry for all the things (#6908)
  Fix issue about loading configs from tsconfig.json (#6881)
  Add `@section` to Compressor type (#6885)
  Parcel API improvements (#6866)
  Use stream-browserify for polyfilling instead (#6863)
  Add support for compressor plugins (#6776)
  Support for inline style attributes and inline scripts in SVG (#6797)
  Bump less (#6852)
  Make sure (non-React) SVGs are in separate bundles (#6757)
  Add support for injecting manifest into service workers (#6798)
  Fix 'does not export default' error with scope hoisting and url/worklet pipeline (#6803)
  Remaining cargo clippy fixes (#6829)
  Lazily install sharp only when needed (#6816)
  More cargo clippy suggestions (#6811)
  Don't emit runtime manifest for inline child bundles (#6807)
  Apply suggestions from rust-clippy (#6256)
  Fix add directoryExists function to matchFiles call. (#6784)
  Upgrade to Flow 158 (#6763)
  Revert "added cio headers (#6404)" (#6789)
  Process CSS in SVGs (#6743)
  ...
lettertwo added a commit that referenced this pull request Sep 10, 2021
* v2: (38 commits)
  Use yarnpkg registry for all the things (#6908)
  Fix issue about loading configs from tsconfig.json (#6881)
  Add `@section` to Compressor type (#6885)
  Parcel API improvements (#6866)
  Use stream-browserify for polyfilling instead (#6863)
  Add support for compressor plugins (#6776)
  Support for inline style attributes and inline scripts in SVG (#6797)
  Bump less (#6852)
  Make sure (non-React) SVGs are in separate bundles (#6757)
  Add support for injecting manifest into service workers (#6798)
  Fix 'does not export default' error with scope hoisting and url/worklet pipeline (#6803)
  Remaining cargo clippy fixes (#6829)
  Lazily install sharp only when needed (#6816)
  More cargo clippy suggestions (#6811)
  Don't emit runtime manifest for inline child bundles (#6807)
  Apply suggestions from rust-clippy (#6256)
  Fix add directoryExists function to matchFiles call. (#6784)
  Upgrade to Flow 158 (#6763)
  Revert "added cio headers (#6404)" (#6789)
  Process CSS in SVGs (#6743)
  ...
lettertwo added a commit that referenced this pull request Sep 11, 2021
* bdo/number-edgetypes: (70 commits)
  Use yarnpkg registry for all the things (#6908)
  Fix issue about loading configs from tsconfig.json (#6881)
  Add `@section` to Compressor type (#6885)
  Parcel API improvements (#6866)
  Use stream-browserify for polyfilling instead (#6863)
  Add support for compressor plugins (#6776)
  Support for inline style attributes and inline scripts in SVG (#6797)
  Bump less (#6852)
  Make sure (non-React) SVGs are in separate bundles (#6757)
  Add support for injecting manifest into service workers (#6798)
  Fix 'does not export default' error with scope hoisting and url/worklet pipeline (#6803)
  Remaining cargo clippy fixes (#6829)
  Lazily install sharp only when needed (#6816)
  More cargo clippy suggestions (#6811)
  Don't emit runtime manifest for inline child bundles (#6807)
  Apply suggestions from rust-clippy (#6256)
  Fix add directoryExists function to matchFiles call. (#6784)
  Upgrade to Flow 158 (#6763)
  Revert "added cio headers (#6404)" (#6789)
  Process CSS in SVGs (#6743)
  ...
lettertwo added a commit that referenced this pull request Sep 13, 2021
* v2: (38 commits)
  Use yarnpkg registry for all the things (#6908)
  Fix issue about loading configs from tsconfig.json (#6881)
  Add `@section` to Compressor type (#6885)
  Parcel API improvements (#6866)
  Use stream-browserify for polyfilling instead (#6863)
  Add support for compressor plugins (#6776)
  Support for inline style attributes and inline scripts in SVG (#6797)
  Bump less (#6852)
  Make sure (non-React) SVGs are in separate bundles (#6757)
  Add support for injecting manifest into service workers (#6798)
  Fix 'does not export default' error with scope hoisting and url/worklet pipeline (#6803)
  Remaining cargo clippy fixes (#6829)
  Lazily install sharp only when needed (#6816)
  More cargo clippy suggestions (#6811)
  Don't emit runtime manifest for inline child bundles (#6807)
  Apply suggestions from rust-clippy (#6256)
  Fix add directoryExists function to matchFiles call. (#6784)
  Upgrade to Flow 158 (#6763)
  Revert "added cio headers (#6404)" (#6789)
  Process CSS in SVGs (#6743)
  ...
lettertwo added a commit that referenced this pull request Sep 13, 2021
* bdo/number-edgetypes: (70 commits)
  Use yarnpkg registry for all the things (#6908)
  Fix issue about loading configs from tsconfig.json (#6881)
  Add `@section` to Compressor type (#6885)
  Parcel API improvements (#6866)
  Use stream-browserify for polyfilling instead (#6863)
  Add support for compressor plugins (#6776)
  Support for inline style attributes and inline scripts in SVG (#6797)
  Bump less (#6852)
  Make sure (non-React) SVGs are in separate bundles (#6757)
  Add support for injecting manifest into service workers (#6798)
  Fix 'does not export default' error with scope hoisting and url/worklet pipeline (#6803)
  Remaining cargo clippy fixes (#6829)
  Lazily install sharp only when needed (#6816)
  More cargo clippy suggestions (#6811)
  Don't emit runtime manifest for inline child bundles (#6807)
  Apply suggestions from rust-clippy (#6256)
  Fix add directoryExists function to matchFiles call. (#6784)
  Upgrade to Flow 158 (#6763)
  Revert "added cio headers (#6404)" (#6789)
  Process CSS in SVGs (#6743)
  ...
lettertwo added a commit that referenced this pull request Sep 13, 2021
* v2: (42 commits)
  Remove dead link to docs in diagnostic (#6913)
  Fix engines.parcel in SVG packager (#6911)
  Use imported Readable flow type instead of global (#6910)
  Use non-deprecated SVGO options in HTMLNanoOptimizer (#6785)
  Use yarnpkg registry for all the things (#6908)
  Fix issue about loading configs from tsconfig.json (#6881)
  Add `@section` to Compressor type (#6885)
  Parcel API improvements (#6866)
  Use stream-browserify for polyfilling instead (#6863)
  Add support for compressor plugins (#6776)
  Support for inline style attributes and inline scripts in SVG (#6797)
  Bump less (#6852)
  Make sure (non-React) SVGs are in separate bundles (#6757)
  Add support for injecting manifest into service workers (#6798)
  Fix 'does not export default' error with scope hoisting and url/worklet pipeline (#6803)
  Remaining cargo clippy fixes (#6829)
  Lazily install sharp only when needed (#6816)
  More cargo clippy suggestions (#6811)
  Don't emit runtime manifest for inline child bundles (#6807)
  Apply suggestions from rust-clippy (#6256)
  ...
lettertwo added a commit that referenced this pull request Sep 13, 2021
* v2: (42 commits)
  Remove dead link to docs in diagnostic (#6913)
  Fix engines.parcel in SVG packager (#6911)
  Use imported Readable flow type instead of global (#6910)
  Use non-deprecated SVGO options in HTMLNanoOptimizer (#6785)
  Use yarnpkg registry for all the things (#6908)
  Fix issue about loading configs from tsconfig.json (#6881)
  Add `@section` to Compressor type (#6885)
  Parcel API improvements (#6866)
  Use stream-browserify for polyfilling instead (#6863)
  Add support for compressor plugins (#6776)
  Support for inline style attributes and inline scripts in SVG (#6797)
  Bump less (#6852)
  Make sure (non-React) SVGs are in separate bundles (#6757)
  Add support for injecting manifest into service workers (#6798)
  Fix 'does not export default' error with scope hoisting and url/worklet pipeline (#6803)
  Remaining cargo clippy fixes (#6829)
  Lazily install sharp only when needed (#6816)
  More cargo clippy suggestions (#6811)
  Don't emit runtime manifest for inline child bundles (#6807)
  Apply suggestions from rust-clippy (#6256)
  ...
lettertwo added a commit that referenced this pull request Sep 13, 2021
* bdo/number-edgetypes: (74 commits)
  Remove dead link to docs in diagnostic (#6913)
  Fix engines.parcel in SVG packager (#6911)
  Use imported Readable flow type instead of global (#6910)
  Use non-deprecated SVGO options in HTMLNanoOptimizer (#6785)
  Use yarnpkg registry for all the things (#6908)
  Fix issue about loading configs from tsconfig.json (#6881)
  Add `@section` to Compressor type (#6885)
  Parcel API improvements (#6866)
  Use stream-browserify for polyfilling instead (#6863)
  Add support for compressor plugins (#6776)
  Support for inline style attributes and inline scripts in SVG (#6797)
  Bump less (#6852)
  Make sure (non-React) SVGs are in separate bundles (#6757)
  Add support for injecting manifest into service workers (#6798)
  Fix 'does not export default' error with scope hoisting and url/worklet pipeline (#6803)
  Remaining cargo clippy fixes (#6829)
  Lazily install sharp only when needed (#6816)
  More cargo clippy suggestions (#6811)
  Don't emit runtime manifest for inline child bundles (#6807)
  Apply suggestions from rust-clippy (#6256)
  ...
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

3 participants