env-runner 0.2.3 → 0.3.1
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 +370 -20
- package/dist/_chunks/common-base-runner.d.mts +486 -15
- package/dist/_chunks/common-base-runner.mjs +712 -32
- package/dist/_chunks/common-process-data.mjs +13 -0
- package/dist/_chunks/common-worker-utils.mjs +47 -114
- package/dist/_chunks/deno-process-runner.d.mts +4 -1
- package/dist/_chunks/deno-process-runner.mjs +9 -6
- package/dist/_chunks/lexer.mjs +2 -0
- package/dist/_chunks/libs/cjs-module-lexer.mjs +6 -1
- package/dist/_chunks/miniflare-runner.d.mts +26 -14
- package/dist/_chunks/miniflare-runner.mjs +430 -134
- package/dist/_chunks/netlify-runner.d.mts +3 -1
- package/dist/_chunks/node-worker-runner.d.mts +3 -1
- package/dist/_chunks/node-worker-runner.mjs +8 -4
- package/dist/_chunks/plugin-hooks.mjs +1656 -0
- package/dist/_chunks/server.mjs +21 -5
- package/dist/_chunks/types.d.mts +37 -1
- package/dist/_chunks/vercel-runner.d.mts +3 -1
- package/dist/cli.mjs +0 -0
- package/dist/index.d.mts +21 -4
- package/dist/runners/bun-process/runner.d.mts +4 -1
- package/dist/runners/bun-process/runner.mjs +12 -9
- package/dist/runners/bun-process/worker.mjs +12 -11
- package/dist/runners/deno-process/worker.mjs +12 -11
- package/dist/runners/node-process/runner.d.mts +3 -1
- package/dist/runners/node-process/runner.mjs +2 -6
- package/dist/runners/node-process/worker.mjs +12 -11
- package/dist/runners/node-worker/worker.mjs +10 -10
- package/dist/runners/self/runner.d.mts +5 -2
- package/dist/runners/self/runner.mjs +12 -0
- package/package.json +26 -26
- package/dist/_chunks/common-host-env.mjs +0 -11
- package/dist/_chunks/virtual-loader.mjs +0 -71
package/package.json
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "env-runner",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Generic environment runner for JavaScript runtimes.",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"repository":
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "unjs/env-runner"
|
|
9
|
-
},
|
|
6
|
+
"repository": "unjs/env-runner",
|
|
10
7
|
"bin": {
|
|
11
8
|
"env-runner": "./dist/cli.mjs"
|
|
12
9
|
},
|
|
@@ -34,6 +31,17 @@
|
|
|
34
31
|
"./runners/netlify/worker": "./dist/runners/netlify/worker.mjs",
|
|
35
32
|
"./vite": "./dist/vite.mjs"
|
|
36
33
|
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "obuild",
|
|
36
|
+
"dev": "vitest dev",
|
|
37
|
+
"fmt": "automd && oxlint . --fix && oxfmt .",
|
|
38
|
+
"lint": "oxlint . && oxfmt --check .",
|
|
39
|
+
"prepack": "pnpm build",
|
|
40
|
+
"env-runner": "node ./src/cli.ts",
|
|
41
|
+
"release": "pnpm test && pnpm build && changelogen --release && pnpm publish && git push --follow-tags",
|
|
42
|
+
"test": "pnpm lint && pnpm typecheck && vitest run --coverage",
|
|
43
|
+
"typecheck": "tsc --noEmit --skipLibCheck"
|
|
44
|
+
},
|
|
37
45
|
"dependencies": {
|
|
38
46
|
"crossws": "^0.4.12",
|
|
39
47
|
"exsolve": "^1.1.1",
|
|
@@ -41,31 +49,23 @@
|
|
|
41
49
|
"srvx": "^1.0.5"
|
|
42
50
|
},
|
|
43
51
|
"devDependencies": {
|
|
44
|
-
"@netlify/runtime": "^5.0.
|
|
45
|
-
"@types/node": "^26.
|
|
46
|
-
"@vercel/queue": "^0.
|
|
47
|
-
"@vitest/coverage-v8": "^5.0.
|
|
52
|
+
"@netlify/runtime": "^5.0.5",
|
|
53
|
+
"@types/node": "^26.6.2",
|
|
54
|
+
"@vercel/queue": "^0.7.0",
|
|
55
|
+
"@vitest/coverage-v8": "^5.0.1",
|
|
48
56
|
"automd": "^0.4.3",
|
|
49
57
|
"changelogen": "^0.6.2",
|
|
50
58
|
"cjs-module-lexer": "^2.2.1",
|
|
51
59
|
"env-runner-fixture": "link:",
|
|
52
60
|
"es-module-lexer": "^3.0.2",
|
|
53
|
-
"miniflare": "^
|
|
54
|
-
"obuild": "^0.4.
|
|
55
|
-
"
|
|
56
|
-
"
|
|
61
|
+
"miniflare": "^5.20260921.1-alpha",
|
|
62
|
+
"obuild": "^0.4.40",
|
|
63
|
+
"oxc-transform": "^0.151.0",
|
|
64
|
+
"oxfmt": ">=0.70.0",
|
|
65
|
+
"oxlint": "^1.85.0",
|
|
57
66
|
"typescript": "^7.0.2",
|
|
58
|
-
"vitest": "^5.0.
|
|
59
|
-
"wrangler": "^4.
|
|
67
|
+
"vitest": "^5.0.1",
|
|
68
|
+
"wrangler": "^4.140.0"
|
|
60
69
|
},
|
|
61
|
-
"
|
|
62
|
-
|
|
63
|
-
"dev": "vitest dev",
|
|
64
|
-
"fmt": "automd && oxlint . --fix && oxfmt .",
|
|
65
|
-
"lint": "oxlint . && oxfmt --check .",
|
|
66
|
-
"env-runner": "node ./src/cli.ts",
|
|
67
|
-
"release": "pnpm test && pnpm build && changelogen --release && pnpm publish && git push --follow-tags",
|
|
68
|
-
"test": "pnpm lint && pnpm typecheck && vitest run --coverage",
|
|
69
|
-
"typecheck": "tsc --noEmit --skipLibCheck"
|
|
70
|
-
}
|
|
71
|
-
}
|
|
70
|
+
"packageManager": "pnpm@12.6.0"
|
|
71
|
+
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
function hostEnv(extra) {
|
|
2
|
-
const env = {
|
|
3
|
-
...process.env,
|
|
4
|
-
...extra
|
|
5
|
-
};
|
|
6
|
-
const stdout = process.stdout;
|
|
7
|
-
if (!("FORCE_COLOR" in env) && !env.NO_COLOR && stdout?.isTTY) env.FORCE_COLOR = "1";
|
|
8
|
-
if (!("COLUMNS" in env) && stdout?.columns) env.COLUMNS = String(stdout.columns);
|
|
9
|
-
return env;
|
|
10
|
-
}
|
|
11
|
-
export { hostEnv };
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { pathToFileURL } from "node:url";
|
|
2
|
-
async function resolveVirtualModules(virtual) {
|
|
3
|
-
const entries = await Promise.all(Object.entries(virtual).map(async ([key, value]) => [key, typeof value === "function" ? await value() : value]));
|
|
4
|
-
return Object.fromEntries(entries);
|
|
5
|
-
}
|
|
6
|
-
const VIRTUAL_SCHEME = "virtual:";
|
|
7
|
-
function createVirtualHooks(virtual, versions, parentURL = _defaultParentURL(), forcePlainModule = false) {
|
|
8
|
-
const resolve = (specifier, context, nextResolve) => {
|
|
9
|
-
const key = _stripQuery(specifier);
|
|
10
|
-
if (Object.hasOwn(virtual, key)) {
|
|
11
|
-
const version = versions?.get(key);
|
|
12
|
-
return {
|
|
13
|
-
url: VIRTUAL_SCHEME + encodeURIComponent(specifier) + (version ? `?v=${version}` : ""),
|
|
14
|
-
shortCircuit: true
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
if (context.parentURL?.startsWith(VIRTUAL_SCHEME)) return nextResolve(specifier, {
|
|
18
|
-
...context,
|
|
19
|
-
parentURL
|
|
20
|
-
});
|
|
21
|
-
return nextResolve(specifier, context);
|
|
22
|
-
};
|
|
23
|
-
const load = (url, context, nextLoad) => {
|
|
24
|
-
if (url.startsWith(VIRTUAL_SCHEME)) {
|
|
25
|
-
const key = _stripQuery(decodeURIComponent(url.slice(8)));
|
|
26
|
-
if (Object.hasOwn(virtual, key)) return {
|
|
27
|
-
format: forcePlainModule ? "module" : virtualModuleFormat(key),
|
|
28
|
-
source: virtual[key],
|
|
29
|
-
shortCircuit: true
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
return nextLoad(url, context);
|
|
33
|
-
};
|
|
34
|
-
return {
|
|
35
|
-
resolve,
|
|
36
|
-
load
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function virtualModuleFormat(specifier) {
|
|
40
|
-
if (specifier.endsWith(".json")) return "json";
|
|
41
|
-
if (specifier.endsWith(".ts") || specifier.endsWith(".mts")) return "module-typescript";
|
|
42
|
-
return "module";
|
|
43
|
-
}
|
|
44
|
-
function stripVirtualTypeScript(specifier, source, stripTypeScriptTypes, hints) {
|
|
45
|
-
if (typeof stripTypeScriptTypes !== "function") throw new TypeError(`[env-runner] virtual TypeScript module "${specifier}" requires \`module.stripTypeScriptTypes\` ${hints.requirement}; ${hints.remedy} or provide a pre-transpiled JavaScript source instead.`);
|
|
46
|
-
return stripTypeScriptTypes(source);
|
|
47
|
-
}
|
|
48
|
-
function expandVirtualInvalidation(virtual, specifier) {
|
|
49
|
-
const invalidated = [specifier];
|
|
50
|
-
const seen = new Set(invalidated);
|
|
51
|
-
for (const target of invalidated) {
|
|
52
|
-
const refs = [
|
|
53
|
-
`"${target}"`,
|
|
54
|
-
`'${target}'`,
|
|
55
|
-
"`" + target + "`"
|
|
56
|
-
];
|
|
57
|
-
for (const [key, source] of Object.entries(virtual)) if (!seen.has(key) && refs.some((ref) => source.includes(ref))) {
|
|
58
|
-
seen.add(key);
|
|
59
|
-
invalidated.push(key);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return invalidated;
|
|
63
|
-
}
|
|
64
|
-
function _stripQuery(specifier) {
|
|
65
|
-
const qIndex = specifier.indexOf("?");
|
|
66
|
-
return qIndex === -1 ? specifier : specifier.slice(0, qIndex);
|
|
67
|
-
}
|
|
68
|
-
function _defaultParentURL() {
|
|
69
|
-
return pathToFileURL(process.cwd() + "/").href;
|
|
70
|
-
}
|
|
71
|
-
export { createVirtualHooks, expandVirtualInvalidation, resolveVirtualModules, stripVirtualTypeScript, virtualModuleFormat };
|