-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5283 from systeminit/arm
fix: arm rootfs needs an arm linker
- Loading branch information
Showing
8 changed files
with
194 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import * as _ from "npm:lodash-es"; | ||
import { transpile } from "jsr:@deno/emit"; | ||
import { Debug } from "./debug.ts"; | ||
import { lock } from "npm:proper-lockfile"; | ||
|
||
const debug = Debug("langJs:transpile"); | ||
|
||
const LOCK_FILE = "/tmp/lang-js-transpile"; | ||
|
||
async function ensureLockfile() { | ||
try { | ||
await Deno.writeTextFile(LOCK_FILE, ""); | ||
} catch (err) { | ||
if (!(err instanceof Deno.errors.AlreadyExists)) { | ||
throw err; | ||
} | ||
} | ||
} | ||
|
||
export function bundleCode(code: string): Promise<string> { | ||
return (async () => { | ||
let release; | ||
|
||
await ensureLockfile(); | ||
|
||
try { | ||
release = await lock("/tmp/lang-js-transpile", { | ||
stale: 30000, | ||
updateInterval: 1000, | ||
retries: { | ||
retries: 60, | ||
minTimeout: 100, | ||
maxTimeout: 1000, | ||
}, | ||
}); | ||
|
||
debug({ "code before bundle": code }); | ||
const tempDir = await Deno.makeTempDir(); | ||
const tempFile = `${tempDir}/script.ts`; | ||
|
||
await Deno.writeTextFile(tempFile, code); | ||
const fileUrl = new URL(tempFile, import.meta.url); | ||
|
||
try { | ||
const result = await transpile(fileUrl); | ||
const bundled = result.get(fileUrl.href) as string; | ||
if (!bundled) { | ||
throw new Error("Transpilation resulted in empty output"); | ||
} | ||
debug({ "code after bundle": bundled }); | ||
return bundled; | ||
} finally { | ||
await Deno.remove(tempDir, { recursive: true }); | ||
} | ||
} finally { | ||
if (release) { | ||
await release(); | ||
} | ||
} | ||
})(); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.