@prosopo/config 3.3.15 → 3.3.17
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/.turbo/turbo-build$colon$cjs.log +3 -3
- package/.turbo/turbo-build$colon$tsc.log +4 -4
- package/.turbo/turbo-build.log +5 -5
- package/CHANGELOG.md +23 -0
- package/dist/cjs/vite/TsNoCheckPlugin.cjs +1 -1
- package/dist/cjs/vite/vite.frontend.config.cjs +1 -0
- package/dist/vite/NodejsPolarsDirnamePlugin.d.ts +2 -1
- package/dist/vite/NodejsPolarsDirnamePlugin.d.ts.map +1 -1
- package/dist/vite/NodejsPolarsDirnamePlugin.js.map +1 -1
- package/dist/vite/NodejsPolarsNativeFilePlugin.d.ts +3 -2
- package/dist/vite/NodejsPolarsNativeFilePlugin.d.ts.map +1 -1
- package/dist/vite/NodejsPolarsNativeFilePlugin.js.map +1 -1
- package/dist/vite/TsNoCheckPlugin.d.ts +2 -1
- package/dist/vite/TsNoCheckPlugin.d.ts.map +1 -1
- package/dist/vite/TsNoCheckPlugin.js +1 -1
- package/dist/vite/TsNoCheckPlugin.js.map +1 -1
- package/dist/vite/bundleConfigs.test.js +11 -6
- package/dist/vite/bundleConfigs.test.js.map +1 -1
- package/dist/vite/configs.test.js +7 -3
- package/dist/vite/configs.test.js.map +1 -1
- package/dist/vite/plugins.test.js +12 -5
- package/dist/vite/plugins.test.js.map +1 -1
- package/dist/vite/vite.frontend.config.d.ts.map +1 -1
- package/dist/vite/vite.frontend.config.js +1 -0
- package/dist/vite/vite.frontend.config.js.map +1 -1
- package/package.json +6 -6
- package/src/vite/NodejsPolarsDirnamePlugin.ts +7 -2
- package/src/vite/NodejsPolarsNativeFilePlugin.ts +10 -4
- package/src/vite/TsNoCheckPlugin.ts +7 -3
- package/src/vite/bundleConfigs.test.ts +17 -6
- package/src/vite/configs.test.ts +11 -3
- package/src/vite/plugins.test.ts +24 -7
- package/src/vite/vite.frontend.config.ts +6 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
import fs from "node:fs";
|
|
16
16
|
import path from "node:path";
|
|
17
|
+
import type { Rollup } from "vite";
|
|
17
18
|
|
|
18
19
|
/**
|
|
19
20
|
* Each entry is either a plain path (copied under its original basename) or
|
|
@@ -37,8 +38,11 @@ export const nodejsPolarsNativeFilePlugin = (
|
|
|
37
38
|
const name = "nodejs-polars-native-file-plugin";
|
|
38
39
|
return {
|
|
39
40
|
name,
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
resolveId(
|
|
42
|
+
source: string,
|
|
43
|
+
importer: string | undefined,
|
|
44
|
+
options: Rollup.ResolveIdExtraOptions,
|
|
45
|
+
) {
|
|
42
46
|
// return the id if this plugin can resolve the import
|
|
43
47
|
for (const entry of nodeFiles) {
|
|
44
48
|
if (path.basename(source) === path.basename(entrySrc(entry))) {
|
|
@@ -83,8 +87,10 @@ export const nodejsPolarsNativeFilePlugin = (
|
|
|
83
87
|
}
|
|
84
88
|
return null;
|
|
85
89
|
},
|
|
86
|
-
|
|
87
|
-
|
|
90
|
+
generateBundle(
|
|
91
|
+
options: Rollup.NormalizedOutputOptions,
|
|
92
|
+
bundle: Rollup.OutputBundle,
|
|
93
|
+
) {
|
|
88
94
|
for (const entry of nodeFiles) {
|
|
89
95
|
const src = entrySrc(entry);
|
|
90
96
|
const destBasename = entryDestBasename(entry);
|
|
@@ -11,14 +11,18 @@
|
|
|
11
11
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
// See the License for the specific language governing permissions and
|
|
13
13
|
// limitations under the License.
|
|
14
|
+
import type { Rollup } from "vite";
|
|
15
|
+
|
|
14
16
|
export function tsNoCheckPlugin() {
|
|
15
17
|
return {
|
|
16
18
|
name: "vite-plugin-ts-nocheck",
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
generateBundle(
|
|
20
|
+
_: Rollup.NormalizedOutputOptions,
|
|
21
|
+
bundle: Rollup.OutputBundle,
|
|
22
|
+
) {
|
|
19
23
|
for (const fileName in bundle) {
|
|
20
24
|
const chunk = bundle[fileName];
|
|
21
|
-
if (chunk
|
|
25
|
+
if (chunk?.type === "chunk" && chunk.code) {
|
|
22
26
|
chunk.code = `// @ts-nocheck\n${chunk.code}`;
|
|
23
27
|
}
|
|
24
28
|
}
|
|
@@ -36,6 +36,12 @@ afterEach(() => {
|
|
|
36
36
|
fs.rmSync(root, { recursive: true, force: true });
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
+
const resolveOptions: Rollup.ResolveIdExtraOptions = {
|
|
40
|
+
isEntry: false,
|
|
41
|
+
kind: "import-statement",
|
|
42
|
+
};
|
|
43
|
+
const outputOptions = {} as Rollup.NormalizedOutputOptions;
|
|
44
|
+
|
|
39
45
|
/** A tsconfig with no references, so no npm lookups are needed. */
|
|
40
46
|
const leafTsConfig = (): string => {
|
|
41
47
|
const dir = path.join(root, "pkg");
|
|
@@ -260,10 +266,12 @@ describe("ViteCommonJSConfig", () => {
|
|
|
260
266
|
describe("nodejsPolarsNativeFilePlugin", () => {
|
|
261
267
|
it("claims a native file by basename, wherever it is imported from", () => {
|
|
262
268
|
const plugin = nodejsPolarsNativeFilePlugin(["/abs/polars.node"], "dist");
|
|
263
|
-
expect(plugin.resolveId("./polars.node", "/src/a.ts",
|
|
269
|
+
expect(plugin.resolveId("./polars.node", "/src/a.ts", resolveOptions)).toBe(
|
|
264
270
|
"./polars.node",
|
|
265
271
|
);
|
|
266
|
-
expect(
|
|
272
|
+
expect(
|
|
273
|
+
plugin.resolveId("./other.node", "/src/a.ts", resolveOptions),
|
|
274
|
+
).toBeNull();
|
|
267
275
|
});
|
|
268
276
|
|
|
269
277
|
it("replaces the module with a createRequire shim", () => {
|
|
@@ -293,7 +301,10 @@ describe("nodejsPolarsNativeFilePlugin", () => {
|
|
|
293
301
|
const bytes = Buffer.from([0, 1, 2, 255]);
|
|
294
302
|
fs.writeFileSync(src, bytes);
|
|
295
303
|
|
|
296
|
-
nodejsPolarsNativeFilePlugin([src], outDir).generateBundle(
|
|
304
|
+
nodejsPolarsNativeFilePlugin([src], outDir).generateBundle(
|
|
305
|
+
outputOptions,
|
|
306
|
+
{},
|
|
307
|
+
);
|
|
297
308
|
|
|
298
309
|
expect(fs.readFileSync(path.join(outDir, "polars.node"))).toEqual(bytes);
|
|
299
310
|
});
|
|
@@ -305,14 +316,14 @@ describe("nodejsPolarsNativeFilePlugin", () => {
|
|
|
305
316
|
[path.join(root, "absent.node")],
|
|
306
317
|
path.join(root, "dist"),
|
|
307
318
|
);
|
|
308
|
-
expect(() => plugin.generateBundle(
|
|
319
|
+
expect(() => plugin.generateBundle(outputOptions, {})).toThrow();
|
|
309
320
|
});
|
|
310
321
|
|
|
311
322
|
it("does nothing at all when there are no native files", () => {
|
|
312
323
|
const plugin = nodejsPolarsNativeFilePlugin([], "dist");
|
|
313
|
-
expect(plugin.resolveId("anything", undefined,
|
|
324
|
+
expect(plugin.resolveId("anything", undefined, resolveOptions)).toBeNull();
|
|
314
325
|
expect(plugin.load("anything")).toBeNull();
|
|
315
|
-
expect(() => plugin.generateBundle(
|
|
326
|
+
expect(() => plugin.generateBundle(outputOptions, {})).not.toThrow();
|
|
316
327
|
});
|
|
317
328
|
});
|
|
318
329
|
|
package/src/vite/configs.test.ts
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
import fs from "node:fs";
|
|
16
16
|
import os from "node:os";
|
|
17
17
|
import path from "node:path";
|
|
18
|
+
import type { Rollup } from "vite";
|
|
18
19
|
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
19
20
|
import { nodejsPolarsDirnamePlugin } from "./NodejsPolarsDirnamePlugin.js";
|
|
20
21
|
import ViteTestConfig from "./vite.test.config.js";
|
|
@@ -22,6 +23,11 @@ import ViteThreadsTestConfig from "./vite.threads.test.config.js";
|
|
|
22
23
|
|
|
23
24
|
const NATIVE_POLARS = "/repo/node_modules/nodejs-polars/bin/native-polars.js";
|
|
24
25
|
|
|
26
|
+
const resolveOptions: Rollup.ResolveIdExtraOptions = {
|
|
27
|
+
isEntry: false,
|
|
28
|
+
kind: "import-statement",
|
|
29
|
+
};
|
|
30
|
+
|
|
25
31
|
let root: string;
|
|
26
32
|
let cwd: string;
|
|
27
33
|
let originalTestType: string | undefined;
|
|
@@ -179,10 +185,12 @@ describe("nodejsPolarsDirnamePlugin", () => {
|
|
|
179
185
|
const plugin = nodejsPolarsDirnamePlugin();
|
|
180
186
|
|
|
181
187
|
it("claims only the native polars entry point", () => {
|
|
182
|
-
expect(plugin.resolveId(NATIVE_POLARS, undefined,
|
|
183
|
-
|
|
188
|
+
expect(plugin.resolveId(NATIVE_POLARS, undefined, resolveOptions)).toBe(
|
|
189
|
+
NATIVE_POLARS,
|
|
190
|
+
);
|
|
191
|
+
expect(plugin.resolveId("zod", undefined, resolveOptions)).toBeNull();
|
|
184
192
|
expect(
|
|
185
|
-
plugin.resolveId("nodejs-polars/bin/other.js", undefined,
|
|
193
|
+
plugin.resolveId("nodejs-polars/bin/other.js", undefined, resolveOptions),
|
|
186
194
|
).toBeNull();
|
|
187
195
|
});
|
|
188
196
|
|
package/src/vite/plugins.test.ts
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
import fs from "node:fs";
|
|
16
16
|
import os from "node:os";
|
|
17
17
|
import path from "node:path";
|
|
18
|
+
import type { Rollup } from "vite";
|
|
18
19
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
19
20
|
import { tsNoCheckPlugin } from "./TsNoCheckPlugin.js";
|
|
20
21
|
import VitePluginCopy from "./vite-plugin-copy.js";
|
|
@@ -132,14 +133,25 @@ describe("VitePluginFixAbsoluteImports", () => {
|
|
|
132
133
|
});
|
|
133
134
|
|
|
134
135
|
describe("tsNoCheckPlugin", () => {
|
|
136
|
+
const outputOptions = {} as Rollup.NormalizedOutputOptions;
|
|
137
|
+
|
|
135
138
|
it("prefixes every emitted chunk with a ts-nocheck pragma", () => {
|
|
136
139
|
// Consumers typecheck the bundled output; without this the generated
|
|
137
140
|
// code fails their build.
|
|
138
141
|
const bundle = {
|
|
139
|
-
"index.js": {
|
|
140
|
-
|
|
142
|
+
"index.js": {
|
|
143
|
+
type: "chunk",
|
|
144
|
+
code: "export const a = 1;",
|
|
145
|
+
} as Rollup.OutputChunk,
|
|
146
|
+
"other.js": {
|
|
147
|
+
type: "chunk",
|
|
148
|
+
code: "export const b = 2;",
|
|
149
|
+
} as Rollup.OutputChunk,
|
|
141
150
|
};
|
|
142
|
-
tsNoCheckPlugin().generateBundle(
|
|
151
|
+
tsNoCheckPlugin().generateBundle(
|
|
152
|
+
outputOptions,
|
|
153
|
+
bundle as Rollup.OutputBundle,
|
|
154
|
+
);
|
|
143
155
|
|
|
144
156
|
expect(bundle["index.js"].code).toBe("// @ts-nocheck\nexport const a = 1;");
|
|
145
157
|
expect(bundle["other.js"].code).toBe("// @ts-nocheck\nexport const b = 2;");
|
|
@@ -147,17 +159,22 @@ describe("tsNoCheckPlugin", () => {
|
|
|
147
159
|
|
|
148
160
|
it("leaves assets and empty chunks alone", () => {
|
|
149
161
|
const bundle = {
|
|
150
|
-
"style.css": { type: "asset", source: "body{}" },
|
|
151
|
-
"empty.js": { type: "chunk", code: "" },
|
|
162
|
+
"style.css": { type: "asset", source: "body{}" } as Rollup.OutputAsset,
|
|
163
|
+
"empty.js": { type: "chunk", code: "" } as Rollup.OutputChunk,
|
|
152
164
|
};
|
|
153
|
-
tsNoCheckPlugin().generateBundle(
|
|
165
|
+
tsNoCheckPlugin().generateBundle(
|
|
166
|
+
outputOptions,
|
|
167
|
+
bundle as Rollup.OutputBundle,
|
|
168
|
+
);
|
|
154
169
|
|
|
155
170
|
expect(bundle["style.css"]).toEqual({ type: "asset", source: "body{}" });
|
|
156
171
|
expect(bundle["empty.js"].code).toBe("");
|
|
157
172
|
});
|
|
158
173
|
|
|
159
174
|
it("handles an empty bundle", () => {
|
|
160
|
-
expect(() =>
|
|
175
|
+
expect(() =>
|
|
176
|
+
tsNoCheckPlugin().generateBundle(outputOptions, {}),
|
|
177
|
+
).not.toThrow();
|
|
161
178
|
});
|
|
162
179
|
|
|
163
180
|
it("is named", () => {
|
|
@@ -75,6 +75,12 @@ export default async function (
|
|
|
75
75
|
"process.env.PROSOPO_SERVER_URL": JSON.stringify(
|
|
76
76
|
process.env.PROSOPO_SERVER_URL,
|
|
77
77
|
),
|
|
78
|
+
// Lets a development widget reach a provider that is not on the machine
|
|
79
|
+
// serving the page — a phone or simulator testing over the LAN would
|
|
80
|
+
// otherwise resolve the default `localhost` to itself.
|
|
81
|
+
"process.env.PROSOPO_PROVIDER_URL_DEVELOPMENT": JSON.stringify(
|
|
82
|
+
process.env.PROSOPO_PROVIDER_URL_DEVELOPMENT,
|
|
83
|
+
),
|
|
78
84
|
"process.env._DEV_ONLY_WATCH_EVENTS": JSON.stringify(
|
|
79
85
|
process.env._DEV_ONLY_WATCH_EVENTS,
|
|
80
86
|
),
|