windows: fix bundler reliability and nuke WSL-based codegen scripts (#8890)

* bruh

* yeaaahhhhhhhhhhhhhhhhhhhhhhhhhhh

* revisions

* yeah

* fix

* make no codegen do less things
This commit is contained in:
dave caruso
2024-02-13 20:33:24 -08:00
committed by GitHub
parent 04a6ebaa17
commit aba37525a6
18 changed files with 132 additions and 60 deletions

View File

@@ -1,3 +1,5 @@
import { pathToUpperSnakeCase } from "./helpers";
// This is the implementation for $debug
export function createLogClientJS(filepath: string, publicName: string) {
return `
@@ -5,16 +7,8 @@ let $debug_log_enabled = ((env) => (
// The rationale for checking all these variables is just so you don't have to exactly remember which one you set.
(env.BUN_DEBUG_ALL && env.BUN_DEBUG_ALL !== '0')
|| (env.BUN_DEBUG_JS && env.BUN_DEBUG_JS !== '0')
|| (env.BUN_DEBUG_${filepath
.replace(/^.*?:/, "")
.split(/[-_./]/g)
.join("_")
.toUpperCase()})
|| (env.DEBUG_${filepath
.replace(/^.*?:/, "")
.split(/[-_./]/g)
.join("_")
.toUpperCase()})
|| (env.BUN_DEBUG_${pathToUpperSnakeCase(filepath)})
|| (env.DEBUG_${pathToUpperSnakeCase(filepath)})
))(Bun.env);
let $debug_pid_prefix = Bun.env.SHOW_PID === '1';
let $debug_log = $debug_log_enabled ? (...args) => {

View File

@@ -18,8 +18,9 @@ const to_remove = new RegExp(`#if\\s+(!OS\\(${os}\\)|OS\\((${other_oses.join("|"
const input_preprocessed = to_preprocess.replace(to_remove, "");
console.log("Generating " + output + " from " + input);
const proc = spawn({
cmd: [create_hash_table, "-"],
cmd: ["perl", create_hash_table, "-"],
stdin: "pipe",
stdout: "pipe",
stderr: "inherit",

View File

@@ -952,6 +952,7 @@ await Bun.write(resolve(outDir + "/JSSink.lut.txt"), lutInput());
Bun.spawnSync(
[
process.execPath,
"run",
join(import.meta.dir, "create-hash-table.ts"),
resolve(outDir + "/JSSink.lut.txt"),
join(outDir, "JSSink.lut.h"),

View File

@@ -80,3 +80,11 @@ export function writeIfNotChanged(file: string, contents: string) {
fs.writeFileSync(file, contents);
}
}
export function pathToUpperSnakeCase(filepath: string) {
return filepath
.replace(/^.*?:/, "")
.split(/[-_./\\]/g)
.join("_")
.toUpperCase();
}

View File

@@ -7,6 +7,7 @@ export function createInternalModuleRegistry(basedir: string) {
.flatMap(dir => readdirRecursive(path.join(basedir, dir)))
.filter(file => file.endsWith(".js") || (file.endsWith(".ts") && !file.endsWith(".d.ts")))
.map(file => file.slice(basedir.length + 1))
.map(x => x.replaceAll("\\", "/"))
.sort();
// Create the Internal Module Registry
@@ -66,7 +67,7 @@ export function createInternalModuleRegistry(basedir: string) {
resolveSyncOrNull(specifier, path.join(basedir, path.dirname(from))) ?? resolveSyncOrNull(specifier, basedir);
if (relativeMatch) {
const found = moduleList.indexOf(path.relative(basedir, relativeMatch));
const found = moduleList.indexOf(path.relative(basedir, relativeMatch).replaceAll("\\", "/"));
if (found === -1) {
throw new Error(
`Builtin Bundler: "${specifier}" cannot be imported here because it doesn't get a module ID. Only files in "src/js" besides "src/js/builtins" can be used here. Note that the 'node:' or 'bun:' prefix is required here. `,