diff options
author | 2023-06-02 20:35:00 -0700 | |
---|---|---|
committer | 2023-06-02 20:35:00 -0700 | |
commit | d8e7436db02f38f74ce29b4a0e7c0efcd133ec53 (patch) | |
tree | 6606ff8423f33643260d0ddd54077519491070cf /src | |
parent | f798a0cfe8372e7df62d9514e6785e6f16549d25 (diff) | |
download | bun-d8e7436db02f38f74ce29b4a0e7c0efcd133ec53.tar.gz bun-d8e7436db02f38f74ce29b4a0e7c0efcd133ec53.tar.zst bun-d8e7436db02f38f74ce29b4a0e7c0efcd133ec53.zip |
use NODE_ENV for react-jsx or react-jsxdev (#3184)
Diffstat (limited to 'src')
-rw-r--r-- | src/bun.js/api/JSTranspiler.zig | 1 | ||||
-rw-r--r-- | src/resolver/resolver.zig | 2 | ||||
-rw-r--r-- | src/resolver/tsconfig_json.zig | 14 |
3 files changed, 6 insertions, 11 deletions
diff --git a/src/bun.js/api/JSTranspiler.zig b/src/bun.js/api/JSTranspiler.zig index c58029c5e..83e3b741f 100644 --- a/src/bun.js/api/JSTranspiler.zig +++ b/src/bun.js/api/JSTranspiler.zig @@ -464,7 +464,6 @@ fn transformOptionsFromJSC(globalObject: JSC.C.JSContextRef, temp_allocator: std &transpiler.log, logger.Source.initPathString("tsconfig.json", transpiler.tsconfig_buf), &VirtualMachine.get().bundler.resolver.caches.json, - true, ) catch null) |parsed_tsconfig| { transpiler.tsconfig = parsed_tsconfig; } diff --git a/src/resolver/resolver.zig b/src/resolver/resolver.zig index e23f00c9a..8a6a2bc5e 100644 --- a/src/resolver/resolver.zig +++ b/src/resolver/resolver.zig @@ -2332,7 +2332,7 @@ pub const Resolver = struct { const source = logger.Source.initPathString(key_path.text, entry.contents); const file_dir = source.path.sourceDir(); - var result = (try TSConfigJSON.parse(bun.fs_allocator, r.log, source, &r.caches.json, r.opts.jsx.development)) orelse return null; + var result = (try TSConfigJSON.parse(bun.fs_allocator, r.log, source, &r.caches.json)) orelse return null; if (result.hasBaseURL()) { diff --git a/src/resolver/tsconfig_json.zig b/src/resolver/tsconfig_json.zig index 7ec6b3e0b..4f04c39ca 100644 --- a/src/resolver/tsconfig_json.zig +++ b/src/resolver/tsconfig_json.zig @@ -104,9 +104,7 @@ pub const TSConfigJSON = struct { log: *logger.Log, source: logger.Source, json_cache: *cache.Json, - is_jsx_development_: bool, ) anyerror!?*TSConfigJSON { - var is_jsx_development = is_jsx_development_; // Unfortunately "tsconfig.json" isn't actually JSON. It's some other // format that appears to be defined by the implementation details of the // TypeScript compiler. @@ -155,20 +153,18 @@ pub const TSConfigJSON = struct { } } + // https://www.typescriptlang.org/docs/handbook/jsx.html#basic-usages if (compiler_opts.expr.asProperty("jsx")) |jsx_prop| { if (jsx_prop.expr.asString(allocator)) |str| { var str_lower = allocator.alloc(u8, str.len) catch unreachable; defer allocator.free(str_lower); _ = strings.copyLowercase(str, str_lower); - // we don't support "preserve" yet + // - We don't support "preserve" yet + // - We rely on NODE_ENV for "jsx" or "jsxDEV" + // - We treat "react-jsx" and "react-jsxDEV" identically + // because it is too easy to auto-import the wrong one. if (options.JSX.RuntimeMap.get(str_lower)) |runtime| { result.jsx.runtime = runtime; - if (runtime == .automatic) { - result.jsx.setProduction(!strings.contains(str_lower, "jsxdev")); - is_jsx_development = result.jsx.development; - result.jsx_flags.insert(.development); - } - result.jsx_flags.insert(.runtime); } } |