Fix unbundled imports

Former-commit-id: f221da115c1afcd136648c9683d8e9907005a128
This commit is contained in:
Jarred Sumner
2021-08-26 21:43:42 -07:00
parent 3a34f2e952
commit 92229ac0f6
11 changed files with 49 additions and 40 deletions

View File

@@ -2944,10 +2944,10 @@ pub fn NewPrinter(
if (p.options.runtime_imports.__require) |require_ref| {
var module_name_buf: [256]u8 = undefined;
var fixed_buf_allocator = std.heap.FixedBufferAllocator.init(&module_name_buf);
const module_name_segment = (fs.PathName.init(record.path.pretty).nonUniqueNameString(&fixed_buf_allocator.allocator) catch unreachable)[1..];
p.print("import * as ");
const module_name_segment = (fs.PathName.init(record.path.pretty).nonUniqueNameString(&fixed_buf_allocator.allocator) catch unreachable);
p.print("import * as $$");
p.print(module_name_segment);
p.print("_module from \"");
p.print(" from \"");
p.print(record.path.text);
p.print("\";\n");
@@ -2956,9 +2956,9 @@ pub fn NewPrinter(
p.printSymbol(s.namespace_ref);
p.print(" = ");
p.printSymbol(require_ref);
p.print("(");
p.print("($$");
p.print(module_name_segment);
p.print("_module);\n");
p.print(");\n");
}
if (s.default_name) |default_name| {
@@ -2966,9 +2966,9 @@ pub fn NewPrinter(
p.printSymbol(default_name.ref.?);
p.print(" = ");
p.printSymbol(require_ref);
p.print("(");
p.print("($$");
p.print(module_name_segment);
p.print("_module);\n");
p.print(");\n");
}
return;