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

Propagate symbols data in bundler #4375

Closed
wants to merge 2 commits into from
Closed

Propagate symbols data in bundler #4375

wants to merge 2 commits into from

Conversation

mischnic
Copy link
Member

@mischnic mischnic commented Mar 24, 2020

↪️ Pull Request

Would close #4370 and fix #4318

Instead of finding used imports per bundle, do this directly after inserting the runtimes. By directly updating asset.meta.symbols with this information, we can do cross-bundle treeshaking without major changes in the scope-hoisting code itself.

I've had to update the runtime mechanism to allow runtimes to insert themselves between an asset and a dependency (so act as a reexporting asset).

Potential downsides: getUsedExports is now single-threaded. But this is more of an API problem because

enter(bundle) {
setUsedExports(usedExports, processedDeps, bundle, bundleGraph);
},

is simply running per bundle and the resulting map could be merged later.

🚨 TODO

  • shared bundles are still not shaken
  • detect more dynamic import patterns (currently, only import("./b.js").then(({ default: b }) => ...); for testing)
  • is a JSRuntime always correctly replacing a dependency?
  • much else (CI)

For discussion:

  • create new plugin (type) instead of DefaultBundler#propagate

@height
Copy link

height bot commented Mar 24, 2020

Link Height tasks by mentioning a task ID in the pull request title or description, commit messages, or comments.

You can also use "Close T-X" to automatically close a task when the pull request is merged.

@parcel-benchmark
Copy link

parcel-benchmark commented Mar 24, 2020

Benchmark Results

packages/benchmarks/three 🚨

Timings

Description Time Difference
Cold FAILED -0.00ms
Cached FAILED -0.00ms

Cold Bundles

No bundles found, this is probably a failed build...

Cached Bundles

No bundles found, this is probably a failed build...

packages/benchmarks/kitchen-sink 🚨

Timings

Description Time Difference
Cold FAILED -0.00ms
Cached FAILED -0.00ms

Cold Bundles

No bundles found, this is probably a failed build...

Cached Bundles

No bundles found, this is probably a failed build...

packages/benchmarks/react-hn 🚨

Timings

Description Time Difference
Cold FAILED -0.00ms
Cached FAILED -0.00ms

Cold Bundles

No bundles found, this is probably a failed build...

Cached Bundles

No bundles found, this is probably a failed build...

packages/benchmarks/ak-editor 🚨

Timings

Description Time Difference
Cold FAILED -0.00ms
Cached FAILED -0.00ms

Cold Bundles

No bundles found, this is probably a failed build...

Cached Bundles

No bundles found, this is probably a failed build...

Click here to view a detailed benchmark overview.

@mischnic
Copy link
Member Author

Superseded by #4861

@mischnic mischnic closed this Jul 15, 2020
@DeMoorJasper DeMoorJasper deleted the bundler-propagate branch November 12, 2020 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tree-shaking dynamic imports
2 participants