mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
go
Former-commit-id: d90f4747fe450c6f5d11d550df5117a9dca9962e
This commit is contained in:
@@ -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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
42
src/http.zig
42
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 });
|
||||
}
|
||||
|
||||
@@ -74,9 +74,7 @@ fn matchPathNameString(
|
||||
ctx: js.JSContextRef,
|
||||
pathname: string,
|
||||
exception: js.ExceptionRef,
|
||||
) js.JSObjectRef {
|
||||
|
||||
}
|
||||
) js.JSObjectRef {}
|
||||
|
||||
fn matchPathName(
|
||||
ctx: js.JSContextRef,
|
||||
@@ -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);
|
||||
@@ -368,7 +367,6 @@ pub fn getScriptSrc(
|
||||
break :brk this.script_src_buf[0..this.script_src_buf_writer.pos];
|
||||
};
|
||||
|
||||
|
||||
this.script_src = src;
|
||||
|
||||
return js.JSValueMakeString(ctx, ZigString.init(src).toJSStringRef());
|
||||
|
||||
96
workspace.code-workspace
Normal file
96
workspace.code-workspace
Normal file
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user