@pithy-sh/vite 0.1.4 → 0.1.5
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/clientEnvDeclaration.d.ts +2 -0
- package/dist/clientEnvDeclaration.js +2 -0
- package/dist/devOrigin.d.ts +2 -0
- package/dist/devOrigin.js +2 -0
- package/dist/plugin.d.ts +2 -0
- package/dist/plugin.js +2 -0
- package/dist/testPlugin.d.ts +2 -0
- package/dist/testPlugin.js +2 -0
- package/dist/virtualModule.d.ts +2 -0
- package/dist/virtualModule.js +2 -0
- package/dist/workerConfig.d.ts +13 -1
- package/dist/workerConfig.d.ts.map +1 -1
- package/dist/workerConfig.js +20 -3
- package/package.json +3 -3
- package/src/workerConfig.ts +24 -4
package/dist/devOrigin.d.ts
CHANGED
package/dist/devOrigin.js
CHANGED
package/dist/plugin.d.ts
CHANGED
package/dist/plugin.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
1
3
|
import { capabilityNameFromResolvedId, isResolvedVirtualId, renderVirtualModule, resolveVirtualId } from "./virtualModule.js";
|
|
2
4
|
import { loadWorkerConfig } from "./workerConfig.js";
|
|
3
5
|
import { resolve } from "node:path";
|
package/dist/testPlugin.d.ts
CHANGED
package/dist/testPlugin.js
CHANGED
package/dist/virtualModule.d.ts
CHANGED
package/dist/virtualModule.js
CHANGED
package/dist/workerConfig.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
1
3
|
import type { Capability } from "@pithy-sh/core/src/capability/capability";
|
|
2
4
|
/** One Worker's composed capabilities, indexed by name, plus the files the config was built from. */
|
|
3
5
|
export interface LoadedWorkerConfig {
|
|
@@ -43,7 +45,17 @@ export interface WorkerConfigFailure {
|
|
|
43
45
|
/** The remedy, chosen from the kind. Carries no absolute path, no source line, no stack. */
|
|
44
46
|
action: string;
|
|
45
47
|
}
|
|
46
|
-
/**
|
|
48
|
+
/**
|
|
49
|
+
* Choose the refusal's `action` **from** the failure rather than asserting one over it (#217).
|
|
50
|
+
*
|
|
51
|
+
* An unresolved import names its **importer** alongside its specifier when the runtime gave one (#480,
|
|
52
|
+
* #489). A specifier alone is honest and can still send the reader to the wrong package, because the
|
|
53
|
+
* import that failed is often not the config's own: `pithy add email` refused with *nothing resolves
|
|
54
|
+
* `@pithy-sh/core/src/capability/capability`* while core resolved from the Worker throughout, because
|
|
55
|
+
* the failing import was `@pithy-sh/email`'s. The importer is the half that pointed at `email`, and
|
|
56
|
+
* `importingPackage` is where core records that both runtimes hand it over. **It asserts nothing about
|
|
57
|
+
* which package is absent** — nothing here can know that — only where the import is written.
|
|
58
|
+
*/
|
|
47
59
|
export declare function classifyWorkerConfigFailure(wrapped: unknown): WorkerConfigFailure;
|
|
48
60
|
/**
|
|
49
61
|
* Load a Worker's `pithy.config.ts` and index the capabilities it composes.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"workerConfig.d.ts","sourceRoot":"","sources":["../src/workerConfig.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;
|
|
1
|
+
{"version":3,"file":"workerConfig.d.ts","sourceRoot":"","sources":["../src/workerConfig.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAmB3E,qGAAqG;AACrG,MAAM,WAAW,kBAAkB;IACjC,gGAAgG;IAChG,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACtC,oGAAoG;IACpG,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;CACjC;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,uBAAuB;AACjC,yFAAyF;AACvF,mBAAmB;AACrB,0GAA0G;GACxG,aAAa;AACf,iFAAiF;GAC/E,eAAe;AACjB,oGAAoG;GAClG,SAAS,CAAC;AAEd,2DAA2D;AAC3D,MAAM,WAAW,mBAAmB;IAClC,iFAAiF;IACjF,IAAI,EAAE,uBAAuB,CAAC;IAC9B,4FAA4F;IAC5F,MAAM,EAAE,MAAM,CAAC;CAChB;AA4CD;;;;;;;;;;GAUG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,EAAE,OAAO,GAAG,mBAAmB,CA8CjF;AAMD;;;;;;;;GAQG;AACH,wBAAsB,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAkDtF"}
|
package/dist/workerConfig.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
1
3
|
import { access } from "node:fs/promises";
|
|
2
4
|
import { runnerImport } from "vite";
|
|
3
|
-
import { causeMessage, failurePosition, isBuildFailureWrapper, prop, rootCause, safeReason, unresolvedSpecifier } from "@pithy-sh/core/src/error/cause";
|
|
5
|
+
import { causeMessage, failurePosition, importingPackage, isBuildFailureWrapper, prop, rootCause, safeReason, unresolvedSpecifier } from "@pithy-sh/core/src/error/cause";
|
|
4
6
|
import { InternalError, NotFoundError } from "@pithy-sh/core/src/error/pithyError";
|
|
5
7
|
//#region src/workerConfig.ts
|
|
6
8
|
/**
|
|
@@ -28,14 +30,29 @@ function isParseError(cause) {
|
|
|
28
30
|
if (isBuildFailureWrapper(cause)) return true;
|
|
29
31
|
return /Transform failed|\[PARSE_ERROR]|Parse (?:error|failure)|Unexpected (?:token|end of input)/.test(rawMessage(cause));
|
|
30
32
|
}
|
|
31
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Choose the refusal's `action` **from** the failure rather than asserting one over it (#217).
|
|
35
|
+
*
|
|
36
|
+
* An unresolved import names its **importer** alongside its specifier when the runtime gave one (#480,
|
|
37
|
+
* #489). A specifier alone is honest and can still send the reader to the wrong package, because the
|
|
38
|
+
* import that failed is often not the config's own: `pithy add email` refused with *nothing resolves
|
|
39
|
+
* `@pithy-sh/core/src/capability/capability`* while core resolved from the Worker throughout, because
|
|
40
|
+
* the failing import was `@pithy-sh/email`'s. The importer is the half that pointed at `email`, and
|
|
41
|
+
* `importingPackage` is where core records that both runtimes hand it over. **It asserts nothing about
|
|
42
|
+
* which package is absent** — nothing here can know that — only where the import is written.
|
|
43
|
+
*/
|
|
32
44
|
function classifyWorkerConfigFailure(wrapped) {
|
|
33
45
|
const cause = rootCause(wrapped);
|
|
34
46
|
if (isUnresolvedImport(cause)) {
|
|
35
47
|
const specifier = unresolvedSpecifier(cause);
|
|
48
|
+
const importer = importingPackage(cause);
|
|
49
|
+
if (specifier === void 0) return {
|
|
50
|
+
kind: "unresolved-import",
|
|
51
|
+
action: "An import in the config does not resolve. Install the project's dependencies (bun install), then check its imports."
|
|
52
|
+
};
|
|
36
53
|
return {
|
|
37
54
|
kind: "unresolved-import",
|
|
38
|
-
action:
|
|
55
|
+
action: importer ? `Nothing resolves "${specifier}". ${importer} is what imports it, not the config. Install the project's dependencies (bun install).` : `Nothing resolves "${specifier}". Install the project's dependencies (bun install), or correct that import.`
|
|
39
56
|
};
|
|
40
57
|
}
|
|
41
58
|
if (isParseError(cause)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pithy-sh/vite",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
27
|
"generate": "bun scripts/generateClientEnv.ts",
|
|
28
|
-
"build": "bun run generate && tsdown && tsc -p tsconfig.build.json",
|
|
28
|
+
"build": "bun run generate && tsdown && tsc -p tsconfig.build.json && bun ../../tooling/build/src/stampDeclarations.ts",
|
|
29
29
|
"typecheck": "tsc -p tsconfig.json",
|
|
30
30
|
"test": "vitest run",
|
|
31
31
|
"test:node": "vitest run --project=node",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"vite": "^6.1.0 || ^7.0.0 || ^8.0.0"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@pithy-sh/core": "^0.1.
|
|
39
|
+
"@pithy-sh/core": "^0.1.5"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@pithy-sh/auth": "workspace:*",
|
package/src/workerConfig.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type { Capability } from "@pithy-sh/core/src/capability/capability";
|
|
|
6
6
|
import {
|
|
7
7
|
causeMessage,
|
|
8
8
|
failurePosition,
|
|
9
|
+
importingPackage,
|
|
9
10
|
isBuildFailureWrapper,
|
|
10
11
|
prop,
|
|
11
12
|
rootCause,
|
|
@@ -109,17 +110,36 @@ function isParseError(cause: unknown): boolean {
|
|
|
109
110
|
);
|
|
110
111
|
}
|
|
111
112
|
|
|
112
|
-
/**
|
|
113
|
+
/**
|
|
114
|
+
* Choose the refusal's `action` **from** the failure rather than asserting one over it (#217).
|
|
115
|
+
*
|
|
116
|
+
* An unresolved import names its **importer** alongside its specifier when the runtime gave one (#480,
|
|
117
|
+
* #489). A specifier alone is honest and can still send the reader to the wrong package, because the
|
|
118
|
+
* import that failed is often not the config's own: `pithy add email` refused with *nothing resolves
|
|
119
|
+
* `@pithy-sh/core/src/capability/capability`* while core resolved from the Worker throughout, because
|
|
120
|
+
* the failing import was `@pithy-sh/email`'s. The importer is the half that pointed at `email`, and
|
|
121
|
+
* `importingPackage` is where core records that both runtimes hand it over. **It asserts nothing about
|
|
122
|
+
* which package is absent** — nothing here can know that — only where the import is written.
|
|
123
|
+
*/
|
|
113
124
|
export function classifyWorkerConfigFailure(wrapped: unknown): WorkerConfigFailure {
|
|
114
125
|
// Bun hands `import()` failures over inside an `AggregateError`. Classify what is inside it.
|
|
115
126
|
const cause = rootCause(wrapped);
|
|
116
127
|
if (isUnresolvedImport(cause)) {
|
|
117
128
|
const specifier = unresolvedSpecifier(cause);
|
|
129
|
+
// A package name or nothing — core never hands a path back, so there is none to keep out of here.
|
|
130
|
+
const importer = importingPackage(cause);
|
|
131
|
+
if (specifier === undefined) {
|
|
132
|
+
return {
|
|
133
|
+
kind: "unresolved-import",
|
|
134
|
+
action:
|
|
135
|
+
"An import in the config does not resolve. Install the project's dependencies (bun install), then check its imports.",
|
|
136
|
+
};
|
|
137
|
+
}
|
|
118
138
|
return {
|
|
119
139
|
kind: "unresolved-import",
|
|
120
|
-
action:
|
|
121
|
-
? `Nothing resolves "${specifier}". Install the project's dependencies (bun install)
|
|
122
|
-
:
|
|
140
|
+
action: importer
|
|
141
|
+
? `Nothing resolves "${specifier}". ${importer} is what imports it, not the config. Install the project's dependencies (bun install).`
|
|
142
|
+
: `Nothing resolves "${specifier}". Install the project's dependencies (bun install), or correct that import.`,
|
|
123
143
|
};
|
|
124
144
|
}
|
|
125
145
|
|