Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -739,6 +739,7 @@ fn addInternalImports(b: *Build, mod: *Module, opts: *BunBuildOptions) void {
.{ .file = "node-fallbacks/url.js", .enable = opts.shouldEmbedCode() },
.{ .file = "node-fallbacks/util.js", .enable = opts.shouldEmbedCode() },
.{ .file = "node-fallbacks/zlib.js", .enable = opts.shouldEmbedCode() },
.{ .file = "eval/feedback.ts", .enable = opts.shouldEmbedCode() },
}) |entry| {
if (!@hasField(@TypeOf(entry), "enable") or entry.enable) {
const path = b.pathJoin(&.{ opts.codegen_path, entry.file });
Expand Down
1 change: 1 addition & 0 deletions src/cli.zig
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ pub const HelpCommand = struct {
\\ <b><cyan>init<r> Start an empty Bun project from a built-in template
\\ <b><cyan>create<r> <d>{s:<16}<r> Create a new project from a template <d>(bun c)<r>
\\ <b><cyan>upgrade<r> Upgrade to latest version of Bun.
\\ <b><cyan>feedback<r> <d>./file1 ./file2<r> Provide feedback to the Bun team.
\\ <d>\<command\><r> <b><cyan>--help<r> Print help text for command.
\\
;
Expand Down
19 changes: 19 additions & 0 deletions src/cli/run_command.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1603,6 +1603,12 @@ pub const RunCommand = struct {
return true;
}

if (ctx.filters.len == 0 and !ctx.workspaces and CLI.Cli.cmd != null and CLI.Cli.cmd.? == .AutoCommand) {
if (bun.strings.eqlComptime(target_name, "feedback")) {
try @"bun feedback"(ctx);
}
}

if (log_errors) {
const ext = std.fs.path.extension(target_name);
const default_loader = options.defaultLoaders.get(ext);
Expand Down Expand Up @@ -1665,6 +1671,19 @@ pub const RunCommand = struct {
Global.exit(1);
};
}

fn @"bun feedback"(ctx: Command.Context) !noreturn {
const trigger = bun.pathLiteral("/[eval]");
var entry_point_buf: [bun.MAX_PATH_BYTES + trigger.len]u8 = undefined;
const cwd = try std.posix.getcwd(&entry_point_buf);
@memcpy(entry_point_buf[cwd.len..][0..trigger.len], trigger);
ctx.runtime_options.eval.script = if (bun.Environment.codegen_embed)
@embedFile("eval/feedback.ts")
else
bun.runtimeEmbedFile(.codegen, "eval/feedback.ts");
try Run.boot(ctx, entry_point_buf[0 .. cwd.len + trigger.len], null);
Global.exit(0);
}
};

pub const BunXFastPath = struct {
Expand Down
21 changes: 21 additions & 0 deletions src/codegen/bundle-modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,27 @@ declare module "module" {

mark("Generate Code");

const evalFiles = new Bun.Glob(path.join(BASE, "eval", "*.ts")).scanSync();
for (const file of evalFiles) {
const {
outputs: [output],
} = await Bun.build({
entrypoints: [file],

// Shrink it.
minify: !debug,

target: "bun",
format: "esm",
env: "disable",
define: {
"process.platform": JSON.stringify(process.platform),
"process.arch": JSON.stringify(process.arch),
},
});
writeIfNotChanged(path.join(CODEGEN_DIR, "eval", path.basename(file)), await output.text());
}

if (!silent) {
console.log("");
console.timeEnd(timeString);
Expand Down
1 change: 1 addition & 0 deletions src/js/eval/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
These are not bundled as builtin modules and instead are minified.
Loading
Loading