aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bundler/bundle_v2.zig28
-rw-r--r--src/js/out/modules/node/async_hooks.js11
-rw-r--r--test/bundler/bundler_edgecase.test.ts11
-rw-r--r--test/bundler/bundler_naming.test.ts2
-rw-r--r--test/bundler/esbuild/loader.test.ts1
5 files changed, 28 insertions, 25 deletions
diff --git a/src/bundler/bundle_v2.zig b/src/bundler/bundle_v2.zig
index 2a97b98ed..c62be6153 100644
--- a/src/bundler/bundle_v2.zig
+++ b/src/bundler/bundle_v2.zig
@@ -8119,13 +8119,14 @@ const LinkerContext = struct {
stmts.reset();
- const part_index_for_lazy_default_export: u32 = if (ast.flags.has_lazy_export) brk: {
- if (c.graph.meta.items(.resolved_exports)[part_range.source_index.get()].get("default")) |default| {
- break :brk c.graph.topLevelSymbolToParts(part_range.source_index.get(), default.data.import_ref)[0];
+ const part_index_for_lazy_default_export: u32 = brk: {
+ if (ast.flags.has_lazy_export) {
+ if (c.graph.meta.items(.resolved_exports)[part_range.source_index.get()].get("default")) |default| {
+ break :brk c.graph.topLevelSymbolToParts(part_range.source_index.get(), default.data.import_ref)[0];
+ }
}
-
break :brk std.math.maxInt(u32);
- } else std.math.maxInt(u32);
+ };
// TODO: handle directive
if (namespace_export_part_index >= part_range.part_index_begin and
@@ -8218,12 +8219,13 @@ const LinkerContext = struct {
// Be careful: the top-level value in a JSON file is not necessarily an object
if (default_expr.data == .e_object) {
- var new_properties = std.ArrayList(js_ast.G.Property).initCapacity(temp_allocator, default_expr.data.e_object.properties.len) catch unreachable;
+ var new_properties = default_expr.data.e_object.properties.clone(temp_allocator) catch unreachable;
+
var resolved_exports = c.graph.meta.items(.resolved_exports)[part_range.source_index.get()];
// If any top-level properties ended up being imported directly, change
// the property to just reference the corresponding variable instead
- for (default_expr.data.e_object.properties.slice()) |prop| {
+ for (new_properties.slice()) |*prop| {
if (prop.key == null or prop.key.?.data != .e_string or prop.value == null) continue;
const name = prop.key.?.data.e_string.slice(temp_allocator);
if (strings.eqlComptime(name, "default") or
@@ -8234,12 +8236,10 @@ const LinkerContext = struct {
const export_ref = export_data.data.import_ref;
const export_part = ast.parts.slice()[c.graph.topLevelSymbolToParts(part_range.source_index.get(), export_ref)[0]];
if (export_part.is_live) {
- new_properties.appendAssumeCapacity(
- .{
- .key = prop.key,
- .value = Expr.initIdentifier(export_ref, prop.value.?.loc),
- },
- );
+ prop.* = .{
+ .key = prop.key,
+ .value = Expr.initIdentifier(export_ref, prop.value.?.loc),
+ };
}
}
}
@@ -8248,7 +8248,7 @@ const LinkerContext = struct {
temp_allocator,
E.Object,
E.Object{
- .properties = BabyList(G.Property).init(new_properties.items),
+ .properties = new_properties,
},
default_expr.loc,
);
diff --git a/src/js/out/modules/node/async_hooks.js b/src/js/out/modules/node/async_hooks.js
index 5e7abe8e9..c1fdf050f 100644
--- a/src/js/out/modules/node/async_hooks.js
+++ b/src/js/out/modules/node/async_hooks.js
@@ -133,7 +133,16 @@ class AsyncResource {
}
runInAsyncScope;
#runInAsyncScope(fn, ...args) {
- return fn(...args);
+ var result, err;
+ if (process.nextTick((fn2) => {
+ try {
+ result = fn2(...args);
+ } catch (err2) {
+ err = err2;
+ }
+ }, fn), drainMicrotasks(), err)
+ throw err;
+ return result;
}
asyncId() {
return 0;
diff --git a/test/bundler/bundler_edgecase.test.ts b/test/bundler/bundler_edgecase.test.ts
index adb496eb1..c8b1591a7 100644
--- a/test/bundler/bundler_edgecase.test.ts
+++ b/test/bundler/bundler_edgecase.test.ts
@@ -296,7 +296,6 @@ describe("bundler", () => {
},
});
itBundled("edgecase/JSONDefaultImport", {
- todo: true,
files: {
"/entry.js": /* js */ `
import def from './test.json'
@@ -309,7 +308,6 @@ describe("bundler", () => {
},
});
itBundled("edgecase/JSONDefaultKeyImport", {
- todo: true,
files: {
"/entry.js": /* js */ `
import def from './test.json'
@@ -322,6 +320,8 @@ describe("bundler", () => {
},
});
itBundled("edgecase/JSONDefaultAndNamedImport", {
+ // We don't support rewriting default import to property acceses yet
+ todo: true,
files: {
"/entry.js": /* js */ `
import def from './test.json'
@@ -336,7 +336,6 @@ describe("bundler", () => {
},
});
itBundled("edgecase/JSONWithDefaultKey", {
- todo: true,
files: {
"/entry.js": /* js */ `
import def from './test.json'
@@ -373,7 +372,6 @@ describe("bundler", () => {
},
});
itBundled("edgecase/PackageJSONDefaultConditionRequire", {
- todo: true,
files: {
"/entry.js": /* js */ `
const boop = require('boop')
@@ -385,7 +383,7 @@ describe("bundler", () => {
"exports": {
".": {
"boop-server": "./ignore.js",
- "default": "./boop.js",
+ "default": "./boop.js"
}
}
}
@@ -411,7 +409,7 @@ describe("bundler", () => {
"exports": {
".": {
"react-server": "./ignore.js",
- "default": "./react.js",
+ "default": "./react.js"
}
}
}
@@ -787,7 +785,6 @@ describe("bundler", () => {
run: {},
});
itBundled("edgecase/ImportDefaultInDirectory", {
- todo: true,
files: {
"/a/file.js": `
import def from './def'
diff --git a/test/bundler/bundler_naming.test.ts b/test/bundler/bundler_naming.test.ts
index 897126ad8..92f3d4f9a 100644
--- a/test/bundler/bundler_naming.test.ts
+++ b/test/bundler/bundler_naming.test.ts
@@ -41,7 +41,6 @@ describe("bundler", () => {
],
});
itBundled("naming/ImplicitOutbase2", {
- todo: true,
files: {
"/a/hello/entry.js": /* js */ `
import data from '../dependency'
@@ -74,7 +73,6 @@ describe("bundler", () => {
],
});
itBundled("naming/EntryNamingTemplate1", {
- todo: true,
files: {
"/a/hello/entry.js": /* js */ `
import data from '../dependency'
diff --git a/test/bundler/esbuild/loader.test.ts b/test/bundler/esbuild/loader.test.ts
index f45862b1d..c76fdd18a 100644
--- a/test/bundler/esbuild/loader.test.ts
+++ b/test/bundler/esbuild/loader.test.ts
@@ -9,7 +9,6 @@ var { describe, test, expect } = testForFile(import.meta.path);
describe("bundler", () => {
itBundled("loader/JSONCommonJSAndES6", {
- todo: true,
files: {
"/entry.js": /* js */ `
const x_json = require('./x.json')