aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-08-11 13:56:03 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-08-11 13:56:03 -0700
commit842bb9cba28e51172407523a4e8b624fde8d702e (patch)
tree674e7ed4a8d768bb60ee612affe846c4d7904691
parentca90126cc43e688cfbe8636f6b373c4bb3af602c (diff)
downloadbun-842bb9cba28e51172407523a4e8b624fde8d702e.tar.gz
bun-842bb9cba28e51172407523a4e8b624fde8d702e.tar.zst
bun-842bb9cba28e51172407523a4e8b624fde8d702e.zip
go
Former-commit-id: d90f4747fe450c6f5d11d550df5117a9dca9962e
-rw-r--r--src/bundler.zig2
-rw-r--r--src/feature_flags.zig2
-rw-r--r--src/http.zig42
-rw-r--r--src/javascript/jsc/api/router.zig8
-rw-r--r--workspace.code-workspace96
5 files changed, 136 insertions, 14 deletions
diff --git a/src/bundler.zig b/src/bundler.zig
index acf8ca94c..e500360de 100644
--- a/src/bundler.zig
+++ b/src/bundler.zig
@@ -898,7 +898,7 @@ pub fn NewBundler(cache_files: bool) type {
Output.prettyErrorln("\n<r><red>{s}<r> on resolving \"{s}\" from \"{s}\"", .{
@errorName(err),
import_record.path.text,
- source_dir
+ file_path.text,
});
}
}
diff --git a/src/feature_flags.zig b/src/feature_flags.zig
index f74c6e5ef..f2fa69884 100644
--- a/src/feature_flags.zig
+++ b/src/feature_flags.zig
@@ -41,7 +41,7 @@ pub const enable_bytecode_caching = false;
// command ../../build/debug/macos-x86_64/esdev --use=./nexty2 --new-jsb > /dev/null
// end
// It only happens 1 out of every N times, probably like 50.
-pub const parallel_jsb = true;
+pub const parallel_jsb = false;
pub const CSSModulePolyfill = enum {
// When you import a .css file and you reference the import in JavaScript
diff --git a/src/http.zig b/src/http.zig
index 34303d131..06eaf7a18 100644
--- a/src/http.zig
+++ b/src/http.zig
@@ -552,6 +552,7 @@ pub const RequestContext = struct {
0,
fd,
id,
+ null,
) orelse {
return WatchBuildResult{
.value = .{ .fail = std.mem.zeroes(Api.WebsocketMessageBuildFailure) },
@@ -1258,6 +1259,8 @@ pub const RequestContext = struct {
}
}
+ threadlocal var client_entry_point: bundler.ClientEntryPoint = undefined;
+
pub fn renderServeResult(ctx: *RequestContext, result: bundler.ServeResult) !void {
if (ctx.keep_alive) {
ctx.appendHeader("Connection", "keep-alive");
@@ -1382,6 +1385,17 @@ pub const RequestContext = struct {
// It will call flush for us automatically
ctx.bundler.resetStore();
+ var client_entry_point_: ?*bundler.ClientEntryPoint = null;
+ if (resolve_result.import_kind == .entry_point and loader.supportsClientEntryPoint()) {
+ if (ctx.bundler.options.framework) |*framework| {
+ if (framework.client.len > 0) {
+ client_entry_point = bundler.ClientEntryPoint{};
+ try client_entry_point.generate(Bundler, ctx.bundler, resolve_result.path_pair.primary.name, framework.client);
+ client_entry_point_ = &client_entry_point;
+ }
+ }
+ }
+
var written = ctx.bundler.buildWithResolveResult(
resolve_result,
ctx.allocator,
@@ -1393,13 +1407,14 @@ pub const RequestContext = struct {
hash,
Watcher,
ctx.watcher,
+ client_entry_point_,
) catch |err| {
ctx.sendInternalError(err) catch {};
return;
};
// CSS handles this specially
- if (loader != .css) {
+ if (loader != .css and client_entry_point_ == null) {
if (written.input_fd) |written_fd| {
try ctx.watcher.addFile(
written_fd,
@@ -1553,12 +1568,25 @@ pub const RequestContext = struct {
// errdefer ctx.auto500();
- const result = try ctx.bundler.buildFile(
- &ctx.log,
- ctx.allocator,
- ctx.url.path,
- ctx.url.extname,
- );
+ const result = brk: {
+ if (ctx.bundler.options.isFrontendFrameworkEnabled()) {
+ break :brk try ctx.bundler.buildFile(
+ &ctx.log,
+ ctx.allocator,
+ ctx.url.path,
+ ctx.url.extname,
+ true,
+ );
+ } else {
+ break :brk try ctx.bundler.buildFile(
+ &ctx.log,
+ ctx.allocator,
+ ctx.url.path,
+ ctx.url.extname,
+ false,
+ );
+ }
+ };
try @call(.{ .modifier = .always_inline }, RequestContext.renderServeResult, .{ ctx, result });
}
diff --git a/src/javascript/jsc/api/router.zig b/src/javascript/jsc/api/router.zig
index 380759fb0..e2283e9c5 100644
--- a/src/javascript/jsc/api/router.zig
+++ b/src/javascript/jsc/api/router.zig
@@ -74,9 +74,7 @@ fn matchPathNameString(
ctx: js.JSContextRef,
pathname: string,
exception: js.ExceptionRef,
-) js.JSObjectRef {
-
-}
+) js.JSObjectRef {}
fn matchPathName(
ctx: js.JSContextRef,
@@ -177,7 +175,7 @@ pub const Instance = NewClass(
.@"tsdoc" = "URL path as appears in a web browser's address bar",
},
},
-
+
.filePath = .{
.get = getFilePath,
.ro = true,
@@ -283,6 +281,7 @@ const KindEnum = struct {
pub const optional_catch_all = "optional-catch-all";
pub const dynamic = "dynamic";
+ // this is kinda stupid it should maybe just store it
pub fn init(name: string) ZigString {
if (strings.contains(name, "[[...")) {
return ZigString.init(optional_catch_all);
@@ -367,7 +366,6 @@ pub fn getScriptSrc(
}
break :brk this.script_src_buf[0..this.script_src_buf_writer.pos];
};
-
this.script_src = src;
diff --git a/workspace.code-workspace b/workspace.code-workspace
new file mode 100644
index 000000000..b71214b7a
--- /dev/null
+++ b/workspace.code-workspace
@@ -0,0 +1,96 @@
+{
+ "folders": [
+ {
+ "path": "."
+ }
+],
+ "settings": {
+ "git.autoRepositoryDetection": "openEditors",
+ "search.quickOpen.includeSymbols": false,
+ "search.seedWithNearestWord": true,
+ "search.smartCase": true,
+ "search.followSymlinks": false,
+ "zig.buildOnSave": false,
+ "files.associations": {
+ "*.idl": "cpp",
+ "memory": "cpp",
+ "iostream": "cpp",
+ "algorithm": "cpp",
+ "random": "cpp",
+ "ios": "cpp",
+ "filesystem": "cpp",
+ "__locale": "cpp",
+ "type_traits": "cpp",
+ "__mutex_base": "cpp",
+ "__string": "cpp",
+ "string": "cpp",
+ "string_view": "cpp",
+ "typeinfo": "cpp",
+ "__config": "cpp",
+ "__nullptr": "cpp",
+ "exception": "cpp",
+ "__bit_reference": "cpp",
+ "atomic": "cpp",
+ "utility": "cpp",
+ "sstream": "cpp",
+ "__functional_base": "cpp",
+ "new": "cpp",
+ "__debug": "cpp",
+ "__errc": "cpp",
+ "__hash_table": "cpp",
+ "__node_handle": "cpp",
+ "__split_buffer": "cpp",
+ "__threading_support": "cpp",
+ "__tuple": "cpp",
+ "array": "cpp",
+ "bit": "cpp",
+ "bitset": "cpp",
+ "cctype": "cpp",
+ "chrono": "cpp",
+ "clocale": "cpp",
+ "cmath": "cpp",
+ "complex": "cpp",
+ "condition_variable": "cpp",
+ "cstdarg": "cpp",
+ "cstddef": "cpp",
+ "cstdint": "cpp",
+ "cstdio": "cpp",
+ "cstdlib": "cpp",
+ "cstring": "cpp",
+ "ctime": "cpp",
+ "cwchar": "cpp",
+ "cwctype": "cpp",
+ "deque": "cpp",
+ "fstream": "cpp",
+ "functional": "cpp",
+ "initializer_list": "cpp",
+ "iomanip": "cpp",
+ "iosfwd": "cpp",
+ "istream": "cpp",
+ "iterator": "cpp",
+ "limits": "cpp",
+ "locale": "cpp",
+ "mutex": "cpp",
+ "optional": "cpp",
+ "ostream": "cpp",
+ "ratio": "cpp",
+ "stack": "cpp",
+ "stdexcept": "cpp",
+ "streambuf": "cpp",
+ "system_error": "cpp",
+ "thread": "cpp",
+ "tuple": "cpp",
+ "unordered_map": "cpp",
+ "unordered_set": "cpp",
+ "vector": "cpp",
+ "__bits": "cpp",
+ "__tree": "cpp",
+ "map": "cpp",
+ "numeric": "cpp",
+ "set": "cpp",
+ "__memory": "cpp",
+ "memory_resource": "cpp"
+ },
+ "git.ignoreLimitWarning": true
+ }
+}