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

Improvements to new resolver #8844

Merged
merged 2 commits into from
Feb 21, 2023
Merged

Improvements to new resolver #8844

merged 2 commits into from
Feb 21, 2023

Conversation

devongovett
Copy link
Member

This implements two improvements to the new resolver from #8807 based on feedback in #4155.

  1. The .json extension can be omitted from the tsconfig "extends" field. The behavior now matches TSC.
  2. Add support for custom package export/import conditions, which can be set by plugins on dependencies. This is used to support the sass, less, stylus, and style conditions that are supported by webpack.

For performance reasons, we store commonly used conditions as bit flags in dependencies internally, with custom conditions stored as strings. This is done transparently to plugin authors. The rust resolver also uses a similar strategy.

When packageConditions is specified on a dependencies, it overrides the default "import" and "require" conditions that are normally inferred from the specifierType. These can be included explicitly if desired. This is so dependencies in style files don't use these conditions and end up resolving to JavaScript. The environment-based conditions such as browser/node/production/development/etc are merged with these conditions.

This also adds an options parameter to the resolve function that is passed to transformers so that the specifierType and packageConditions can be customized.

specifier: &'s str,
from: &Path,
specifier_type: SpecifierType,
options: ResolveOptions,
Copy link
Member

Choose a reason for hiding this comment

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

Is there a case where there you'd want no conditions to apply (and then this should be an Option<ResolveOptions>)? Probably not..

Copy link
Member Author

Choose a reason for hiding this comment

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

You mean to disable the import/require conditions but not add any in its place? Hmm... not sure.

@parcel-benchmark
Copy link

Benchmark Results

Kitchen Sink ✅

Timings

Description Time Difference
Cold 1.85s +70.00ms
Cached 376.00ms +34.00ms ⚠️

Cold Bundles

Bundle Size Difference Time Difference
dist/legacy/parcel.7cdb0fad.webp 102.94kb +0.00b 283.00ms +35.00ms ⚠️
dist/legacy/parcel.7cdb0fad.webp 102.94kb +0.00b 284.00ms +36.00ms ⚠️
dist/modern/parcel.7cdb0fad.webp 102.94kb +0.00b 284.00ms +36.00ms ⚠️
dist/legacy/index.2c76ad23.js 1.66kb +0.00b 472.00ms +43.00ms ⚠️
dist/legacy/index.8aaa89c9.js 1.20kb +0.00b 472.00ms +42.00ms ⚠️
dist/modern/index.6be20f01.js 1.13kb +0.00b 473.00ms +44.00ms ⚠️
dist/legacy/index.html 826.00b +0.00b 600.00ms +41.00ms ⚠️
dist/modern/index.html 749.00b +0.00b 599.00ms +41.00ms ⚠️
dist/legacy/index.b8ae99ba.css 94.00b +0.00b 294.00ms +35.00ms ⚠️
dist/modern/index.31cedca9.css 94.00b +0.00b 293.00ms +35.00ms ⚠️

Cached Bundles

Bundle Size Difference Time Difference
dist/legacy/index.2c76ad23.js 1.66kb +0.00b 468.00ms +29.00ms ⚠️
dist/legacy/index.8aaa89c9.js 1.20kb +0.00b 467.00ms +28.00ms ⚠️
dist/modern/index.6be20f01.js 1.13kb +0.00b 467.00ms +27.00ms ⚠️

React HackerNews ✅

Timings

Description Time Difference
Cold 11.95s -173.00ms
Cached 486.00ms +10.00ms

Cold Bundles

No bundle changes detected.

Cached Bundles

No bundle changes detected.

AtlasKit Editor ✅

Timings

Description Time Difference
Cold 2.18m -1.18s
Cached 2.25s +24.00ms

Cold Bundles

No bundle changes detected.

Cached Bundles

No bundle changes detected.

Three.js ✅

Timings

Description Time Difference
Cold 9.45s +117.00ms
Cached 283.00ms -13.00ms

Cold Bundles

No bundle changes detected.

Cached Bundles

No bundle changes detected.

Click here to view a detailed benchmark overview.

@devongovett devongovett merged commit 19bc122 into v2 Feb 21, 2023
@devongovett devongovett deleted the resolver-fixes branch February 21, 2023 14:48
marcins pushed a commit to marcins/parcel that referenced this pull request Jul 14, 2023
* upstream/v2:
  Missing edge for multiple targets (parcel-bundler#8854)
  Split large runtime manifest into separate bundles (parcel-bundler#8837)
  Improvements to new resolver (parcel-bundler#8844)
  Fix published files for resolver
  New resolver implementation in Rust (parcel-bundler#8807)
  Update yarn.lock (parcel-bundler#8843)
  Bump napi-rs to latest (parcel-bundler#8838)
lettertwo added a commit that referenced this pull request Nov 6, 2023
* upstream/v2: (128 commits)
  [webextension] Add support for `chrome_style` (#8867)
  Switch to SWC minifier by default (#8860)
  Use BitSet for bundler intersections (#8862)
  best key logic truncating package names (#8865)
  Add support for loadConfig to resolver plugins (#8847)
  Missing edge for multiple targets (#8854)
  Split large runtime manifest into separate bundles (#8837)
  Improvements to new resolver (#8844)
  Fix published files for resolver
  New resolver implementation in Rust (#8807)
  Update yarn.lock (#8843)
  Bump napi-rs to latest (#8838)
  Support .proxyrc.cjs  (#8833)
  Sort global deps before injecting imports (#8818)
  Sort CSS module exports (#8817)
  fix: add extra information to unique bundles (#8784)
  Don't blow up HMR when <link />s don't have hrefs (#8800)
  v2.8.3
  Changelog for v2.8.3
  Address bug by updating an asset reference and merge conditions (#8762)
  ...
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