Repository navigation
bundler: keep source order in a wrapper prefix that has no async dependency #41601
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
Closed
Closed
Changes from all commits
Commits
Show all changes
49 commits
Select commit
Hold shift + click to select a range
bada17a
bundler: evaluate a wrapped module's dependencies in source order and…
robobun 44fb00d
test: update the libraries.js bytecode snapshot for the dependency or…
robobun 5f7d42a
bundler: shorten the comments on the wrapper prefix and async propaga…
robobun be90257
bundler: mark __promiseAll live for the __reExport of the first async…
robobun 6904566
bundler: join async dependencies with Promise.all and call import() t…
robobun 46f615f
test: regenerate the async wrapper snapshots for Promise.all and the …
robobun 9f8c400
ci: retrigger
robobun 184b4e0
bundler: discard the value of a joined require or __reExport so Promi…
robobun d47c137
Merge branch 'main' into robobun/46e46b5b/bundler-wrapper-init-order
robobun 50c815f
test: a CommonJS import before a wrapped ES module import runs first …
robobun de69ca3
test: update the libraries.js bytecode snapshot for the dependency or…
robobun 479d178
test: expect the import() form of an async module in UsingWithHoistab…
robobun 2e3caf9
test: pin the rejection that ExportStarOfRejectedAsyncDependencyRejec…
robobun 37b107f
bundler: join statements that can throw through a generator so a star…
robobun 4100a21
bundler: optional spaces around the import() retry, and a test for a …
robobun 5402f83
bundler: convert a joined declaration only when every binding is an i…
robobun 990b9e9
bundler: shorten the doc comment of the wrapper prefix
robobun 31cd4dd
bundler: keep the await of one async dependency bare, and skip it for…
robobun 6700468
test: regenerate the async wrapper snapshots for the conditional await
robobun d104be9
test: build the async import cycle with both source index orders of i…
robobun ccbc1ab
bundler: shorten the comments of the wrapper prefix
robobun 184d3e6
bundler: one-line comments at the statements the wrapper prefix emits…
robobun 1aefaeb
Merge remote-tracking branch 'origin/main' into robobun/46e46b5b/bund…
robobun fc0581c
Merge remote-tracking branch 'origin/main' into robobun/46e46b5b/bund…
robobun 09d9c21
test: pin the libraries.js bundle and bytecode hashes of the tree mer…
robobun dba3c27
Merge remote-tracking branch 'origin/main' into robobun/46e46b5b/bund…
robobun f117e32
test: pin the libraries.js bytecode hash of the tree merged with main
robobun 49b0642
bundler: start an import()ed async module after the caller's synchron…
robobun 587e1d7
Merge remote-tracking branch 'origin/main' into robobun/46e46b5b/bund…
robobun b41fec6
bundler: await an async dependency with a bare await, and drop the as…
robobun a3a5113
test: pin the libraries.js bundle and bytecode hashes of the tree mer…
robobun 2c90d79
bundler: print shorter forms for the rejection handler and the import…
robobun 3c299f9
test: import() cases for a caller in an import cycle and for an impor…
robobun 8771df1
Merge remote-tracking branch 'origin/main' into robobun/46e46b5b/bund…
robobun 41ba934
bundler: keep main's prefix layout after the first async dependency
robobun 2e5aedc
test: re-cut the order cases, pin the known losses, and add an unspli…
robobun 2fb1b77
test: a todo case for the importer of an async import cycle member
robobun 75c5638
test: pin an import() in an export * dependency that runs before the …
robobun 38ddf82
bundler: leave an export star of an async module as on main
robobun c347be9
bundler: print main's prefix layout from an async export star on
robobun 87491b1
Merge remote-tracking branch 'origin/main' into robobun/46e46b5b/bund…
robobun 612deb6
bundler: keep source order only in a wrapper prefix with no async dep…
robobun 9eda6aa
bundler: shorten the doc comment of leave_source_order
robobun 6d64d37
Merge remote-tracking branch 'origin/main' into robobun/46e46b5b/bund…
robobun 076cd9f
test: a plain bundle in code-from-disk now runs its CommonJS import f…
robobun e3a598a
bundler: test the wrapper prefix layout for every short list, and the…
robobun 392f790
Merge remote-tracking branch 'origin/main' into robobun/46e46b5b/bund…
robobun ba6d620
test: say when bun runs the sources of the case with a CommonJS file …
robobun c9eff65
bundler: one line for the comment of the expected layout in the wrapp…
robobun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,31 +1,45 @@ | ||
| // bun scripts/splitting-fuzz.ts <bun> <graphs> [first seed] | ||
| // bun scripts/splitting-fuzz.ts <bun> <graphs> [first seed] [--unsplit [--baseline=<bun>]] | ||
| // Runs test/bundler/splitting-fuzz.ts over many seeds against <bun> and prints the seeds where chunk folding made a | ||
| // bundle worse than the unfolded one (rerun a seed with `<graphs>` = 1 to look at it). | ||
| // bundle worse than the unfolded one (rerun a seed with `<graphs>` = 1 to look at it). With --unsplit it builds each | ||
| // graph without code splitting and prints the seeds where the bundle differs from the unbundled program. With a | ||
| // baseline binary it prints the seeds where the bundle is worse than the one that the baseline builds. | ||
| import { resolve } from "node:path"; | ||
| import { checkGraph } from "../test/bundler/splitting-fuzz"; | ||
| import { checkGraph, checkUnsplit } from "../test/bundler/splitting-fuzz"; | ||
|
|
||
| const [bun, count = "100", first = "1"] = process.argv.slice(2); | ||
| if (!bun) { | ||
| console.error("usage: bun scripts/splitting-fuzz.ts <bun> <graphs> [first seed]"); | ||
| const flags = process.argv.slice(2).filter(arg => arg.startsWith("--")); | ||
| const [bun, count = "100", first = "1"] = process.argv.slice(2).filter(arg => !arg.startsWith("--")); | ||
| const unsplit = flags.includes("--unsplit"); | ||
| const baselineFlag = flags.find(flag => flag.startsWith("--baseline=")); | ||
| if (!bun || (baselineFlag && !unsplit)) { | ||
| console.error("usage: bun scripts/splitting-fuzz.ts <bun> <graphs> [first seed] [--unsplit [--baseline=<bun>]]"); | ||
| process.exit(1); | ||
| } | ||
| const target = Bun.which(bun) ?? resolve(bun); | ||
| const tally = { ok: 0, skipped: 0, worse: 0, folded: 0 }; | ||
| const binary = (name: string) => Bun.which(name) ?? resolve(name); | ||
| const target = binary(bun); | ||
| const baseline = baselineFlag ? binary(baselineFlag.slice("--baseline=".length)) : undefined; | ||
| const tally = { ok: 0, skipped: 0, worse: 0, different: 0, folded: 0, unjudged: 0 }; | ||
| const parallel = 8; | ||
| const end = Number(first) + Number(count); | ||
| for (let seed = Number(first); seed < end; seed += parallel) { | ||
| const batch = []; | ||
| for (let s = seed; s < Math.min(end, seed + parallel); s++) batch.push(checkGraph(target, s)); | ||
| for (let s = seed; s < Math.min(end, seed + parallel); s++) { | ||
| batch.push(unsplit ? checkUnsplit(target, s, baseline) : checkGraph(target, s)); | ||
| } | ||
| for (const result of await Promise.all(batch)) { | ||
| tally[result.status]++; | ||
| if (result.folded) tally.folded++; | ||
| if (result.status !== "ok") | ||
| console.log(`seed ${result.seed} ${result.status}:\n ` + result.problems.slice(0, 6).join("\n ")); | ||
| if ("folded" in result && result.folded) tally.folded++; | ||
| const unjudged = "unjudged" in result ? result.unjudged.map(why => "no verdict: " + why) : []; | ||
| if (unjudged.length) tally.unjudged++; | ||
| if (result.status !== "ok" || unjudged.length) { | ||
| console.log( | ||
| `seed ${result.seed} ${result.status}:\n ` + [...result.problems.slice(0, 6), ...unjudged].join("\n "), | ||
| ); | ||
| } | ||
| } | ||
| } | ||
| console.log(JSON.stringify({ graphs: Number(count), firstSeed: Number(first), ...tally })); | ||
| // Folding changes about one graph in sixteen. | ||
| if (tally.folded === 0 && Number(count) >= 200 && tally.skipped < Number(count)) { | ||
| if (!unsplit && tally.folded === 0 && Number(count) >= 200 && tally.skipped < Number(count)) { | ||
| console.error("folding changed no bundle: does <bun> read foldChunksForTesting (--expose-internals gate)?"); | ||
| process.exit(1); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.