unrun 0.2.30 → 0.2.32

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/cli.mjs CHANGED
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
  import process from "node:process";
3
-
4
3
  //#region src/cli.ts
5
4
  function parseCLIArguments(argv) {
6
5
  let debug = false;
@@ -100,6 +99,5 @@ runCLI().catch((error) => {
100
99
  console.error(error.message);
101
100
  process.exit(1);
102
101
  });
103
-
104
102
  //#endregion
105
- export { };
103
+ export {};
package/dist/index.mjs CHANGED
@@ -1,58 +1,2 @@
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
-
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
58
- export { unrun, unrunCli, unrunSync };
1
+ import { n as unrunCli, r as unrunSync, t as unrun } from "./src-GU5PtktT.mjs";
2
+ export { unrun, unrunCli, unrunSync };
@@ -8,10 +8,8 @@ import { Buffer as Buffer$1 } from "node:buffer";
8
8
  import { spawn } from "node:child_process";
9
9
  import crypto from "node:crypto";
10
10
  import { tmpdir } from "node:os";
11
-
12
11
  //#region \0rolldown/runtime.js
13
12
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
14
-
15
13
  //#endregion
16
14
  //#region src/features/preset.ts
17
15
  /**
@@ -26,7 +24,6 @@ function preset(options, module) {
26
24
  if (module && typeof module === "object" && "default" in module) return module.default;
27
25
  return module;
28
26
  }
29
-
30
27
  //#endregion
31
28
  //#region src/utils/normalize-path.ts
32
29
  /**
@@ -54,7 +51,6 @@ function normalizePath(pathLike) {
54
51
  }
55
52
  return String(pathLike);
56
53
  }
57
-
58
54
  //#endregion
59
55
  //#region src/options.ts
60
56
  function resolveOptions(options = {}) {
@@ -73,7 +69,6 @@ function resolveOptions(options = {}) {
73
69
  ]).has(resolvedOptions.preset)) throw new Error(`[unrun] Invalid preset "${resolvedOptions.preset}" (expected: none | jiti | bundle-require)`);
74
70
  return resolvedOptions;
75
71
  }
76
-
77
72
  //#endregion
78
73
  //#region src/utils/module-resolution.ts
79
74
  /**
@@ -87,7 +82,6 @@ function isBuiltinModuleSpecifier(id) {
87
82
  if (!id) return false;
88
83
  return BUILTIN_MODULE_SPECIFIERS.has(id) || id.startsWith("node:");
89
84
  }
90
-
91
85
  //#endregion
92
86
  //#region src/features/external.ts
93
87
  /**
@@ -127,7 +121,6 @@ function getPackageName(specifier) {
127
121
  const [name] = specifier.split("/");
128
122
  return name || void 0;
129
123
  }
130
-
131
124
  //#endregion
132
125
  //#region src/plugins/console-output-customizer.ts
133
126
  const INSPECT_HELPER_SNIPPET = `(function(){
@@ -272,7 +265,6 @@ function insertAfterShebang(code, insertion) {
272
265
  if (nl === -1) return `${code}\n${insertion}`;
273
266
  return `${code.slice(0, nl + 1)}${insertion}${code.slice(nl + 1)}`;
274
267
  }
275
-
276
268
  //#endregion
277
269
  //#region src/plugins/json-loader.ts
278
270
  /**
@@ -322,7 +314,6 @@ function createJsonLoader() {
322
314
  }
323
315
  };
324
316
  }
325
-
326
317
  //#endregion
327
318
  //#region src/plugins/make-cjs-wrapper-async-friendly.ts
328
319
  /**
@@ -380,7 +371,6 @@ function createMakeCjsWrapperAsyncFriendlyPlugin() {
380
371
  } }
381
372
  };
382
373
  }
383
-
384
374
  //#endregion
385
375
  //#region src/plugins/require-resolve-fix.ts
386
376
  /**
@@ -416,7 +406,6 @@ function createRequireResolveFix(options) {
416
406
  } }
417
407
  };
418
408
  }
419
-
420
409
  //#endregion
421
410
  //#region src/plugins/require-typeof-fix.ts
422
411
  /**
@@ -431,7 +420,6 @@ function createRequireTypeofFix() {
431
420
  } }
432
421
  };
433
422
  }
434
-
435
423
  //#endregion
436
424
  //#region src/plugins/source-context-shims.ts
437
425
  /**
@@ -637,7 +625,6 @@ function createSourceContextShimsPlugin() {
637
625
  }
638
626
  };
639
627
  }
640
-
641
628
  //#endregion
642
629
  //#region src/utils/bundle.ts
643
630
  async function bundle(options) {
@@ -685,7 +672,6 @@ async function bundle(options) {
685
672
  dependencies: files
686
673
  };
687
674
  }
688
-
689
675
  //#endregion
690
676
  //#region src/utils/module/clean-module.ts
691
677
  /**
@@ -705,7 +691,6 @@ function cleanModule(moduleUrl, options) {
705
691
  if (error.code !== "ENOENT") throw error;
706
692
  }
707
693
  }
708
-
709
694
  //#endregion
710
695
  //#region src/utils/module/exec-module.ts
711
696
  /**
@@ -789,7 +774,6 @@ function execModule(moduleUrl, args = []) {
789
774
  });
790
775
  });
791
776
  }
792
-
793
777
  //#endregion
794
778
  //#region src/utils/module/write-module.ts
795
779
  function sanitize(name) {
@@ -826,7 +810,6 @@ function writeModule(code, options) {
826
810
  }
827
811
  return moduleUrl;
828
812
  }
829
-
830
813
  //#endregion
831
814
  //#region src/utils/module/load-module.ts
832
815
  /**
@@ -846,6 +829,59 @@ async function loadModule(code, options) {
846
829
  }
847
830
  return _module;
848
831
  }
849
-
850
832
  //#endregion
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 };
833
+ //#region src/index.ts
834
+ /**
835
+ * Loads a module with JIT transpilation based on the provided options.
836
+ *
837
+ * @param options - The options for loading the module.
838
+ * @returns A promise that resolves to the loaded module.
839
+ */
840
+ async function unrun(options) {
841
+ const resolvedOptions = resolveOptions(options);
842
+ const output = await bundle(resolvedOptions);
843
+ let module;
844
+ try {
845
+ module = await loadModule(output.chunk.code, resolvedOptions);
846
+ } catch (error) {
847
+ throw new Error(`[unrun] Import failed (code length: ${output.chunk.code.length}): ${error.message}`, { cause: error });
848
+ }
849
+ return {
850
+ module: preset(resolvedOptions, module),
851
+ dependencies: output.dependencies
852
+ };
853
+ }
854
+ /**
855
+ * Loads a module with JIT transpilation based on the provided options.
856
+ * This function runs synchronously using a worker thread.
857
+ *
858
+ * @param options - The options for loading the module.
859
+ * @returns The loaded module.
860
+ */
861
+ function unrunSync(options) {
862
+ const { createSyncFn } = __require("synckit");
863
+ return createSyncFn(__require.resolve("./sync/worker.mjs"), { tsRunner: "node" })(options);
864
+ }
865
+ /**
866
+ * Runs a given module with JIT transpilation based on the provided options.
867
+ * This function does not return the module, as it simply executes it.
868
+ * Corresponds to the CLI behavior.
869
+ *
870
+ * @param options - The options for running the module.
871
+ * @param args - Additional command-line arguments to pass to the module.
872
+ */
873
+ async function unrunCli(options, args = []) {
874
+ const resolvedOptions = resolveOptions(options);
875
+ const output = await bundle(resolvedOptions);
876
+ const moduleUrl = writeModule(output.chunk.code, resolvedOptions);
877
+ let cliResult;
878
+ try {
879
+ cliResult = await execModule(moduleUrl, args);
880
+ } catch (error) {
881
+ throw new Error(`[unrun] Run failed (code length: ${output.chunk.code.length}): ${error.message}`, { cause: error });
882
+ }
883
+ cleanModule(moduleUrl, resolvedOptions);
884
+ return cliResult;
885
+ }
886
+ //#endregion
887
+ export { unrunCli as n, unrunSync as r, unrun as t };
@@ -1,7 +1,5 @@
1
- import "../load-module-CeH7YHFU.mjs";
2
- import { unrun } from "../index.mjs";
1
+ import { t as unrun } from "../src-GU5PtktT.mjs";
3
2
  import { runAsWorker } from "synckit";
4
-
5
3
  //#region src/sync/worker.ts
6
4
  function cloneForTransfer(value, seen = /* @__PURE__ */ new WeakMap()) {
7
5
  if (typeof value === "function") throw new TypeError("[unrun] unrunSync cannot return functions");
@@ -46,6 +44,5 @@ runAsWorker(async (...args) => {
46
44
  const options = args[0];
47
45
  return cloneForTransfer(await unrun(options));
48
46
  });
49
-
50
47
  //#endregion
51
- export { };
48
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "unrun",
3
3
  "type": "module",
4
- "version": "0.2.30",
4
+ "version": "0.2.32",
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,13 +42,13 @@
42
42
  }
43
43
  },
