aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.vscode/launch.json12
-rw-r--r--src/api/demo/pages/index.tsx (renamed from src/api/demo/pages/index.jsx)0
-rw-r--r--src/cli.zig18
-rw-r--r--src/fs.zig4
-rw-r--r--src/global.zig5
-rw-r--r--src/js_parser/js_parser.zig2
-rw-r--r--src/linker.zig5
-rw-r--r--src/options.zig1
-rw-r--r--src/test/fixtures/object-newline.js10
9 files changed, 54 insertions, 3 deletions
diff --git a/.vscode/launch.json b/.vscode/launch.json
index 774ec4e7e..32bd294f5 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -26,7 +26,7 @@
"request": "launch",
"name": "Dev Launch",
"program": "${workspaceFolder}/build/debug/macos-x86_64/esdev",
- "args": ["./defines.jsx", "--resolve=disable"],
+ "args": ["./object-newline.js", "--resolve=disable"],
"cwd": "${workspaceFolder}/src/test/fixtures",
"console": "internalConsole"
},
@@ -34,6 +34,16 @@
{
"type": "lldb",
"request": "launch",
+ "name": "Demo Build",
+ "program": "${workspaceFolder}/build/debug/macos-x86_64/esdev",
+ "args": ["./pages/index.tsx", "--resolve=dev", "--outdir=out"],
+ "cwd": "${workspaceFolder}/src/api/demo",
+ "console": "internalConsole"
+ },
+
+ {
+ "type": "lldb",
+ "request": "launch",
"name": "DAev Launch",
"program": "${workspaceFolder}/build/macos-x86_64/esdev",
"args": ["./simple.jsx", "--resolve=disable"],
diff --git a/src/api/demo/pages/index.jsx b/src/api/demo/pages/index.tsx
index 9523fbc8b..9523fbc8b 100644
--- a/src/api/demo/pages/index.jsx
+++ b/src/api/demo/pages/index.tsx
diff --git a/src/cli.zig b/src/cli.zig
index de0be93e2..74ba7e252 100644
--- a/src/cli.zig
+++ b/src/cli.zig
@@ -329,7 +329,18 @@ pub const Cli = struct {
} else |err| {}
did_write = true;
- var root_dir = try std.fs.openDirAbsolute(result.outbase, std.fs.Dir.OpenDirOptions{});
+ var root_dir = std.fs.openDirAbsolute(result.outbase, std.fs.Dir.OpenDirOptions{}) catch brk: {
+ std.fs.makeDirAbsolute(result.outbase) catch |err| {
+ Output.printErrorln("error: Unable to mkdir \"{s}\": \"{s}\"", .{ result.outbase, @errorName(err) });
+ std.os.exit(1);
+ };
+
+ var handle = std.fs.openDirAbsolute(result.outbase, std.fs.Dir.OpenDirOptions{}) catch |err2| {
+ Output.printErrorln("error: Unable to open \"{s}\": \"{s}\"", .{ result.outbase, @errorName(err2) });
+ std.os.exit(1);
+ };
+ break :brk handle;
+ };
// On posix, file handles automatically close on process exit by the OS
// Closing files shows up in profiling.
// So don't do that unless we actually need to.
@@ -360,8 +371,13 @@ pub const Cli = struct {
.truncate = true,
}) catch |err2| return err2);
};
+
try _handle.seekTo(0);
+ if (FeatureFlags.disable_filesystem_cache) {
+ _ = std.os.fcntl(_handle.handle, std.os.F_NOCACHE, 1) catch 0;
+ }
+
defer {
if (do_we_need_to_close) {
_handle.close();
diff --git a/src/fs.zig b/src/fs.zig
index f13ee0495..5ac8983db 100644
--- a/src/fs.zig
+++ b/src/fs.zig
@@ -704,6 +704,10 @@ pub const FileSystem = struct {
pub fn readFileWithHandle(fs: *RealFS, path: string, _size: ?usize, file: std.fs.File) !File {
FileSystem.setMaxFd(file.handle);
+ if (FeatureFlags.disable_filesystem_cache) {
+ _ = std.os.fcntl(file.handle, std.os.F_NOCACHE, 1) catch 0;
+ }
+
// Skip the extra file.stat() call when possible
var size = _size orelse (file.getEndPos() catch |err| {
fs.readFileError(path, err);
diff --git a/src/global.zig b/src/global.zig
index 821f09b5f..4e95b7d1f 100644
--- a/src/global.zig
+++ b/src/global.zig
@@ -27,10 +27,15 @@ pub const FeatureFlags = struct {
pub const use_std_path_relative = false;
pub const use_std_path_join = false;
+ // Debug helpers
pub const print_ast = false;
pub const disable_printing_null = false;
+ // This was a ~5% performance improvement
pub const store_file_descriptors = !isWindows and !isBrowser;
+
+ // This doesn't really seem to do anything for us
+ pub const disable_filesystem_cache = false and std.Target.current.os.tag == .macos;
};
pub const enableTracing = true;
diff --git a/src/js_parser/js_parser.zig b/src/js_parser/js_parser.zig
index 089fccb93..5ab16f072 100644
--- a/src/js_parser/js_parser.zig
+++ b/src/js_parser/js_parser.zig
@@ -10176,7 +10176,7 @@ pub const P = struct {
.e_import => |e_| {
const state = TransposeState{
.is_await_target = if (p.await_target != null) p.await_target.?.e_import == e_ else false,
- .is_then_catch_target = expr.data.e_import == p.then_catch_chain.next_target.e_import and p.then_catch_chain.has_catch,
+ .is_then_catch_target = p.then_catch_chain.has_catch and std.meta.activeTag(p.then_catch_chain.next_target) == .e_import and expr.data.e_import == p.then_catch_chain.next_target.e_import,
.loc = e_.expr.loc,
};
diff --git a/src/linker.zig b/src/linker.zig
index 884dfe6ee..db9db78e0 100644
--- a/src/linker.zig
+++ b/src/linker.zig
@@ -8,4 +8,9 @@ pub const Linker = struct {
pub fn requireOrImportMetaForSource(c: Linker, source_index: Ref.Int) RequireOrImportMeta {
return RequireOrImportMeta{};
}
+
+ // This modifies the Ast in-place!
+ // But more importantly, this does the following:
+ // - Wrap CommonJS files
+ pub fn link(allocator: *std.mem.Allocator, ast: *js_ast.Ast) !void {}
};
diff --git a/src/options.zig b/src/options.zig
index afa45e039..22d335aa3 100644
--- a/src/options.zig
+++ b/src/options.zig
@@ -63,6 +63,7 @@ pub const ExternalModules = struct {
if (platform == .node) {
// TODO: fix this stupid copy
+ result.node_modules.hash_map.ensureCapacity(NodeBuiltinPatterns.len) catch unreachable;
for (NodeBuiltinPatterns) |pattern| {
result.node_modules.put(pattern) catch unreachable;
}
diff --git a/src/test/fixtures/object-newline.js b/src/test/fixtures/object-newline.js
new file mode 100644
index 000000000..cc4371415
--- /dev/null
+++ b/src/test/fixtures/object-newline.js
@@ -0,0 +1,10 @@
+// hey
+const foo = import("react");
+
+const Bar = {
+ foo: true,
+ bar: 1,
+ nested: {
+ hey: 1,
+ },
+};