diff options
author | 2021-06-02 12:48:38 -0700 | |
---|---|---|
committer | 2021-06-02 12:48:38 -0700 | |
commit | ddd5ed1cc2e64f151864bd977cedcefa6929fb74 (patch) | |
tree | 491b8a941a50e10d2770692acfbfdbf01f28ca72 /src/linker.zig | |
parent | ee6643ce8b8b3ac32d5ba71d2617b38bb03379af (diff) | |
download | bun-ddd5ed1cc2e64f151864bd977cedcefa6929fb74.tar.gz bun-ddd5ed1cc2e64f151864bd977cedcefa6929fb74.tar.zst bun-ddd5ed1cc2e64f151864bd977cedcefa6929fb74.zip |
JSX & CJS work end-to-end!
Former-commit-id: 44bab947c650bb258d4cdfdf3dfc0b48c559945a
Diffstat (limited to 'src/linker.zig')
-rw-r--r-- | src/linker.zig | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/linker.zig b/src/linker.zig index 9b5359481..63ec7d72b 100644 --- a/src/linker.zig +++ b/src/linker.zig @@ -120,7 +120,7 @@ pub const Linker = struct { // If it's a namespace import, assume it's safe. // We can do this in the printer instead of creating a bunch of AST nodes here. // But we need to at least tell the printer that this needs to happen. - if (import_record.kind == .stmt and !import_record.contains_import_star and resolved_import.shouldAssumeCommonJS(import_record)) { + if (import_record.kind == .stmt and resolved_import.shouldAssumeCommonJS(import_record)) { import_record.wrap_with_to_module = true; result.ast.needs_runtime = true; } @@ -170,6 +170,19 @@ pub const Linker = struct { else => {}, } result.ast.externals = externals.toOwnedSlice(); + + if (result.ast.needs_runtime and result.ast.runtime_import_record_id == null) { + var import_records = try linker.allocator.alloc(ImportRecord, result.ast.import_records.len + 1); + std.mem.copy(ImportRecord, import_records, result.ast.import_records); + import_records[import_records.len - 1] = ImportRecord{ + .kind = .stmt, + .path = try linker.generateImportPath( + source_dir, + linker.runtime_source_path, + ), + .range = logger.Range{ .loc = logger.Loc{ .start = 0 }, .len = 0 }, + }; + } } const ImportPathsList = allocators.BSSStringList(512, 128); |