diff options
author | 2023-04-26 01:31:09 -0700 | |
---|---|---|
committer | 2023-04-26 01:31:09 -0700 | |
commit | 97e2b133e3af4a92fc9dec07cfce31f414f698c4 (patch) | |
tree | 52dab74aa0df1f4e47cc31206b8eed34cc2dae8a | |
parent | b957087fe64b41624ebf0edb278f0df6adf7d846 (diff) | |
parent | 149f097ffd9e819c665ecc24cb197b3921ca9a6d (diff) | |
download | bun-jarred/request-finalizer.tar.gz bun-jarred/request-finalizer.tar.zst bun-jarred/request-finalizer.zip |
Merge branch 'main' into jarred/request-finalizerjarred/request-finalizer
-rw-r--r-- | src/bun.js/bindings/JSBundlerPlugin.cpp | 16 | ||||
-rw-r--r-- | src/cli.zig | 2 | ||||
-rw-r--r-- | src/js_parser.zig | 24 | ||||
-rw-r--r-- | src/runtime.footer.bun.js | 2 | ||||
-rw-r--r-- | src/sourcemap/sourcemap.zig | 2 |
5 files changed, 18 insertions, 28 deletions
diff --git a/src/bun.js/bindings/JSBundlerPlugin.cpp b/src/bun.js/bindings/JSBundlerPlugin.cpp index 1ac8b0c30..bff8ebd0d 100644 --- a/src/bun.js/bindings/JSBundlerPlugin.cpp +++ b/src/bun.js/bindings/JSBundlerPlugin.cpp @@ -58,16 +58,21 @@ void BundlerPlugin::NamespaceList::append(JSC::VM& vm, JSC::RegExp* filter, Stri bool BundlerPlugin::anyMatchesCrossThread(const ZigString* namespaceStr, const ZigString* path, bool isOnLoad) { - auto namespaceString = namespaceStr ? Zig::toString(*namespaceStr) : String(); - auto pathString = Zig::toString(*path); if (isOnLoad) { + if (this->onLoad.fileNamespace.isEmpty() && this->onLoad.namespaces.isEmpty()) + return false; + + // Avoid unnecessary string copies + auto namespaceString = namespaceStr ? Zig::toString(*namespaceStr) : String(); + auto* group = this->onLoad.group(namespaceString); if (group == nullptr) { return false; } auto& filters = *group; + auto pathString = Zig::toString(*path); for (auto& filter : filters) { if (filter.match(pathString) > -1) { @@ -76,11 +81,18 @@ bool BundlerPlugin::anyMatchesCrossThread(const ZigString* namespaceStr, const Z } } else { + if (this->onResolve.fileNamespace.isEmpty() && this->onResolve.namespaces.isEmpty()) + return false; + + // Avoid unnecessary string copies + auto namespaceString = namespaceStr ? Zig::toString(*namespaceStr) : String(); + auto* group = this->onResolve.group(namespaceString); if (group == nullptr) { return false; } + auto pathString = Zig::toString(*path); auto& filters = *group; for (auto& filter : filters) { diff --git a/src/cli.zig b/src/cli.zig index 61e236bad..142ab06e3 100644 --- a/src/cli.zig +++ b/src/cli.zig @@ -58,7 +58,7 @@ pub const Cli = struct { Command.start(allocator, log) catch |err| { switch (err) { error.MissingEntryPoint => { - Output.prettyErrorln("<r><red>MissingEntryPoint<r> what do you want to bundle?\n\n<d>Example:\n\n<r> <b><cyan>bun bun --use next<r>\n\n <b><cyan>bun bun ./src/index.ts ./src/file2.ts<r>\n", .{}); + Output.prettyErrorln("<r><red>MissingEntryPoint<r> what do you want to build?\n\n<d>Example:\n\n<r> <b><cyan>bun build ./src/index.ts<r>\n\n <b><cyan>bun build --minify --outdir=out ./index.jsx ./lib/worker.ts<r>\n", .{}); Global.exit(1); }, else => { diff --git a/src/js_parser.zig b/src/js_parser.zig index ad8dd0ecd..df99e3738 100644 --- a/src/js_parser.zig +++ b/src/js_parser.zig @@ -4780,10 +4780,6 @@ fn NewParser_( // "visit" pass. enclosing_namespace_arg_ref: ?Ref = null, - react_element_type: GeneratedSymbol = GeneratedSymbol{ .ref = Ref.None, .primary = Ref.None, .backup = Ref.None }, - /// Symbol object - es6_symbol_global: GeneratedSymbol = GeneratedSymbol{ .ref = Ref.None, .primary = Ref.None, .backup = Ref.None }, - // TODO: remove all these jsx_runtime: GeneratedSymbol = GeneratedSymbol{ .ref = Ref.None, .primary = Ref.None, .backup = Ref.None }, jsx_factory: GeneratedSymbol = GeneratedSymbol{ .ref = Ref.None, .primary = Ref.None, .backup = Ref.None }, @@ -6461,11 +6457,6 @@ fn NewParser_( switch (comptime jsx_transform_type) { .react => { if (!p.options.bundle) { - if (p.options.features.jsx_optimization_inline) { - p.react_element_type = p.declareGeneratedSymbol(.other, "REACT_ELEMENT_TYPE") catch unreachable; - p.es6_symbol_global = p.declareGeneratedSymbol(.unbound, "Symbol") catch unreachable; - } - p.jsx_fragment = p.declareGeneratedSymbol(.other, "Fragment") catch unreachable; p.jsx_runtime = p.declareGeneratedSymbol(.other, "jsx") catch unreachable; if (comptime FeatureFlags.support_jsxs_in_jsx_transform) @@ -6561,8 +6552,6 @@ fn NewParser_( return; if (p.options.features.jsx_optimization_inline) { - p.resolveGeneratedSymbol(&p.react_element_type); - p.resolveGeneratedSymbol(&p.es6_symbol_global); if (p.runtime_imports.__merge) |*merge| { p.resolveGeneratedSymbol(merge); } @@ -15104,8 +15093,6 @@ fn NewParser_( // _owner: null // }; // - if (!p.options.bundle) - p.recordUsage(p.react_element_type.ref); const key = if (e_.key) |key_| brk: { // key: void 0 === key ? null : "" + key, break :brk switch (key_.data) { @@ -15180,16 +15167,7 @@ fn NewParser_( [_]G.Property{ G.Property{ .key = Expr{ .data = Prefill.Data.@"$$typeof", .loc = tag.loc }, - .value = if (p.options.bundle) - p.runtimeIdentifier(tag.loc, "$$typeof") - else - p.newExpr( - E.Identifier{ - .ref = p.react_element_type.ref, - .can_be_removed_if_unused = true, - }, - tag.loc, - ), + .value = p.runtimeIdentifier(tag.loc, "$$typeof"), }, G.Property{ .key = Expr{ .data = Prefill.Data.type, .loc = tag.loc }, diff --git a/src/runtime.footer.bun.js b/src/runtime.footer.bun.js index 56da601b4..520b89e89 100644 --- a/src/runtime.footer.bun.js +++ b/src/runtime.footer.bun.js @@ -15,7 +15,7 @@ export var __decorateClass = BUN_RUNTIME.__decorateClass; export var __decorateParam = BUN_RUNTIME.__decorateParam; export var $$bun_runtime_json_parse = JSON.parse; export var __internalIsCommonJSNamespace = BUN_RUNTIME.__internalIsCommonJSNamespace; - +export var $$typeof = BUN_RUNTIME.$$typeof; export var __require = (globalThis.require ||= function (moduleId) { if (typeof moduleId === "string") { return import.meta.require(moduleId); diff --git a/src/sourcemap/sourcemap.zig b/src/sourcemap/sourcemap.zig index b9d19b40d..f7a92a9c1 100644 --- a/src/sourcemap/sourcemap.zig +++ b/src/sourcemap/sourcemap.zig @@ -698,7 +698,7 @@ pub const LineOffsetTable = struct { if (c > 0x7F and columns_for_non_ascii.items.len == 0) { std.debug.assert(@ptrToInt( remaining.ptr, - ) > @ptrToInt( + ) >= @ptrToInt( contents.ptr, )); // we have a non-ASCII character, so we need to keep track of the |