diff options
author | 2021-06-09 13:26:30 -0700 | |
---|---|---|
committer | 2021-06-09 13:26:30 -0700 | |
commit | ecda693e3844511644a177a0bcb146bda07effb9 (patch) | |
tree | e032597bdae3e8229a88042d1ae2b978ef63e056 /src/cli.zig | |
parent | 6a4712f4c90ef7f1bb858ea81fe3d11ea60b036e (diff) | |
download | bun-ecda693e3844511644a177a0bcb146bda07effb9.tar.gz bun-ecda693e3844511644a177a0bcb146bda07effb9.tar.zst bun-ecda693e3844511644a177a0bcb146bda07effb9.zip |
lots
Former-commit-id: 7346cdaa5a32ade26821ed97ef07f7c9ae87c0c2
Diffstat (limited to 'src/cli.zig')
-rw-r--r-- | src/cli.zig | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/src/cli.zig b/src/cli.zig index 472c6ac02..c6b1c38bd 100644 --- a/src/cli.zig +++ b/src/cli.zig @@ -132,7 +132,9 @@ pub const Cli = struct { clap.parseParam("--platform <STR> \"browser\" or \"node\". Defaults to \"browser\"") catch unreachable, clap.parseParam("--main-fields <STR>... Main fields to lookup in package.json. Defaults to --platform dependent") catch unreachable, clap.parseParam("--scan Instead of bundling or transpiling, print a list of every file imported by an entry point, recursively") catch unreachable, - clap.parseParam("--jsb Generate a new node_modules.jsb file from node_modules and entry point(s)") catch unreachable, + clap.parseParam("--new-jsb Generate a new node_modules.jsb file from node_modules and entry point(s)") catch unreachable, + clap.parseParam("--jsb <STR> Use a Speedy JavaScript Bundle (default: \"./node_modules.jsb\" if exists)") catch unreachable, + // clap.parseParam("--no-jsb Use a Speedy JavaScript Bundle (default: \"./node_modules.jsb\" if exists)") catch unreachable, clap.parseParam("<POS>... Entry points to use") catch unreachable, }; @@ -186,6 +188,22 @@ pub const Cli = struct { var react_fast_refresh = args.flag("--react-fast-refresh"); var main_fields = args.options("--main-fields"); + var node_modules_bundle_path = args.option("--jsb") orelse brk: { + if (args.flag("--new-jsb")) { + break :brk null; + } + + const node_modules_bundle_path_absolute = resolve_path.joinAbs(cwd, .auto, "node_modules.jsb"); + std.fs.accessAbsolute(node_modules_bundle_path_absolute, .{}) catch |err| { + break :brk null; + }; + break :brk try allocator.dupe(u8, node_modules_bundle_path_absolute); + }; + + if (args.flag("--new-jsb")) { + node_modules_bundle_path = null; + } + const PlatformMatcher = strings.ExactSizeMatcher(8); const ResoveMatcher = strings.ExactSizeMatcher(8); @@ -266,10 +284,15 @@ pub const Cli = struct { .absolute_working_dir = cwd, .tsconfig_override = tsconfig_override, .public_url = public_url, - .define_keys = define_keys, - .define_values = define_values, - .loader_keys = loader_keys, - .loader_values = loader_values, + .define = .{ + .keys = define_keys, + .values = define_values, + }, + .loaders = .{ + .extensions = loader_keys, + .loaders = loader_values, + }, + .node_modules_bundle_path = node_modules_bundle_path, .public_dir = if (args.option("--public-dir")) |public_dir| allocator.dupe(u8, public_dir) catch unreachable else null, .write = write, .serve = serve, @@ -279,7 +302,7 @@ pub const Cli = struct { .main_fields = args.options("--main-fields"), .platform = platform, .only_scan_dependencies = if (args.flag("--scan")) Api.ScanDependencyMode.all else Api.ScanDependencyMode._none, - .generate_node_module_bundle = if (args.flag("--jsb")) true else false, + .generate_node_module_bundle = if (args.flag("--new-jsb")) true else false, }; } }; @@ -363,6 +386,13 @@ pub const Cli = struct { args, ); }, + .lazy => { + result = try bundler.ServeBundler.bundle( + allocator, + &log, + args, + ); + }, else => { result = try bundler.Bundler.bundle( allocator, |