@prosopo/config 3.3.17 → 3.4.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.
@@ -18,6 +18,7 @@ import os from "node:os";
18
18
  import path from "node:path";
19
19
  import type { Rollup, UserConfig } from "vite";
20
20
  import { afterEach, beforeEach, describe, expect, it } from "vitest";
21
+ import { copyAssetsPlugin } from "./CopyAssetsPlugin.js";
21
22
  import { nodejsPolarsNativeFilePlugin } from "./NodejsPolarsNativeFilePlugin.js";
22
23
  import VitePluginCloseAndCopy from "./vite-plugin-close-and-copy.js";
23
24
  import ViteCommonJSConfig from "./vite.commonjs.config.js";
@@ -327,6 +328,50 @@ describe("nodejsPolarsNativeFilePlugin", () => {
327
328
  });
328
329
  });
329
330
 
331
+ describe("copyAssetsPlugin", () => {
332
+ it("copies each asset under its declared basename", () => {
333
+ const src = path.join(root, "decodePayload.js");
334
+ const outDir = path.join(root, "nested", "dist");
335
+ fs.writeFileSync(src, "export default 1;");
336
+
337
+ copyAssetsPlugin(
338
+ [{ src, dest: "decodePayload.js" }],
339
+ outDir,
340
+ ).generateBundle();
341
+
342
+ expect(fs.readFileSync(path.join(outDir, "decodePayload.js"), "utf8")).toBe(
343
+ "export default 1;",
344
+ );
345
+ });
346
+
347
+ it("renames on copy when dest differs from the source basename", () => {
348
+ const src = path.join(root, "a.js");
349
+ const outDir = path.join(root, "dist");
350
+ fs.writeFileSync(src, "x");
351
+
352
+ copyAssetsPlugin([{ src, dest: "b.js" }], outDir).generateBundle();
353
+
354
+ expect(fs.existsSync(path.join(outDir, "b.js"))).toBe(true);
355
+ expect(fs.existsSync(path.join(outDir, "a.js"))).toBe(false);
356
+ });
357
+
358
+ it("throws when a declared asset is missing", () => {
359
+ // Skipping silently would ship a bundle whose decoders resolve to
360
+ // nothing, and the first request would be the one to find out.
361
+ const plugin = copyAssetsPlugin(
362
+ [{ src: path.join(root, "absent.js"), dest: "absent.js" }],
363
+ path.join(root, "dist"),
364
+ );
365
+ expect(() => plugin.generateBundle()).toThrow();
366
+ });
367
+
368
+ it("does nothing at all when there are no assets", () => {
369
+ expect(() =>
370
+ copyAssetsPlugin([], path.join(root, "dist")).generateBundle(),
371
+ ).not.toThrow();
372
+ });
373
+ });
374
+
330
375
  describe("VitePluginCloseAndCopy", () => {
331
376
  it("is a no-op at close time when no copy options are given", () => {
332
377
  const plugin = VitePluginCloseAndCopy();
package/src/vite/index.ts CHANGED
@@ -25,4 +25,6 @@ export { default as VitePluginRemoveUnusedTranslations } from "./vite-plugin-rem
25
25
  export * from "./TsNoCheckPlugin.js";
26
26
  export { default as VitePluginCopy } from "./vite-plugin-copy.js";
27
27
  export { default as VitePluginModifyExportsFiles } from "./vite-plugin-modify-exports-files.js";
28
+ export { copyAssetsPlugin } from "./CopyAssetsPlugin.js";
29
+ export type { CopyAssetEntry } from "./CopyAssetsPlugin.js";
28
30
  export { nodejsPolarsNativeFilePlugin } from "./NodejsPolarsNativeFilePlugin.js";
@@ -81,6 +81,12 @@ export default async function (
81
81
  "process.env.PROSOPO_PROVIDER_URL_DEVELOPMENT": JSON.stringify(
82
82
  process.env.PROSOPO_PROVIDER_URL_DEVELOPMENT,
83
83
  ),
84
+ // Points a self-hosted build at its own providers regardless of
85
+ // environment, so a production bundle no longer has to masquerade as a
86
+ // development build to be redirected.
87
+ "process.env.PROSOPO_PROVIDER_LIST": JSON.stringify(
88
+ process.env.PROSOPO_PROVIDER_LIST,
89
+ ),
84
90
  "process.env._DEV_ONLY_WATCH_EVENTS": JSON.stringify(
85
91
  process.env._DEV_ONLY_WATCH_EVENTS,
86
92
  ),