diff options
Diffstat (limited to 'src/cli.zig')
-rw-r--r-- | src/cli.zig | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/cli.zig b/src/cli.zig index 3f796e798..171593246 100644 --- a/src/cli.zig +++ b/src/cli.zig @@ -141,7 +141,6 @@ pub const Arguments = struct { clap.parseParam("--jsx-factory <STR> Changes the function called when compiling JSX elements using the classic JSX runtime") catch unreachable, clap.parseParam("--jsx-fragment <STR> Changes the function called when compiling JSX fragments") catch unreachable, clap.parseParam("--jsx-import-source <STR> Declares the module specifier to be used for importing the jsx and jsxs factory functions. Default: \"react\"") catch unreachable, - clap.parseParam("--jsx-production Use jsx instead of jsxDEV (default) for the automatic runtime") catch unreachable, clap.parseParam("--jsx-runtime <STR> \"automatic\" (default) or \"classic\"") catch unreachable, clap.parseParam("-r, --preload <STR>... Import a module before other modules are loaded") catch unreachable, clap.parseParam("--main-fields <STR>... Main fields to lookup in package.json. Defaults to --target dependent") catch unreachable, @@ -194,6 +193,7 @@ pub const Arguments = struct { pub const params = public_params ++ debug_params; const build_only_params = [_]ParamType{ + clap.parseParam("--format <STR> Specifies the module format to build to. Only esm is supported.") catch unreachable, clap.parseParam("--outdir <STR> Default to \"dist\" if multiple files") catch unreachable, clap.parseParam("--outfile <STR> Write to a file") catch unreachable, clap.parseParam("--splitting Enable code splitting") catch unreachable, @@ -489,6 +489,20 @@ pub const Arguments = struct { } } + if (args.option("--format")) |format_str| { + const format = options.Format.fromString(format_str) orelse { + Output.prettyErrorln("<r><red>error<r>: Invalid format - must be esm, cjs, or iife", .{}); + Global.crash(); + }; + switch (format) { + .esm => {}, + else => { + Output.prettyErrorln("<r><red>error<r>: Formats besides 'esm' are not implemented", .{}); + Global.crash(); + }, + } + } + if (args.flag("--splitting")) { ctx.bundler_options.code_splitting = true; } @@ -569,9 +583,8 @@ pub const Arguments = struct { var jsx_fragment = args.option("--jsx-fragment"); var jsx_import_source = args.option("--jsx-import-source"); var jsx_runtime = args.option("--jsx-runtime"); - var jsx_production = args.flag("--jsx-production"); const react_fast_refresh = switch (comptime cmd) { - .DevCommand => !(args.flag("--disable-react-fast-refresh") or jsx_production), + .DevCommand => !args.flag("--disable-react-fast-refresh"), else => true, }; @@ -689,7 +702,7 @@ pub const Arguments = struct { jsx_fragment != null or jsx_import_source != null or jsx_runtime != null or - jsx_production or !react_fast_refresh) + !react_fast_refresh) { var default_factory = "".*; var default_fragment = "".*; @@ -700,7 +713,7 @@ pub const Arguments = struct { .fragment = constStrToU8(jsx_fragment orelse &default_fragment), .import_source = constStrToU8(jsx_import_source orelse &default_import_source), .runtime = if (jsx_runtime != null) try resolve_jsx_runtime(jsx_runtime.?) else Api.JsxRuntime.automatic, - .development = !jsx_production, + .development = false, .react_fast_refresh = react_fast_refresh, }; } else { @@ -709,7 +722,7 @@ pub const Arguments = struct { .fragment = constStrToU8(jsx_fragment orelse opts.jsx.?.fragment), .import_source = constStrToU8(jsx_import_source orelse opts.jsx.?.import_source), .runtime = if (jsx_runtime != null) try resolve_jsx_runtime(jsx_runtime.?) else opts.jsx.?.runtime, - .development = !jsx_production, + .development = false, .react_fast_refresh = react_fast_refresh, }; } |