unrun 0.2.28 → 0.2.30

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/dist/index.mjs CHANGED
@@ -1,3 +1,58 @@
1
- import { n as unrunCli, r as unrunSync, t as unrun } from "./src-CS8hJStK.mjs";
1
+ import { a as bundle, c as __require, i as cleanModule, n as writeModule, o as resolveOptions, r as execModule, s as preset, t as loadModule } from "./load-module-CeH7YHFU.mjs";
2
2
 
3
+ //#region src/index.ts
4
+ /**
5
+ * Loads a module with JIT transpilation based on the provided options.
6
+ *
7
+ * @param options - The options for loading the module.
8
+ * @returns A promise that resolves to the loaded module.
9
+ */
10
+ async function unrun(options) {
11
+ const resolvedOptions = resolveOptions(options);
12
+ const output = await bundle(resolvedOptions);
13
+ let module;
14
+ try {
15
+ module = await loadModule(output.chunk.code, resolvedOptions);
16
+ } catch (error) {
17
+ throw new Error(`[unrun] Import failed (code length: ${output.chunk.code.length}): ${error.message}`);
18
+ }
19
+ return {
20
+ module: preset(resolvedOptions, module),
21
+ dependencies: output.dependencies
22
+ };
23
+ }
24
+ /**
25
+ * Loads a module with JIT transpilation based on the provided options.
26
+ * This function runs synchronously using a worker thread.
27
+ *
28
+ * @param options - The options for loading the module.
29
+ * @returns The loaded module.
30
+ */
31
+ function unrunSync(options) {
32
+ const { createSyncFn } = __require("synckit");
33
+ return createSyncFn(__require.resolve("./sync/worker.mjs"), { tsRunner: "node" })(options);
34
+ }
35
+ /**
36
+ * Runs a given module with JIT transpilation based on the provided options.
37
+ * This function does not return the module, as it simply executes it.
38
+ * Corresponds to the CLI behavior.
39
+ *
40
+ * @param options - The options for running the module.
41
+ * @param args - Additional command-line arguments to pass to the module.
42
+ */
43
+ async function unrunCli(options, args = []) {
44
+ const resolvedOptions = resolveOptions(options);
45
+ const output = await bundle(resolvedOptions);
46
+ const moduleUrl = writeModule(output.chunk.code, resolvedOptions);
47
+ let cliResult;
48
+ try {
49
+ cliResult = await execModule(moduleUrl, args);
50
+ } catch (error) {
51
+ throw new Error(`[unrun] Run failed (code length: ${output.chunk.code.length}): ${error.message}`);
52
+ }
53
+ cleanModule(moduleUrl, resolvedOptions);
54
+ return cliResult;
55
+ }
56
+
57
+ //#endregion
3
58
  export { unrun, unrunCli, unrunSync };
@@ -9,7 +9,7 @@ import { spawn } from "node:child_process";
9
9
  import crypto from "node:crypto";
10
10
  import { tmpdir } from "node:os";
11
11
 
12
- //#region rolldown:runtime
12
+ //#region \0rolldown/runtime.js
13
13
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
14
14
 
15
15
  //#endregion
@@ -848,59 +848,4 @@ async function loadModule(code, options) {
848
848
  }
849
849
 
850
850
  //#endregion
851
- //#region src/index.ts
852
- /**
853
- * Loads a module with JIT transpilation based on the provided options.
854
- *
855
- * @param options - The options for loading the module.
856
- * @returns A promise that resolves to the loaded module.
857
- */
858
- async function unrun(options) {
859
- const resolvedOptions = resolveOptions(options);
860
- const output = await bundle(resolvedOptions);
861
- let module;
862
- try {
863
- module = await loadModule(output.chunk.code, resolvedOptions);
864
- } catch (error) {
865
- throw new Error(`[unrun] Import failed (code length: ${output.chunk.code.length}): ${error.message}`);
866
- }
867
- return {
868
- module: preset(resolvedOptions, module),
869
- dependencies: output.dependencies
870
- };
871
- }
872
- /**
873
- * Loads a module with JIT transpilation based on the provided options.
874
- * This function runs synchronously using a worker thread.
875
- *
876
- * @param options - The options for loading the module.
877
- * @returns The loaded module.
878
- */
879
- function unrunSync(options) {
880
- const { createSyncFn } = __require("synckit");
881
- return createSyncFn(__require.resolve("./sync/worker.mjs"), { tsRunner: "node" })(options);
882
- }
883
- /**
884
- * Runs a given module with JIT transpilation based on the provided options.
885
- * This function does not return the module, as it simply executes it.
886
- * Corresponds to the CLI behavior.
887
- *
888
- * @param options - The options for running the module.
889
- * @param args - Additional command-line arguments to pass to the module.
890
- */
891
- async function unrunCli(options, args = []) {
892
- const resolvedOptions = resolveOptions(options);
893
- const output = await bundle(resolvedOptions);
894
- const moduleUrl = writeModule(output.chunk.code, resolvedOptions);
895
- let cliResult;
896
- try {
897
- cliResult = await execModule(moduleUrl, args);
898
- } catch (error) {
899
- throw new Error(`[unrun] Run failed (code length: ${output.chunk.code.length}): ${error.message}`);
900
- }
901
- cleanModule(moduleUrl, resolvedOptions);
902
- return cliResult;
903
- }
904
-
905
- //#endregion
906
- export { unrunCli as n, unrunSync as r, unrun as t };
851
+ export { bundle as a, __require as c, cleanModule as i, writeModule as n, resolveOptions as o, execModule as r, preset as s, loadModule as t };
@@ -1,4 +1,5 @@
1
- import { t as unrun } from "../src-CS8hJStK.mjs";
1
+ import "../load-module-CeH7YHFU.mjs";
2
+ import { unrun } from "../index.mjs";
2
3
  import { runAsWorker } from "synckit";
