@use-worker/oxc 0.1.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Andrew Ingram
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # @use-worker/oxc
2
+
3
+ Standalone JS/TS/JSX preprocessing and parsing for the ESTree compiler.
4
+ Used by the Bun and Webpack/Turbopack integrations. Vite supplies its own parser
5
+ and does not depend on this package. Source-map composition is not yet complete.
6
+
7
+ Experimental, unpublished `0.0.0` packages.
@@ -0,0 +1,63 @@
1
+ # Third-party notices
2
+
3
+ Parts of the scope analysis and function-hoisting approach in
4
+ `src/compiler/closure-scope.ts` and `src/compiler/hoist.ts` are adapted from the official Vite
5
+ React Server Components transform:
6
+
7
+ https://github.com/vitejs/vite-plugin-react/tree/11ad0af/packages/plugin-rsc/src/transforms
8
+
9
+ Vite is distributed under the following license:
10
+
11
+ > MIT License
12
+ >
13
+ > Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors
14
+ >
15
+ > Permission is hereby granted, free of charge, to any person obtaining a copy
16
+ > of this software and associated documentation files (the "Software"), to deal
17
+ > in the Software without restriction, including without limitation the rights
18
+ > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19
+ > copies of the Software, and to permit persons to whom the Software is
20
+ > furnished to do so, subject to the following conditions:
21
+ >
22
+ > The above copyright notice and this permission notice shall be included in all
23
+ > copies or substantial portions of the Software.
24
+ >
25
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26
+ > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27
+ > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28
+ > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29
+ > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30
+ > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31
+ > SOFTWARE.
32
+
33
+ The directive typo-detection algorithm in `src/compiler/transform.ts` and capture-path
34
+ coalescing in `src/compiler/hoist.ts` are adapted from the Next.js Server Actions
35
+ transform:
36
+
37
+ https://github.com/vercel/next.js/blob/090f1b72753b2d0094235d27d46ffa0da5fc7d35/crates/next-custom-transforms/src/transforms/server_actions.rs#L3231-L3285
38
+
39
+ https://github.com/vercel/next.js/blob/090f1b72753b2d0094235d27d46ffa0da5fc7d35/crates/next-custom-transforms/src/transforms/server_actions.rs#L2920-L2966
40
+
41
+ Next.js is distributed under the following license:
42
+
43
+ > The MIT License (MIT)
44
+ >
45
+ > Copyright (c) 2025 Vercel, Inc.
46
+ >
47
+ > Permission is hereby granted, free of charge, to any person obtaining a copy
48
+ > of this software and associated documentation files (the "Software"), to deal
49
+ > in the Software without restriction, including without limitation the rights
50
+ > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
51
+ > copies of the Software, and to permit persons to whom the Software is
52
+ > furnished to do so, subject to the following conditions:
53
+ >
54
+ > The above copyright notice and this permission notice shall be included in all
55
+ > copies or substantial portions of the Software.
56
+ >
57
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
58
+ > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
59
+ > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
60
+ > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
61
+ > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
62
+ > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
63
+ > SOFTWARE.
@@ -0,0 +1,8 @@
1
+ import { type CompilationOptions } from "@use-worker/compiler-estree";
2
+ export { createModuleWorkerEntry, mayContainWorkerDirective } from "@use-worker/compiler-estree";
3
+ /** Standalone preprocessing for hosts that do not already supply a parser. */
4
+ export declare function compileSource(options: CompilationOptions): {
5
+ code: string;
6
+ map: string;
7
+ compilation: import("@use-worker/compiler-estree").WorkerCompilation | undefined;
8
+ };
package/dist/index.js ADDED
@@ -0,0 +1,25 @@
1
+ import remapping from "@jridgewell/remapping";
2
+ import { parseSync } from "oxc-parser";
3
+ import { transformSync } from "oxc-transform";
4
+ import { compileWorkerModule } from "@use-worker/compiler-estree";
5
+ export { createModuleWorkerEntry, mayContainWorkerDirective } from "@use-worker/compiler-estree";
6
+ /** Standalone preprocessing for hosts that do not already supply a parser. */
7
+ export function compileSource(options) {
8
+ const result = transformSync(options.sourceId, options.code, {
9
+ sourceType: "module",
10
+ sourcemap: true,
11
+ ...(/\.[cm]?jsx?$/.test(options.sourceId) ? { lang: "jsx" } : {}),
12
+ });
13
+ if (result.errors.length)
14
+ throw new Error(result.errors.map(error => error.message).join("\n"));
15
+ if (!result.map)
16
+ throw new Error("Oxc did not return the requested source map");
17
+ const map = remapping(options.inputMap ? [JSON.stringify(result.map), options.inputMap] : JSON.stringify(result.map), () => null).toString();
18
+ const compilation = compileWorkerModule({ ...options, code: result.code, inputMap: map }, code => {
19
+ const parsed = parseSync("worker.js", code, { sourceType: "module" });
20
+ if (parsed.errors.length)
21
+ throw new Error(parsed.errors.map(error => error.message).join("\n"));
22
+ return parsed.program;
23
+ });
24
+ return { code: result.code, map, compilation };
25
+ }
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@use-worker/oxc",
3
+ "version": "0.1.0-beta.0",
4
+ "type": "module",
5
+ "license": "MIT",
6
+ "files": [
7
+ "dist",
8
+ "THIRD_PARTY_NOTICES.md",
9
+ "LICENSE"
10
+ ],
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "default": "./dist/index.js"
15
+ }
16
+ },
17
+ "dependencies": {
18
+ "@jridgewell/remapping": "2.3.5",
19
+ "oxc-parser": "0.148.0",
20
+ "oxc-transform": "0.148.0",
21
+ "@use-worker/compiler-estree": "0.1.0-beta.0"
22
+ },
23
+ "description": "Standalone Oxc preprocessing and parsing for use-worker.",
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
27
+ "scripts": {
28
+ "build": "node ../../scripts/build-package.mjs",
29
+ "typecheck": "tsc -p tsconfig.json --noEmit"
30
+ }
31
+ }