unrun 0.2.11 → 0.2.12
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 +1 -1
- package/dist/{src-DyfW0b4_.mjs → src-BMOFH46e.mjs} +31 -28
- package/dist/sync/worker.mjs +1 -1
- package/package.json +10 -10
package/dist/index.mjs
CHANGED
|
@@ -337,37 +337,40 @@ function createMakeCjsWrapperAsyncFriendlyPlugin() {
|
|
|
337
337
|
for (const chunk of Object.values(bundle$1)) {
|
|
338
338
|
if (chunk.type !== "chunk") continue;
|
|
339
339
|
let code = chunk.code;
|
|
340
|
-
const
|
|
341
|
-
if (!code.includes(marker))
|
|
342
|
-
let pos = 0;
|
|
340
|
+
const wrapperMarkers = ["__commonJS({", "__commonJSMin("];
|
|
341
|
+
if (!wrapperMarkers.some((marker) => code.includes(marker))) continue;
|
|
343
342
|
const arrowToken = "(() => {";
|
|
344
343
|
const asyncArrowToken = "(async () => {";
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
344
|
+
const patchMarker = (marker) => {
|
|
345
|
+
let pos = 0;
|
|
346
|
+
while (true) {
|
|
347
|
+
const markerIdx = code.indexOf(marker, pos);
|
|
348
|
+
if (markerIdx === -1) break;
|
|
349
|
+
const fnStart = code.indexOf(arrowToken, markerIdx);
|
|
350
|
+
if (fnStart === -1) {
|
|
351
|
+
pos = markerIdx + marker.length;
|
|
352
|
+
continue;
|
|
353
|
+
}
|
|
354
|
+
const bodyStart = fnStart + 8;
|
|
355
|
+
let i = bodyStart;
|
|
356
|
+
let depth = 1;
|
|
357
|
+
while (i < code.length && depth > 0) {
|
|
358
|
+
const ch = code[i++];
|
|
359
|
+
if (ch === "{") depth++;
|
|
360
|
+
else if (ch === "}") depth--;
|
|
361
|
+
}
|
|
362
|
+
if (depth !== 0) break;
|
|
363
|
+
const bodyEnd = i - 1;
|
|
364
|
+
const body = code.slice(bodyStart, bodyEnd);
|
|
365
|
+
if (/\bawait\b/.test(body) && code.slice(fnStart, fnStart + 14) !== asyncArrowToken) {
|
|
366
|
+
code = `${code.slice(0, fnStart + 1)}async ${code.slice(fnStart + 1)}`;
|
|
367
|
+
pos = fnStart + 1 + 6;
|
|
368
|
+
continue;
|
|
369
|
+
}
|
|
370
|
+
pos = bodyEnd;
|
|
352
371
|
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
let depth = 1;
|
|
356
|
-
while (i < code.length && depth > 0) {
|
|
357
|
-
const ch = code[i++];
|
|
358
|
-
if (ch === "{") depth++;
|
|
359
|
-
else if (ch === "}") depth--;
|
|
360
|
-
}
|
|
361
|
-
if (depth !== 0) break;
|
|
362
|
-
const bodyEnd = i - 1;
|
|
363
|
-
const body = code.slice(bodyStart, bodyEnd);
|
|
364
|
-
if (/\bawait\b/.test(body) && code.slice(fnStart, fnStart + 14) !== asyncArrowToken) {
|
|
365
|
-
code = `${code.slice(0, fnStart + 1)}async ${code.slice(fnStart + 1)}`;
|
|
366
|
-
pos = fnStart + 1 + 6;
|
|
367
|
-
continue;
|
|
368
|
-
}
|
|
369
|
-
pos = bodyEnd;
|
|
370
|
-
}
|
|
372
|
+
};
|
|
373
|
+
for (const marker of wrapperMarkers) patchMarker(marker);
|
|
371
374
|
if (code !== chunk.code) chunk.code = code;
|
|
372
375
|
}
|
|
373
376
|
} }
|
package/dist/sync/worker.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "unrun",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.12",
|
|
4
4
|
"description": "A tool to load and execute any JavaScript or TypeScript code at runtime.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
}
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@oxc-project/runtime": "^0.
|
|
43
|
-
"rolldown": "1.0.0-beta.
|
|
42
|
+
"@oxc-project/runtime": "^0.99.0",
|
|
43
|
+
"rolldown": "1.0.0-beta.52"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@sxzz/eslint-config": "^7.3.
|
|
46
|
+
"@sxzz/eslint-config": "^7.3.2",
|
|
47
47
|
"@sxzz/prettier-config": "^2.2.5",
|
|
48
48
|
"@types/node": "^24.10.1",
|
|
49
49
|
"acorn": "^8.15.0",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"jiti": "^2.6.1",
|
|
64
64
|
"mime": "^4.1.0",
|
|
65
65
|
"moment-timezone": "^0.6.0",
|
|
66
|
-
"nano-jsx": "^0.2.
|
|
66
|
+
"nano-jsx": "^0.2.1",
|
|
67
67
|
"preact": "^10.27.2",
|
|
68
68
|
"preact-render-to-string": "^6.6.3",
|
|
69
69
|
"prettier": "^3.6.2",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"synckit": "^0.11.11",
|
|
74
74
|
"test-ecosystem-ci": "^0.0.1",
|
|
75
75
|
"tinyexec": "^1.0.2",
|
|
76
|
-
"tsdown": "^0.16.
|
|
76
|
+
"tsdown": "^0.16.7",
|
|
77
77
|
"tsx": "^4.20.6",
|
|
78
78
|
"typedoc": "^0.28.14",
|
|
79
79
|
"typedoc-plugin-markdown": "^4.9.0",
|
|
@@ -81,13 +81,13 @@
|
|
|
81
81
|
"typescript": "^5.9.3",
|
|
82
82
|
"unconfig": "^7.4.1",
|
|
83
83
|
"unplugin-vue": "^7.0.8",
|
|
84
|
-
"vite": "^7.2.
|
|
84
|
+
"vite": "^7.2.4",
|
|
85
85
|
"vitepress": "2.0.0-alpha.12",
|
|
86
86
|
"vitepress-plugin-group-icons": "^1.6.5",
|
|
87
87
|
"vitest": "4.0.8",
|
|
88
|
-
"vue": "^3.5.
|
|
89
|
-
"vue-tsc": "^3.1.
|
|
90
|
-
"zod": "^4.1.
|
|
88
|
+
"vue": "^3.5.25",
|
|
89
|
+
"vue-tsc": "^3.1.5",
|
|
90
|
+
"zod": "^4.1.13"
|
|
91
91
|
},
|
|
92
92
|
"engines": {
|
|
93
93
|
"node": ">=20.19.0"
|