Skip to content

Commit

Permalink
go
Browse files Browse the repository at this point in the history
Former-commit-id: d90f474
  • Loading branch information
Jarred-Sumner committed Aug 11, 2021
1 parent ca90126 commit 842bb9c
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/bundler.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/feature_flags.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
42 changes: 35 additions & 7 deletions src/http.zig
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ pub const RequestContext = struct {
0,
fd,
id,
null,
) orelse {
return WatchBuildResult{
.value = .{ .fail = std.mem.zeroes(Api.WebsocketMessageBuildFailure) },
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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 });
}
Expand Down
8 changes: 3 additions & 5 deletions src/javascript/jsc/api/router.zig
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ fn matchPathNameString(
ctx: js.JSContextRef,
pathname: string,
exception: js.ExceptionRef,
) js.JSObjectRef {

}
) js.JSObjectRef {}

fn matchPathName(
ctx: js.JSContextRef,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -367,7 +366,6 @@ pub fn getScriptSrc(
}
break :brk this.script_src_buf[0..this.script_src_buf_writer.pos];
};


this.script_src = src;

Expand Down
96 changes: 96 additions & 0 deletions workspace.code-workspace
Original file line number Diff line number Diff line change
@@ -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
}
}

0 comments on commit 842bb9c

Please sign in to comment.