44
44
  "dependencies": {
45
- "rolldown": "1.0.0-rc.7"
45
+ "rolldown": "1.0.0-rc.9"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@sxzz/eslint-config": "^7.8.3",
49
49
  "@sxzz/prettier-config": "^2.3.1",
50
- "@types/node": "^25.3.3",
51
- "@typescript/native-preview": "7.0.0-dev.20260305.1",
50
+ "@types/node": "^25.4.0",
51
+ "@typescript/native-preview": "7.0.0-dev.20260311.1",
52
52
  "@vitest/browser": "4.0.18",
53
53
  "@vitest/browser-playwright": "4.0.18",
54
54
  "@webcontainer/api": "^1.6.1",
@@ -60,7 +60,7 @@
60
60
  "defu": "^6.1.4",
61
61
  "destr": "^2.0.5",
62
62
  "esbuild": "^0.27.3",
63
- "eslint": "^10.0.2",
63
+ "eslint": "^10.0.3",
64
64
  "estree-walker": "^3.0.3",
65
65
  "etag": "^1.8.1",
66
66
  "fast-glob": "^3.3.3",
@@ -71,7 +71,7 @@
71
71
  "moment-timezone": "^0.6.0",
72
72
  "nano-jsx": "^0.2.1",
73
73
  "playwright": "^1.58.2",
74
- "preact": "^10.28.4",
74
+ "preact": "^10.29.0",
75
75
  "preact-render-to-string": "^6.6.6",
76
76
  "prettier": "^3.8.1",
77
77
  "react": "^19.2.4",
@@ -80,7 +80,7 @@
80
80
  "synckit": "^0.11.12",
81
81
  "test-ecosystem-ci": "^0.0.3",
82
82
  "tinyexec": "^1.0.2",
83
- "tsdown": "0.20.3",
83
+ "tsdown": "0.21.1",
84
84
  "tsx": "^4.21.0",
85
85
  "typedoc": "^0.28.17",
86
86
  "typedoc-plugin-markdown": "^4.10.0",
@@ -92,7 +92,7 @@
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.29",
95
+ "vue": "^3.5.30",
96
96
  "vue-tsc": "^3.2.5",
97
97
  "zod": "^4.3.6"
98
98
  },