aboutsummaryrefslogtreecommitdiff
path: root/src/cache.zig
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-09-10 22:15:35 -0800
committerGravatar GitHub <noreply@github.com> 2023-09-10 23:15:35 -0700
commit51d3d4382281f789f8175079ed426a63529eb3e7 (patch)
tree14f6fe77a1e3b300488e9343d8e9d54f64bde376 /src/cache.zig
parentedea4f095a3bebf54f986c0fa038482316f4cde8 (diff)
downloadbun-51d3d4382281f789f8175079ed426a63529eb3e7.tar.gz
bun-51d3d4382281f789f8175079ed426a63529eb3e7.tar.zst
bun-51d3d4382281f789f8175079ed426a63529eb3e7.zip
Support named imports for json & toml files at runtime (#4783)
* Support named exports in json imports * Support named imports for `*.json` files * Remove stale comments * Don't export arrays as non-default * Add test for default exports * Don't break webpack --------- Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'src/cache.zig')
-rw-r--r--src/cache.zig7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/cache.zig b/src/cache.zig
index 4585860fa..56d91618d 100644
--- a/src/cache.zig
+++ b/src/cache.zig
@@ -294,6 +294,13 @@ pub const Json = struct {
};
}
pub fn parseJSON(cache: *@This(), log: *logger.Log, source: logger.Source, allocator: std.mem.Allocator) anyerror!?js_ast.Expr {
+ // tsconfig.* and jsconfig.* files are JSON files, but they are not valid JSON files.
+ // They are JSON files with comments and trailing commas.
+ // Sometimes tooling expects this to work.
+ if (source.path.isJSONCFile()) {
+ return try parse(cache, log, source, allocator, json_parser.ParseTSConfig);
+ }
+
return try parse(cache, log, source, allocator, json_parser.ParseJSON);
}