unrun 0.2.37 → 0.3.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/README.md +6 -6
- package/dist/index.mjs +1 -1
- package/dist/{src-GU5PtktT.mjs → src-DgjiW5nf.mjs} +23 -0
- package/dist/sync/worker.mjs +1 -1
- package/package.json +50 -46
package/README.md
CHANGED
|
@@ -28,21 +28,21 @@ npx unrun ./path/to/file.ts
|
|
|
28
28
|
- Async
|
|
29
29
|
|
|
30
30
|
```ts
|
|
31
|
-
import { unrun } from
|
|
31
|
+
import { unrun } from "unrun";
|
|
32
32
|
|
|
33
33
|
const { module } = await unrun({
|
|
34
|
-
path:
|
|
35
|
-
})
|
|
34
|
+
path: "./path/to/file.ts", // Path to the module to load
|
|
35
|
+
});
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
- Sync
|
|
39
39
|
|
|
40
40
|
```ts
|
|
41
|
-
import { unrunSync } from
|
|
41
|
+
import { unrunSync } from "unrun";
|
|
42
42
|
|
|
43
43
|
const { module } = unrunSync({
|
|
44
|
-
path:
|
|
45
|
-
})
|
|
44
|
+
path: "./path/to/file.ts", // Path to the module to load
|
|
45
|
+
});
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
## Credits
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as unrunCli, r as unrunSync, t as unrun } from "./src-
|
|
1
|
+
import { n as unrunCli, r as unrunSync, t as unrun } from "./src-DgjiW5nf.mjs";
|
|
2
2
|
export { unrun, unrunCli, unrunSync };
|
|
@@ -428,6 +428,7 @@ function createRequireTypeofFix() {
|
|
|
428
428
|
* - Injects per-module __filename/__dirname
|
|
429
429
|
* - Replaces import.meta.url with the source file URL
|
|
430
430
|
* - Replaces import.meta.dirname/import.meta.filename with source paths
|
|
431
|
+
* - Replaces import.meta entire object access
|
|
431
432
|
*/
|
|
432
433
|
function createSourceContextShimsPlugin() {
|
|
433
434
|
return {
|
|
@@ -458,13 +459,18 @@ function createSourceContextShimsPlugin() {
|
|
|
458
459
|
const prologueLines = [];
|
|
459
460
|
if (needsFilenameShim) prologueLines.push(`const __filename = ${JSON.stringify(file)}`);
|
|
460
461
|
if (needsDirnameShim) prologueLines.push(`const __dirname = ${JSON.stringify(dir)}`);
|
|
462
|
+
let importMetaShimName = "__unrun_import_meta";
|
|
463
|
+
if (/\b__unrun_import_meta\b/.test(code)) importMetaShimName = "__unrun_import_meta_";
|
|
461
464
|
let transformedCode = code;
|
|
462
465
|
let replacedImportMeta = false;
|
|
466
|
+
let replacedImportMetaObject = false;
|
|
463
467
|
if (hasImportMeta) {
|
|
464
468
|
const resolveRe = /import\s*\.\s*meta\s*\.\s*resolve!?\s*\(\s*(["'])([^"']+)\1\s*\)/y;
|
|
465
469
|
const urlRe = /import\s*\.\s*meta\s*\.\s*url\b/y;
|
|
466
470
|
const dirnameRe = /import\s*\.\s*meta\s*\.\s*dirname\b/y;
|
|
467
471
|
const filenameRe = /import\s*\.\s*meta\s*\.\s*filename\b/y;
|
|
472
|
+
const metaRe = /import\s*\.\s*meta\b/y;
|
|
473
|
+
const parenMetaRe = /\(\s*import\s*\.\s*meta\s*\)/y;
|
|
468
474
|
let out = "";
|
|
469
475
|
let mode = "normal";
|
|
470
476
|
const modeStack = [];
|
|
@@ -612,11 +618,28 @@ function createSourceContextShimsPlugin() {
|
|
|
612
618
|
replacedImportMeta = true;
|
|
613
619
|
continue;
|
|
614
620
|
}
|
|
621
|
+
parenMetaRe.lastIndex = i;
|
|
622
|
+
if (parenMetaRe.test(transformedCode)) {
|
|
623
|
+
out += importMetaShimName;
|
|
624
|
+
i = parenMetaRe.lastIndex;
|
|
625
|
+
replacedImportMeta = true;
|
|
626
|
+
replacedImportMetaObject = true;
|
|
627
|
+
continue;
|
|
628
|
+
}
|
|
629
|
+
metaRe.lastIndex = i;
|
|
630
|
+
if (metaRe.test(transformedCode)) {
|
|
631
|
+
out += importMetaShimName;
|
|
632
|
+
i = metaRe.lastIndex;
|
|
633
|
+
replacedImportMeta = true;
|
|
634
|
+
replacedImportMetaObject = true;
|
|
635
|
+
continue;
|
|
636
|
+
}
|
|
615
637
|
out += ch;
|
|
616
638
|
i += 1;
|
|
617
639
|
}
|
|
618
640
|
if (replacedImportMeta) transformedCode = out;
|
|
619
641
|
}
|
|
642
|
+
if (replacedImportMetaObject) prologueLines.push(`const ${importMetaShimName} = { url: ${JSON.stringify(url)}, filename: ${JSON.stringify(file)}, dirname: ${JSON.stringify(dir)}, env: process.env, resolve: (spec) => new URL(spec, ${JSON.stringify(url)}).href, }`);
|
|
620
643
|
if (prologueLines.length > 0) transformedCode = `${prologueLines.join("\n")}\n${transformedCode}`;
|
|
621
644
|
if (transformedCode !== code) return { code: transformedCode };
|
|
622
645
|
}
|
package/dist/sync/worker.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,56 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unrun",
|
|
3
|
-
"
|
|
4
|
-
"version": "0.2.37",
|
|
3
|
+
"version": "0.3.0",
|
|
5
4
|
"description": "A tool to load and execute any JavaScript or TypeScript code at runtime.",
|
|
6
|
-
"author": "Augustin Mercier <gugustinette@proton.me>",
|
|
7
|
-
"license": "MIT",
|
|
8
|
-
"funding": "https://github.com/sponsors/Gugustinette",
|
|
9
5
|
"homepage": "https://gugustinette.github.io/unrun/",
|
|
10
|
-
"repository": {
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "git+https://github.com/Gugustinette/unrun.git"
|
|
13
|
-
},
|
|
14
6
|
"bugs": {
|
|
15
7
|
"url": "https://github.com/Gugustinette/unrun/issues"
|
|
16
8
|
},
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"author": "Augustin Mercier <gugustinette@proton.me>",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/Gugustinette/unrun.git"
|
|
20
14
|
},
|
|
21
|
-
"
|
|
22
|
-
"module": "./dist/index.mjs",
|
|
23
|
-
"types": "./dist/index.d.mts",
|
|
15
|
+
"funding": "https://github.com/sponsors/Gugustinette",
|
|
24
16
|
"bin": {
|
|
25
17
|
"unrun": "./dist/cli.mjs"
|
|
26
18
|
},
|
|
27
19
|
"files": [
|
|
28
20
|
"dist"
|
|
29
21
|
],
|
|
22
|
+
"type": "module",
|
|
23
|
+
"main": "./dist/index.mjs",
|
|
24
|
+
"module": "./dist/index.mjs",
|
|
25
|
+
"types": "./dist/index.d.mts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": "./dist/index.mjs",
|
|
28
|
+
"./package.json": "./package.json"
|
|
29
|
+
},
|
|
30
30
|
"publishConfig": {
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
|
-
"engines": {
|
|
34
|
-
"node": ">=20.19.0"
|
|
35
|
-
},
|
|
36
|
-
"peerDependencies": {
|
|
37
|
-
"synckit": "^0.11.11"
|
|
38
|
-
},
|
|
39
|
-
"peerDependenciesMeta": {
|
|
40
|
-
"synckit": {
|
|
41
|
-
"optional": true
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
33
|
"dependencies": {
|
|
45
|
-
"rolldown": "1.0.0
|
|
34
|
+
"rolldown": "^1.0.0"
|
|
46
35
|
},
|
|
47
36
|
"devDependencies": {
|
|
48
|
-
"@sxzz/eslint-config": "^
|
|
37
|
+
"@sxzz/eslint-config": "^8.0.0",
|
|
49
38
|
"@sxzz/prettier-config": "^2.3.1",
|
|
50
39
|
"@types/node": "^25.6.0",
|
|
51
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
52
|
-
"@vitest/browser": "4.1.
|
|
53
|
-
"@vitest/browser-playwright": "4.1.
|
|
40
|
+
"@typescript/native-preview": "7.0.0-dev.20260506.1",
|
|
41
|
+
"@vitest/browser": "4.1.5",
|
|
42
|
+
"@vitest/browser-playwright": "4.1.5",
|
|
54
43
|
"@webcontainer/api": "^1.6.4",
|
|
55
44
|
"acorn": "^8.16.0",
|
|
56
45
|
"bumpp": "^11.0.1",
|
|
@@ -60,16 +49,18 @@
|
|
|
60
49
|
"defu": "^6.1.7",
|
|
61
50
|
"destr": "^2.0.5",
|
|
62
51
|
"esbuild": "^0.28.0",
|
|
63
|
-
"eslint": "^10.
|
|
52
|
+
"eslint": "^10.3.0",
|
|
64
53
|
"estree-walker": "^3.0.3",
|
|
65
54
|
"etag": "^1.8.1",
|
|
66
55
|
"fast-glob": "^3.3.3",
|
|
67
56
|
"giget": "^3.2.0",
|
|
68
57
|
"is-installed-globally": "^1.0.0",
|
|
69
|
-
"jiti": "^2.
|
|
58
|
+
"jiti": "^2.7.0",
|
|
70
59
|
"mime": "^4.1.0",
|
|
71
|
-
"moment-timezone": "^0.6.
|
|
60
|
+
"moment-timezone": "^0.6.2",
|
|
72
61
|
"nano-jsx": "^0.2.1",
|
|
62
|
+
"oxfmt": "^0.48.0",
|
|
63
|
+
"oxlint": "^1.63.0",
|
|
73
64
|
"playwright": "^1.59.1",
|
|
74
65
|
"preact": "^10.29.1",
|
|
75
66
|
"preact-render-to-string": "^6.6.7",
|
|
@@ -79,29 +70,39 @@
|
|
|
79
70
|
"reflect-metadata": "^0.2.2",
|
|
80
71
|
"synckit": "^0.11.12",
|
|
81
72
|
"test-ecosystem-ci": "^0.0.3",
|
|
82
|
-
"tinyexec": "^1.1.
|
|
83
|
-
"tsdown": "0.
|
|
73
|
+
"tinyexec": "^1.1.2",
|
|
74
|
+
"tsdown": "0.22.0",
|
|
84
75
|
"tsx": "^4.21.0",
|
|
85
76
|
"typedoc": "^0.28.19",
|
|
86
77
|
"typedoc-plugin-markdown": "^4.11.0",
|
|
87
78
|
"typedoc-vitepress-theme": "^1.1.2",
|
|
88
|
-
"typescript": "^6.0.
|
|
79
|
+
"typescript": "^6.0.3",
|
|
89
80
|
"unconfig": "^7.5.0",
|
|
90
|
-
"unplugin-vue": "^7.
|
|
91
|
-
"vite": "^8.0.
|
|
81
|
+
"unplugin-vue": "^7.2.0",
|
|
82
|
+
"vite": "^8.0.10",
|
|
92
83
|
"vitepress": "2.0.0-alpha.12",
|
|
93
84
|
"vitepress-plugin-group-icons": "^1.7.5",
|
|
94
|
-
"vitest": "4.1.
|
|
95
|
-
"vue": "^3.5.
|
|
96
|
-
"vue-tsc": "^3.2.
|
|
97
|
-
"zod": "^4.3
|
|
85
|
+
"vitest": "4.1.5",
|
|
86
|
+
"vue": "^3.5.34",
|
|
87
|
+
"vue-tsc": "^3.2.8",
|
|
88
|
+
"zod": "^4.4.3"
|
|
89
|
+
},
|
|
90
|
+
"peerDependencies": {
|
|
91
|
+
"synckit": "^0.11.11"
|
|
92
|
+
},
|
|
93
|
+
"peerDependenciesMeta": {
|
|
94
|
+
"synckit": {
|
|
95
|
+
"optional": true
|
|
96
|
+
}
|
|
98
97
|
},
|
|
99
98
|
"prettier": "@sxzz/prettier-config",
|
|
99
|
+
"engines": {
|
|
100
|
+
"node": "^22.13.0 || >=24.0.0"
|
|
101
|
+
},
|
|
100
102
|
"scripts": {
|
|
101
|
-
"lint": "eslint --no-cache .",
|
|
102
|
-
"lint:fix": "pnpm run lint --fix",
|
|
103
103
|
"build": "tsdown",
|
|
104
104
|
"dev": "tsdown --watch",
|
|
105
|
+
"playground": "node ./playground/build.mjs",
|
|
105
106
|
"pretest": "pnpm run build && node ./scripts/manage-pnpm-override.mjs add",
|
|
106
107
|
"test": "vitest",
|
|
107
108
|
"pretest:browser": "pnpm run build",
|
|
@@ -114,8 +115,11 @@
|
|
|
114
115
|
"ecosystem-ci:force": "ecosystem-ci --force",
|
|
115
116
|
"test:update-fixtures": "node ./dist/cli.mjs ./scripts/update-fixtures.ts",
|
|
116
117
|
"benchmark": "tsdown -c benchmark/tsdown.config.ts && node ./benchmark/dist/benchmark.mjs",
|
|
118
|
+
"lint": "oxlint",
|
|
119
|
+
"lint:fix": "oxlint --fix",
|
|
120
|
+
"fmt": "oxfmt",
|
|
121
|
+
"fmt:check": "oxfmt --check",
|
|
117
122
|
"typecheck": "tsgo --noEmit",
|
|
118
|
-
"format": "prettier --cache --write .",
|
|
119
123
|
"release": "bumpp",
|
|
120
124
|
"docs:dev": "vitepress dev docs",
|
|
121
125
|
"docs:build": "vitepress build docs",
|