Repository navigation
Introduce bytecode caching, polish "cjs" bundler output format
#14232
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
Merged
Merged
Changes from 10 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
b67a063
Introduce bytecode caching
Jarred-Sumner 0cdd905
Fix makefile for building webkit
Jarred-Sumner 5ea6e1d
we are caching
Jarred-Sumner 3342dca
Several bugfixes to CommonJS bundling
Jarred-Sumner d8a352e
Update default.test.ts
Jarred-Sumner 4f27596
Update SetupWebKit.cmake
Jarred-Sumner 75bd6f8
We resolve require.resolve
Jarred-Sumner cb6849a
Emit use strict
Jarred-Sumner b499fd2
POSSIBLY BREAKING: don't create module namespace object wrapper
Jarred-Sumner d2f7676
Fix tests
Jarred-Sumner 5c410dd
Set bytecode cache to a known version
Jarred-Sumner 38b6d52
Update ZigGlobalObject.cpp
Jarred-Sumner aa20532
Ban TLA in CJS
Jarred-Sumner 9059d89
Support bytecode & cjs in `bun build --compile`
Jarred-Sumner 478001d
works now.
Jarred-Sumner be9352e
Update bundler_compile.test.ts
Jarred-Sumner 20a3a46
Update some docs
Jarred-Sumner 726b717
Update executables.md
Jarred-Sumner b847a4e
Update index.md
Jarred-Sumner 9b3dda3
oops
Jarred-Sumner f1c5a35
Add an API test
Jarred-Sumner 7b9cb2e
Update cli.zig
Jarred-Sumner 8b1c0ed
cjs
Jarred-Sumner 5d9f9e9
Stricter validations
Jarred-Sumner 3fd10bb
Comment
Jarred-Sumner 3a0c81c
Update bundle_v2.zig
Jarred-Sumner 1705d95
Update src/bun.js/module_loader.zig
Jarred-Sumner df43b7e
Update expectBundled.ts
Jarred-Sumner eeaaf19
Update build_command.zig
Jarred-Sumner 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
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
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
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -479,6 +479,7 @@ pub const RuntimeTranspilerStore = struct { | |||||
| setBreakPointOnFirstLine(), | ||||||
| .runtime_transpiler_cache = if (!JSC.RuntimeTranspilerCache.is_disabled) &cache else null, | ||||||
| .remove_cjs_module_wrapper = is_main and vm.module_loader.eval_source != null, | ||||||
| .allow_bytecode_cache = true, | ||||||
| }; | ||||||
|
|
||||||
| defer { | ||||||
|
|
@@ -573,15 +574,19 @@ pub const RuntimeTranspilerStore = struct { | |||||
| return; | ||||||
| } | ||||||
|
|
||||||
| if (parse_result.already_bundled) { | ||||||
| if (parse_result.already_bundled != .none) { | ||||||
| const duped = String.createUTF8(specifier); | ||||||
| const bytecode_slice = parse_result.already_bundled.bytecodeSlice(); | ||||||
| this.resolved_source = ResolvedSource{ | ||||||
| .allocator = null, | ||||||
| .source_code = bun.String.createLatin1(parse_result.source.contents), | ||||||
| .specifier = duped, | ||||||
| .source_url = duped.createIfDifferent(path.text), | ||||||
| .already_bundled = true, | ||||||
| .hash = 0, | ||||||
| .bytecode_cache = if (bytecode_slice.len > 0) bytecode_slice.ptr else null, | ||||||
| .bytecode_cache_size = if (bytecode_slice.len > 0) bytecode_slice.len else 0, | ||||||
|
Jarred-Sumner marked this conversation as resolved.
Resolved
|
||||||
| .is_commonjs_module = parse_result.already_bundled.isCommonJS(), | ||||||
| }; | ||||||
| this.resolved_source.source_code.ensureHash(); | ||||||
| return; | ||||||
|
|
@@ -1615,6 +1620,7 @@ pub const ModuleLoader = struct { | |||||
| .allow_commonjs = true, | ||||||
| .inject_jest_globals = jsc_vm.bundler.options.rewrite_jest_for_tests and is_main, | ||||||
| .keep_json_and_toml_as_one_statement = true, | ||||||
| .allow_bytecode_cache = true, | ||||||
| .set_breakpoint_on_first_line = is_main and | ||||||
| jsc_vm.debugger != null and | ||||||
| jsc_vm.debugger.?.set_breakpoint_on_first_line and | ||||||
|
|
@@ -1760,14 +1766,18 @@ pub const ModuleLoader = struct { | |||||
| }; | ||||||
| } | ||||||
|
|
||||||
| if (parse_result.already_bundled) { | ||||||
| if (parse_result.already_bundled != .none) { | ||||||
| const bytecode_slice = parse_result.already_bundled.bytecodeSlice(); | ||||||
| return ResolvedSource{ | ||||||
| .allocator = null, | ||||||
| .source_code = bun.String.createLatin1(parse_result.source.contents), | ||||||
| .specifier = input_specifier, | ||||||
| .source_url = input_specifier.createIfDifferent(path.text), | ||||||
| .already_bundled = true, | ||||||
| .hash = 0, | ||||||
| .bytecode_cache = if (bytecode_slice.len > 0) bytecode_slice.ptr else null, | ||||||
| .bytecode_cache_size = if (bytecode_slice.len > 0) bytecode_slice.len else 0, | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| .is_commonjs_module = parse_result.already_bundled.isCommonJS(), | ||||||
| }; | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change looks identical to the original