-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: include source map for worker.js on cjs/esm builds
- Loading branch information
1 parent
b4aba72
commit d4a363c
Showing
2 changed files
with
21 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,16 @@ | ||
// This file is aliased by esbuild for commonjs, esm, and browser builds. | ||
const relativeUrl = (await import.meta.resolve('./worker.ts')) as string | ||
// NB(chris): we can't do the obvious thing here (`new URL('./worker.js', import.meta.url)`.) | ||
// Why? This file is consumed by Deno, and in Deno JSR packages `import.meta.url` | ||
// resolves to an `http(s):` protocol. However, `http(s):` protocol URLs are not supported | ||
// by node:worker_threads. | ||
// | ||
// (And oof, in order to switch from node workers to web Workers, | ||
// we'd have to polyfill the web Worker api on top of node. It was easier to go the other way | ||
// around.) | ||
// | ||
// In Node, Bun, and browser environments, this entire file is *ignored*: the esbuild config | ||
// replaces it with a prebuilt base64'd inline javascript URL. See `build_worker_node` in | ||
// the `justfile`. | ||
const relativeUrl = (await (import.meta.resolve as any)('./worker.ts')) as string | ||
export const WORKER_URL = `data:text/javascript;base64,${btoa(` | ||
export * from ${JSON.stringify(relativeUrl)}; | ||
`)}` |