3
4
 
4
5
  //#region src/sync/worker.ts
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "unrun",
3
3
  "type": "module",
4
- "version": "0.2.28",
4
+ "version": "0.2.30",
5
5
  "description": "A tool to load and execute any JavaScript or TypeScript code at runtime.",
6
6
  "author": "Augustin Mercier <gugustinette@proton.me>",
7
7
  "license": "MIT",
@@ -42,25 +42,25 @@
42
42
  }
43
43
  },
44
44
  "dependencies": {
45
- "rolldown": "1.0.0-rc.5"
45
+ "rolldown": "1.0.0-rc.7"
46
46
  },
47
47
  "devDependencies": {
48
- "@sxzz/eslint-config": "^7.7.2",
48
+ "@sxzz/eslint-config": "^7.8.3",
49
49
  "@sxzz/prettier-config": "^2.3.1",
50
- "@types/node": "^25.2.3",
51
- "@typescript/native-preview": "7.0.0-dev.20260204.1",
50
+ "@types/node": "^25.3.3",
51
+ "@typescript/native-preview": "7.0.0-dev.20260305.1",
52
52
  "@vitest/browser": "4.0.18",
53
53
  "@vitest/browser-playwright": "4.0.18",
54
54
  "@webcontainer/api": "^1.6.1",
55
- "acorn": "^8.15.0",
55
+ "acorn": "^8.16.0",
56
56
  "bumpp": "^10.4.1",
57
57
  "bundle-require": "^5.1.0",
58
- "config": "^4.3.0",
58
+ "config": "^4.4.1",
59
59
  "consola": "^3.4.2",
60
60
  "defu": "^6.1.4",
61
61
  "destr": "^2.0.5",
62
62
  "esbuild": "^0.27.3",
63
- "eslint": "^9.39.2",
63
+ "eslint": "^10.0.2",
64
64
  "estree-walker": "^3.0.3",
65
65
  "etag": "^1.8.1",
66
66
  "fast-glob": "^3.3.3",
@@ -71,8 +71,8 @@
71
71
  "moment-timezone": "^0.6.0",
72
72
  "nano-jsx": "^0.2.1",
73
73
  "playwright": "^1.58.2",
74
- "preact": "^10.28.3",
75
- "preact-render-to-string": "^6.6.5",
74
+ "preact": "^10.28.4",
75
+ "preact-render-to-string": "^6.6.6",
76
76
  "prettier": "^3.8.1",
77
77
  "react": "^19.2.4",
78
78
  "react-dom": "^19.2.4",
@@ -80,20 +80,20 @@
80
80
  "synckit": "^0.11.12",
81
81
  "test-ecosystem-ci": "^0.0.3",
82
82
  "tinyexec": "^1.0.2",
83
- "tsdown": "0.20.1",
83
+ "tsdown": "0.20.3",
84
84
  "tsx": "^4.21.0",
85
- "typedoc": "^0.28.16",
85
+ "typedoc": "^0.28.17",
86
86
  "typedoc-plugin-markdown": "^4.10.0",
87
87
  "typedoc-vitepress-theme": "^1.1.2",
88
88
  "typescript": "^5.9.3",
89
- "unconfig": "^7.4.2",
89
+ "unconfig": "^7.5.0",
90
90
  "unplugin-vue": "^7.1.1",
91
91
  "vite": "^7.3.1",
92
92
  "vitepress": "2.0.0-alpha.12",
93
93
  "vitepress-plugin-group-icons": "^1.7.1",
94
94
  "vitest": "4.0.18",
95
- "vue": "^3.5.28",
96
- "vue-tsc": "^3.2.4",
95
+ "vue": "^3.5.29",
96
+ "vue-tsc": "^3.2.5",
97
97
  "zod": "^4.3.6"
98
98
  },
99
99
  "prettier": "@sxzz/prettier-config",