diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/bundler.zig | 8 | ||||
-rw-r--r-- | src/js_parser.zig | 8 | ||||
-rw-r--r-- | src/options.zig | 4 |
3 files changed, 16 insertions, 4 deletions
diff --git a/src/bundler.zig b/src/bundler.zig index 3c796b576..fb0a11be7 100644 --- a/src/bundler.zig +++ b/src/bundler.zig @@ -506,7 +506,13 @@ pub const Bundler = struct { switch (this.options.env.behavior) { .prefix, .load_all => { // Step 1. Load the project root. - var dir: *Fs.FileSystem.DirEntry = ((this.resolver.readDirInfo(this.fs.top_level_dir) catch return) orelse return).getEntries(this.resolver.generation) orelse return; + const dir_info = this.resolver.readDirInfo(this.fs.top_level_dir) catch return orelse return; + + if (dir_info.tsconfig_json) |tsconfig| { + this.options.jsx = tsconfig.mergeJSX(this.options.jsx); + } + + var dir = dir_info.getEntries(this.resolver.generation) orelse return; // Process always has highest priority. const was_production = this.options.production; diff --git a/src/js_parser.zig b/src/js_parser.zig index 51627a134..33a8cef6d 100644 --- a/src/js_parser.zig +++ b/src/js_parser.zig @@ -15096,6 +15096,10 @@ fn NewParser_( if (e_.tag) |_tag| { break :tagger p.visitExpr(_tag); } else { + if (p.options.jsx.runtime == .classic) { + break :tagger p.jsxStringsToMemberExpression(expr.loc, p.options.jsx.fragment) catch unreachable; + } + break :tagger p.jsxImport(.Fragment, expr.loc); } }; @@ -15169,9 +15173,11 @@ fn NewParser_( i += @intCast(usize, @boolToInt(args[i].data != .e_missing)); } + const target = p.jsxStringsToMemberExpression(expr.loc, p.options.jsx.factory) catch unreachable; + // Call createElement() return p.newExpr(E.Call{ - .target = p.jsxImport(.createElement, expr.loc), + .target = target, .args = ExprNodeList.init(args[0..i]), // Enable tree shaking .can_be_unwrapped_if_unused = !p.options.ignore_dce_annotations, diff --git a/src/options.zig b/src/options.zig index a39c9fc6c..08eb7b4b7 100644 --- a/src/options.zig +++ b/src/options.zig @@ -1048,8 +1048,8 @@ pub const JSX = struct { } pub const Defaults = struct { - pub const Factory = &[_]string{"React.createElement"}; - pub const Fragment = &[_]string{"React.Fragment"}; + pub const Factory = &[_]string{ "React", "createElement" }; + pub const Fragment = &[_]string{ "React", "Fragment" }; pub const ImportSourceDev = "react/jsx-dev-runtime"; pub const ImportSource = "react/jsx-runtime"; pub const JSXFunction = "jsx"; |