aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bun.js/module_loader.zig2
-rw-r--r--src/bundler.zig26
2 files changed, 27 insertions, 1 deletions
diff --git a/src/bun.js/module_loader.zig b/src/bun.js/module_loader.zig
index 9ec142176..bfdb9462d 100644
--- a/src/bun.js/module_loader.zig
+++ b/src/bun.js/module_loader.zig
@@ -879,7 +879,7 @@ pub const ModuleLoader = struct {
const disable_transpilying = comptime flags.disableTranspiling();
switch (loader) {
- .js, .jsx, .ts, .tsx, .json, .toml => {
+ .js, .jsx, .ts, .tsx, .json, .toml, .text => {
jsc_vm.transpiled_count += 1;
jsc_vm.bundler.resetStore();
const hash = http.Watcher.getHash(path.text);
diff --git a/src/bundler.zig b/src/bundler.zig
index 629e377ae..8c9775808 100644
--- a/src/bundler.zig
+++ b/src/bundler.zig
@@ -1454,6 +1454,7 @@ pub const Bundler = struct {
},
};
},
+ // TODO: use lazy export AST
.json => {
var expr = json_parser.ParseJSON(&source, bundler.log, allocator) catch return null;
var stmt = js_ast.Stmt.alloc(js_ast.S.ExportDefault, js_ast.S.ExportDefault{
@@ -1475,6 +1476,7 @@ pub const Bundler = struct {
.input_fd = input_fd,
};
},
+ // TODO: use lazy export AST
.toml => {
var expr = TOML.parse(&source, bundler.log, allocator) catch return null;
var stmt = js_ast.Stmt.alloc(js_ast.S.ExportDefault, js_ast.S.ExportDefault{
@@ -1496,6 +1498,30 @@ pub const Bundler = struct {
.input_fd = input_fd,
};
},
+ // TODO: use lazy export AST
+ .text => {
+ var expr = js_ast.Expr.init(js_ast.E.String, js_ast.E.String{
+ .data = source.contents,
+ }, logger.Loc.Empty);
+ var stmt = js_ast.Stmt.alloc(js_ast.S.ExportDefault, js_ast.S.ExportDefault{
+ .value = js_ast.StmtOrExpr{ .expr = expr },
+ .default_name = js_ast.LocRef{
+ .loc = logger.Loc{},
+ .ref = Ref.None,
+ },
+ }, logger.Loc{ .start = 0 });
+ var stmts = allocator.alloc(js_ast.Stmt, 1) catch unreachable;
+ stmts[0] = stmt;
+ var parts = allocator.alloc(js_ast.Part, 1) catch unreachable;
+ parts[0] = js_ast.Part{ .stmts = stmts };
+
+ return ParseResult{
+ .ast = js_ast.Ast.initTest(parts),
+ .source = source,
+ .loader = loader,
+ .input_fd = input_fd,
+ };
+ },
.wasm => {
if (bundler.options.platform.isBun()) {
if (!source.isWebAssembly()) {