Delete some dead code

This commit is contained in:
Jarred Sumner
2022-09-01 20:34:41 -07:00
parent dfc27e3c30
commit 4e73726bee
8 changed files with 3 additions and 246 deletions

2
.vscode/launch.json generated vendored
View File

@@ -6,7 +6,7 @@
"request": "launch",
"name": "bun test",
"program": "bun-debug",
"args": ["wiptest", "jsc"],
"args": ["wiptest", "${file}"],
"cwd": "${workspaceFolder}/test",
"env": {
"FORCE_COLOR": "1"

View File

@@ -236,7 +236,6 @@ pub fn build(b: *std.build.Builder) !void {
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
mode = b.standardReleaseOptions();
const cwd: []const u8 = b.pathFromRoot(".");
var exe: *std.build.LibExeObjStep = undefined;
var output_dir_buf = std.mem.zeroes([4096]u8);
var bin_label = if (mode == std.builtin.Mode.Debug) "packages/debug-bun-" else "packages/bun-";
@@ -298,8 +297,6 @@ pub fn build(b: *std.build.Builder) !void {
exe.setBuildMode(mode);
b.install_path = output_dir;
var typings_exe = b.addExecutable("typescript-decls", "src/typegen.zig");
const min_version: std.builtin.Version = if (target.getOsTag() != .freestanding)
target.getOsVersionMin().semver
else .{ .major = 0, .minor = 0, .patch = 0 };
@@ -540,25 +537,6 @@ pub fn build(b: *std.build.Builder) !void {
headers_step.dependOn(&after.step);
}
}
try configureObjectStep(b, typings_exe, target, obj.main_pkg_path.?);
try linkObjectFiles(b, typings_exe, target);
var typings_cmd: *std.build.RunStep = typings_exe.run();
typings_cmd.cwd = cwd;
typings_cmd.addArg(cwd);
typings_cmd.addArg("types");
typings_cmd.step.dependOn(&typings_exe.step);
if (target.getOsTag() == .macos) {
typings_exe.linkSystemLibrary("icucore");
typings_exe.linkSystemLibrary("iconv");
typings_exe.addLibPath(
"/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib",
);
}
var typings_step = b.step("types", "Build TypeScript types");
typings_step.dependOn(&typings_cmd.step);
}
pub var original_make_fn: ?fn (step: *std.build.Step) anyerror!void = null;

View File

@@ -1013,143 +1013,87 @@ pub const Class = NewClass(
.{
.match = .{
.rfn = Router.match,
.ts = Router.match_type_definition,
},
.sleepSync = .{
.rfn = sleepSync,
},
.fetch = .{
.rfn = Fetch.call,
.ts = d.ts{},
},
.getImportedStyles = .{
.rfn = Bun.getImportedStyles,
.ts = d.ts{
.name = "getImportedStyles",
.@"return" = "string[]",
},
},
.inspect = .{
.rfn = Bun.inspect,
.ts = d.ts{
.name = "inspect",
.@"return" = "string",
},
},
.getRouteFiles = .{
.rfn = Bun.getRouteFiles,
.ts = d.ts{
.name = "getRouteFiles",
.@"return" = "string[]",
},
},
._Os = .{
.rfn = Bun.newOs,
.ts = d.ts{},
},
._Path = .{
.rfn = Bun.newPath,
.ts = d.ts{},
},
.getRouteNames = .{
.rfn = Bun.getRouteNames,
.ts = d.ts{
.name = "getRouteNames",
.@"return" = "string[]",
},
},
.readFile = .{
.rfn = Bun.readFileAsString,
.ts = d.ts{
.name = "readFile",
.@"return" = "string",
},
},
.resolveSync = .{
.rfn = Bun.resolveSync,
.ts = d.ts{
.name = "resolveSync",
.@"return" = "string",
},
},
.resolve = .{
.rfn = Bun.resolve,
.ts = d.ts{
.name = "resolve",
.@"return" = "string",
},
},
.readFileBytes = .{
.rfn = Bun.readFileAsBytes,
.ts = d.ts{
.name = "readFile",
.@"return" = "Uint8Array",
},
},
.getPublicPath = .{
.rfn = Bun.getPublicPathJS,
.ts = d.ts{
.name = "getPublicPath",
.@"return" = "string",
},
},
.registerMacro = .{
.rfn = Bun.registerMacro,
.ts = d.ts{
.name = "registerMacro",
.@"return" = "undefined",
},
.enumerable = false,
},
.fs = .{
.rfn = Bun.createNodeFS,
.ts = d.ts{},
.enumerable = false,
},
.jest = .{
.rfn = @import("../test/jest.zig").Jest.call,
.ts = d.ts{},
.enumerable = false,
},
.gc = .{
.rfn = Bun.runGC,
.ts = d.ts{},
},
.allocUnsafe = .{
.rfn = Bun.allocUnsafe,
.ts = .{},
},
.mmap = .{
.rfn = Bun.mmapFile,
.ts = .{},
},
.generateHeapSnapshot = .{
.rfn = Bun.generateHeapSnapshot,
.ts = d.ts{},
},
.shrink = .{
.rfn = Bun.shrink,
.ts = d.ts{},
},
.openInEditor = .{
.rfn = Bun.openInEditor,
.ts = d.ts{},
},
.readAllStdinSync = .{
.rfn = Bun.readAllStdinSync,
.ts = d.ts{},
},
.serve = .{
.rfn = Bun.serve,
.ts = d.ts{},
},
.file = .{
.rfn = JSC.WebCore.Blob.constructFile,
.ts = d.ts{},
},
.write = .{
.rfn = JSC.WebCore.Blob.writeFile,
.ts = d.ts{},
},
.sha = .{
.rfn = JSC.wrapWithHasContainer(Crypto.SHA512_256, "hash_", false, false, true),
@@ -1173,15 +1117,12 @@ pub const Class = NewClass(
.{
.main = .{
.get = getMain,
.ts = d.ts{ .name = "main", .@"return" = "string" },
},
.cwd = .{
.get = getCWD,
.ts = d.ts{ .name = "cwd", .@"return" = "string" },
},
.origin = .{
.get = getOrigin,
.ts = d.ts{ .name = "origin", .@"return" = "string" },
},
.stdin = .{
.get = getStdin,
@@ -1194,15 +1135,12 @@ pub const Class = NewClass(
},
.routesDir = .{
.get = getRoutesDir,
.ts = d.ts{ .name = "routesDir", .@"return" = "string" },
},
.assetPrefix = .{
.get = getAssetPrefix,
.ts = d.ts{ .name = "assetPrefix", .@"return" = "string" },
},
.argv = .{
.get = getArgv,
.ts = d.ts{ .name = "argv", .@"return" = "string[]" },
},
.env = .{
.get = EnvironmentVariables.getter,
@@ -1213,19 +1151,16 @@ pub const Class = NewClass(
},
.Transpiler = .{
.get = getTranspilerConstructor,
.ts = d.ts{ .name = "Transpiler", .@"return" = "Transpiler.prototype" },
},
.hash = .{
.get = getHashObject,
},
.TOML = .{
.get = getTOMLObject,
.ts = d.ts{ .name = "TOML", .@"return" = "TOML.prototype" },
},
.unsafe = .{
.get = getUnsafe,
},
.SHA1 = .{
.get = Crypto.SHA1.getter,
},

View File

@@ -178,39 +178,6 @@ fn createRouteObjectFromMatch(
return Instance.make(ctx, router);
}
pub const match_type_definition = &[_]d.ts{
.{
.tsdoc = "Match a {@link https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent FetchEvent} to a `Route` from the local filesystem. Returns `null` if there is no match.",
.args = &[_]d.ts.arg{
.{
.name = "event",
.@"return" = "FetchEvent",
},
},
.@"return" = "Route | null",
},
.{
.tsdoc = "Match a `pathname` to a `Route` from the local filesystem. Returns `null` if there is no match.",
.args = &[_]d.ts.arg{
.{
.name = "pathname",
.@"return" = "string",
},
},
.@"return" = "Route | null",
},
.{
.tsdoc = "Match a {@link https://developer.mozilla.org/en-US/docs/Web/API/Request Request} to a `Route` from the local filesystem. Returns `null` if there is no match.",
.args = &[_]d.ts.arg{
.{
.name = "request",
.@"return" = "Request",
},
},
.@"return" = "Route | null",
},
};
pub const Instance = NewClass(
Router,
.{

View File

@@ -2323,7 +2323,6 @@ pub const EventListenerMixin = struct {
.{
.@"callAsFunction" = .{
.rfn = Handler.addListener,
.ts = d.ts{},
},
},
.{},
@@ -2413,7 +2412,6 @@ pub const ResolveError = struct {
.@"referrer" = .{
.@"get" = getReferrer,
.ro = true,
.ts = d.ts{ .@"return" = "string" },
},
.@"code" = .{
.@"get" = getCode,
@@ -2422,27 +2420,22 @@ pub const ResolveError = struct {
.@"message" = .{
.@"get" = getMessage,
.ro = true,
.ts = d.ts{ .@"return" = "string" },
},
.@"name" = .{
.@"get" = getName,
.ro = true,
.ts = d.ts{ .@"return" = "string" },
},
.@"specifier" = .{
.@"get" = getSpecifier,
.ro = true,
.ts = d.ts{ .@"return" = "string" },
},
.@"importKind" = .{
.@"get" = getImportKind,
.ro = true,
.ts = d.ts{ .@"return" = "string" },
},
.@"position" = .{
.@"get" = getPosition,
.ro = true,
.ts = d.ts{ .@"return" = "string" },
},
},
);
@@ -2897,9 +2890,9 @@ pub const HardcodedModule = enum {
.{ "node:path/win32", "node:path" },
.{ "node:perf_hooks", "node:perf_hooks" },
.{ "node:process", "node:process" },
.{ "node:stream", "node:stream" },
.{ "node:stream/consumer", "node:stream/consumer" },
.{ "node:stream/web", "node:stream/web" },
.{ "node:stream", "node:stream" },
.{ "node:string_decoder", "node:string_decoder" },
.{ "node:timers", "node:timers" },
.{ "node:timers/promises", "node:timers/promises" },
@@ -2910,9 +2903,9 @@ pub const HardcodedModule = enum {
.{ "path/win32", "node:path" },
.{ "perf_hooks", "node:perf_hooks" },
.{ "process", "node:process" },
.{ "stream", "node:stream" },
.{ "stream/consumer", "node:stream/consumer" },
.{ "stream/web", "node:stream/web" },
.{ "stream", "node:stream" },
.{ "string_decoder", "node:string_decoder" },
.{ "timers", "node:timers" },
.{ "timers/promises", "node:timers/promises" },

View File

@@ -1,110 +0,0 @@
const d = @import("./base.zig").d;
const std = @import("std");
const Router = @import("./api/router.zig");
const builtin = @import("builtin");
const io = std.io;
const fs = std.fs;
const process = std.process;
const ChildProcess = std.ChildProcess;
const Progress = std.Progress;
const print = std.debug.print;
const mem = std.mem;
const testing = std.testing;
const Allocator = std.mem.Allocator;
const resolve_path = @import("../resolver/resolve_path.zig");
const JSC = @import("../jsc.zig");
const bun = @import("../global.zig");
const string = bun.string;
const strings = bun.strings;
const default_allocator = bun.default_allocator;
pub const bindgen = true;
pub fn main() anyerror!void {
const modules = comptime [_]d.ts.decl{
JSC.Node.NodeFSBindings.typescriptDeclaration(),
};
const hidden_globals = comptime [_]d.ts.decl{
JSC.WebCore.FetchEvent.Class.typescriptDeclaration(),
};
const globals = comptime [_]d.ts.decl{
Router.Instance.typescriptDeclaration(),
JSC.Bun.Class.typescriptDeclaration(),
JSC.BuildError.Class.typescriptDeclaration(),
JSC.ResolveError.Class.typescriptDeclaration(),
JSC.WebCore.Response.Class.typescriptDeclaration(),
JSC.WebCore.Headers.Class.typescriptDeclaration(),
JSC.EventListenerMixin.addEventListener(JSC.VirtualMachine).typescriptDeclaration(),
JSC.WebCore.Fetch.Class.typescriptDeclaration(),
JSC.Performance.Class.typescriptDeclaration(),
JSC.Crypto.Class.typescriptDeclaration(),
JSC.API.Transpiler.Class.typescriptDeclaration(),
};
var allocator = default_allocator;
var argv = std.mem.span(std.os.argv);
var dest = [_]string{ std.mem.span(argv[argv.len - 2]), std.mem.span(argv[argv.len - 1]) };
var stdout = std.io.getStdOut();
var writer = stdout.writer();
try writer.print("{s}/{s}\n", .{ dest[0], dest[1] });
var dir_path = resolve_path.joinAbsString(try std.process.getCwdAlloc(allocator), &dest, .auto);
std.debug.assert(dir_path.len > 0 and strings.eqlComptime(std.fs.path.basename(dir_path), "types"));
std.fs.deleteTreeAbsolute(dir_path) catch {};
try std.fs.makeDirAbsolute(dir_path);
var dir = try std.fs.openDirAbsolute(dir_path, std.fs.Dir.OpenDirOptions{});
var index_file = try dir.createFile("index.d.ts", .{});
try index_file.writeAll(
\\/// <reference no-default-lib="true" />
\\/// <reference lib="esnext" />
\\/// <reference types="bun.js/types/globals" />
\\/// <reference types="bun.js/types/modules" />
\\
);
var global_file = try dir.createFile("globals.d.ts", .{});
try global_file.writeAll(
\\// bun.js v
\\
\\
);
inline for (globals) |global| {
try global_file.writeAll(comptime d.ts.class.Printer.printDecl(global, 0));
}
var module_file = try dir.createFile("modules.d.ts", .{});
try module_file.writeAll(
\\// bun.js v
\\
\\
);
try global_file.writeAll("\n");
try global_file.writeAll("declare global {\n");
inline for (hidden_globals) |module, i| {
if (i > 0) {
try global_file.writeAll("\n");
}
try global_file.writeAll(comptime d.ts.class.Printer.printDecl(module, 2));
}
try global_file.writeAll("}\n\n");
try stdout.writeAll(" ✔️ index.d.ts\n");
inline for (modules) |decl| {
comptime var module: d.ts.module = decl.module;
const basepath = comptime module.path;
if (std.fs.path.dirname(basepath)) |dirname| {
try dir.makePath(dirname);
}
try module_file.writeAll(comptime d.ts.class.Printer.printDecl(decl, 0));
try stdout.writeAll(comptime " ✔️ " ++ basepath ++ " - modules.d.ts\n");
}
try global_file.writeAll("export {};\n");
}

View File

@@ -397,7 +397,6 @@ pub const RunCommand = struct {
this_bundler.runEnvLoader() catch {};
if (root_dir_info.getEntries()) |dir| {
// Run .env again if it exists in a parent dir
if (this_bundler.options.production) {
this_bundler.env.load(&this_bundler.fs.fs, dir, false) catch {};

View File

@@ -1,5 +0,0 @@
pub const bindgen = true;
pub fn main() anyerror!void {
return try @import("bun.js/typescript.zig").main();
}