diff options
author | 2023-07-05 22:23:32 -0700 | |
---|---|---|
committer | 2023-07-05 22:23:32 -0700 | |
commit | 6bf8f6f9f252dc92dc7da1fcfc3449057edd8be1 (patch) | |
tree | bd813024b51bc21416132536f7313bdcc510a054 /src/js_parser.zig | |
parent | 8869bac4117b41196c4a73d9145c0beaf5e8437d (diff) | |
download | bun-6bf8f6f9f252dc92dc7da1fcfc3449057edd8be1.tar.gz bun-6bf8f6f9f252dc92dc7da1fcfc3449057edd8be1.tar.zst bun-6bf8f6f9f252dc92dc7da1fcfc3449057edd8be1.zip |
don't unwrap react below version `18.0.0` (#3538)
* don't unwrap react below version 18
* empty string
* also `react-dom`
Diffstat (limited to 'src/js_parser.zig')
-rw-r--r-- | src/js_parser.zig | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/js_parser.zig b/src/js_parser.zig index 5729efa39..6a2cc1228 100644 --- a/src/js_parser.zig +++ b/src/js_parser.zig @@ -2629,6 +2629,7 @@ pub const Parser = struct { tree_shaking: bool = false, bundle: bool = false, + package_version: string = "", macro_context: *MacroContextType() = undefined, @@ -21918,11 +21919,25 @@ fn NewParser_( // Only enable during bundling .commonjs_named_exports_deoptimized = !opts.bundle, - .unwrap_all_requires = opts.bundle and - if (source.path.packageName()) |pkg| - opts.features.shouldUnwrapRequire(pkg) - else - false, + }; + + this.unwrap_all_requires = brk: { + if (opts.bundle) { + if (source.path.packageName()) |pkg| { + if (opts.features.shouldUnwrapRequire(pkg)) { + if (strings.eqlComptime(pkg, "react") or strings.eqlComptime(pkg, "react-dom")) { + const version = opts.package_version; + if (version.len > 2 and (version[0] == '0' or (version[0] == '1' and version[1] < '8'))) { + break :brk false; + } + } + + break :brk true; + } + } + } + + break :brk false; }; this.symbols = std.ArrayList(Symbol).init(allocator); |