semi better

This commit is contained in:
RiskyMH
2025-09-14 02:55:27 +10:00
parent b69193ce05
commit 72cb84ce17
3 changed files with 12 additions and 10 deletions

View File

@@ -13,7 +13,7 @@ import.meta.main; // `true` if this file is directly executed by `bun run`
import.meta.resolve("zod"); // => "file:///path/to/project/node_modules/zod/index.js"
import.meta.glob("./models/*.js"); // => { "./models/user.js": [Async Function], ... }
import.meta.glob("./dir/*.ts"); // => { "./dir/a.ts": () => import("./dir/a.ts"), ... }
```
{% table %}

View File

@@ -6034,20 +6034,21 @@ pub fn NewParser_(
}
}.lessThan);
// Create properties
// Create dynamic imports
var properties: []G.Property = bun.handleOom(p.allocator.alloc(G.Property, matched_files.items.len));
for (matched_files.items, 0..) |file_path, i| {
const base_import_path: []const u8 = if (base_path) |base|
bun.handleOom(std.fmt.allocPrint(p.allocator, "{s}/{s}", .{ base, file_path }))
// add the base path and/or query string to the import path
const import_path: []const u8 = if (base_path) |base|
if (query) |q|
bun.handleOom(std.fmt.allocPrint(p.allocator, "{s}/{s}{s}", .{ base, file_path, q }))
else
bun.handleOom(std.fmt.allocPrint(p.allocator, "{s}/{s}", .{ base, file_path }))
else if (query) |q|
bun.handleOom(std.fmt.allocPrint(p.allocator, "{s}{s}", .{ file_path, q }))
else
file_path;
const import_path = if (query) |q|
bun.handleOom(std.fmt.allocPrint(p.allocator, "{s}{s}", .{ base_import_path, q }))
else
base_import_path;
const import_record_index = p.addImportRecord(.dynamic, loc, import_path);
bun.handleOom(p.import_records_for_current_part.append(p.allocator, import_record_index));

View File

@@ -316,7 +316,6 @@ test/js/node/crypto/node-crypto.test.js
test/js/third_party/pg/pg.test.ts
test/regression/issue/01466.test.ts
test/regression/issue/21311.test.ts
test/js/bun/glob/import-meta-glob.test.ts
test/regression/issue/ctrl-c.test.ts
@@ -328,3 +327,5 @@ test/cli/install/bun-repl.test.ts
test/bundler/esbuild/default.test.ts
test/integration/vite-build/vite-build.test.ts
test/cli/inspect/HTTPServerAgent.test.ts
test/js/bun/glob/import-meta-glob.test.ts
test/bundler/bundler_loader.test.ts