Commit df9c9b4
committed
Add a rollup plugin for tree shaking Emscripten output.
Rollup has built in tree shaking which can inform the plugin which exports
are no longer used. If those exports correspond to wasm exports they can
potentially be removed from wasm file too.
Overview:
While the modules are parsed, we collect info about the exports before any
tree shaking occurs to build a map from ESM export name to Wasm export
name and info about the local function name within the JS e.g. _foo.
During bundle generation rollup provides a list of exports that are
removed. We then try to match the removed exports to Wasm exports. However,
they all cannot simply be removed though since they may be used internally
in the file still. A new list of the used wasm exports is generated and
passed to wasm-metadce to remove any unused exports.
Note: there are a lot more things we could do there, but this seemed like
a good stopping point. It also shows that even for specific output, tree
shaking is hard to do soundly for dynamically loaded wasm.1 parent e26084f commit df9c9b4
File tree
10 files changed
+379
-0
lines changed- test
- rollup_plugin
- tools/rollup-plugin-emscripten
- src
10 files changed
+379
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15804 | 15804 | | |
15805 | 15805 | | |
15806 | 15806 | | |
| 15807 | + | |
| 15808 | + | |
| 15809 | + | |
| 15810 | + | |
| 15811 | + | |
| 15812 | + | |
| 15813 | + | |
| 15814 | + | |
| 15815 | + | |
| 15816 | + | |
| 15817 | + | |
| 15818 | + | |
| 15819 | + | |
| 15820 | + | |
| 15821 | + | |
| 15822 | + | |
| 15823 | + | |
| 15824 | + | |
| 15825 | + | |
| 15826 | + | |
| 15827 | + | |
| 15828 | + | |
| 15829 | + | |
| 15830 | + | |
| 15831 | + | |
| 15832 | + | |
| 15833 | + | |
15807 | 15834 | | |
15808 | 15835 | | |
15809 | 15836 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
0 commit comments