tempest-react-sdk 0.71.0 → 0.72.0
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/vite/create-vite-config.cjs +1 -1
- package/dist/vite/create-vite-config.cjs.map +1 -1
- package/dist/vite/create-vite-config.js +30 -28
- package/dist/vite/create-vite-config.js.map +1 -1
- package/dist/vite/tempest-vitest.cjs +2 -0
- package/dist/vite/tempest-vitest.cjs.map +1 -0
- package/dist/vite/tempest-vitest.js +12 -0
- package/dist/vite/tempest-vitest.js.map +1 -0
- package/dist/vite.cjs +1 -1
- package/dist/vite.d.ts +40 -1
- package/dist/vite.js +8 -7
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../_virtual/_rolldown/runtime.cjs"),t=require("./tempest-icons.cjs");let
|
|
1
|
+
const e=require("../_virtual/_rolldown/runtime.cjs"),t=require("./tempest-icons.cjs"),n=require("./tempest-vitest.cjs");let r=require("node:path"),i=require("vite"),a=require("@vitejs/plugin-react");a=e.__toESM(a,1);function o(e){let t={};for(let[n,r]of Object.entries(e))t[n]=typeof r==`string`?{target:r,changeOrigin:!0}:r;return t}function s(e={}){let{srcDir:s=`src`,port:c=5173,host:l=`127.0.0.1`,open:u=!1,proxy:d,alias:f={},plugins:p=[],icons:m=!0,overrides:h={}}=e,g=h,_=m?[t.tempestIcons({dir:s,...typeof m==`object`?m:{}})]:[],v={plugins:[(0,a.default)(),..._,n.tempestVitest(),...p],resolve:{alias:{"@":(0,r.resolve)(process.cwd(),s),...f}},server:{port:c,host:l,open:u,...d?{proxy:o(d)}:{}}},y={...v,...g,plugins:[...v.plugins??[],...g.plugins??[]],resolve:{...v.resolve,...g.resolve},server:{...v.server,...g.server}};return(0,i.defineConfig)(y)}exports.createViteConfig=s;
|
|
2
2
|
//# sourceMappingURL=create-vite-config.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-vite-config.cjs","names":[],"sources":["../../src/vite/create-vite-config.ts"],"sourcesContent":["import { resolve } from \"node:path\";\nimport { defineConfig } from \"vite\";\nimport type { ProxyOptions, UserConfig } from \"vite\";\nimport react from \"@vitejs/plugin-react\";\n\nimport { tempestIcons, type TempestIconsOptions } from \"./tempest-icons\";\n\n/**\n * A Vite proxy entry: either a target URL string (expanded to\n * `{ target, changeOrigin: true }`) or a raw Vite `ProxyOptions` object.\n */\nexport type ProxyEntry = string | Record<string, unknown>;\n\nexport interface CreateViteConfigOptions {\n /**\n * Source directory aliased to `@`, relative to the project root.\n * Default: `\"src\"` (so `@/components/Button` → `<root>/src/components/Button`).\n */\n srcDir?: string;\n /** Dev server port. Default: `5173`. */\n port?: number;\n /** Dev server host. Default: `\"127.0.0.1\"`. */\n host?: string | boolean;\n /** Open the browser on `dev` start. Default: `false`. */\n open?: boolean;\n /**\n * Dev proxy table. String values are expanded to\n * `{ target, changeOrigin: true }`; objects are passed through untouched.\n *\n * @example { \"/api\": \"http://127.0.0.1:8000\" }\n */\n proxy?: Record<string, ProxyEntry>;\n /** Extra path aliases merged on top of the default `@` → src alias. */\n alias?: Record<string, string>;\n /** Vite plugins appended after `@vitejs/plugin-react`. */\n plugins?: unknown[];\n /**\n * The `tempestIcons()` plugin, which generates `virtual:tempest-icons` from the\n * icon slugs your source mentions. On by default — it only ever removes\n * requests. Pass `false` to leave it out, or an options object to configure the\n * scan.\n */\n icons?: boolean | TempestIconsOptions;\n /**\n * Arbitrary Vite config (a `UserConfig` object) deep-merged last, for\n * escape-hatch overrides (build target, define, extra `server` keys, …).\n */\n overrides?: Record<string, unknown>;\n}\n\n/**\n * The resulting Vite config object. Typed loosely so the SDK's published\n * declarations stay free of `vite`'s internal types; assign it straight to a\n * `vite.config.ts` default export.\n */\nexport type TempestViteConfig = Record<string, unknown>;\n\nfunction normalizeProxy(proxy: Record<string, ProxyEntry>): Record<string, ProxyOptions> {\n const out: Record<string, ProxyOptions> = {};\n for (const [path, value] of Object.entries(proxy)) {\n out[path] =\n typeof value === \"string\"\n ? { target: value, changeOrigin: true }\n : (value as ProxyOptions);\n }\n return out;\n}\n\n/**\n * Build a Tempest-flavored Vite config for a React app: the `@vitejs/plugin-react`\n * plugin, the `@` → `src` import alias,
|
|
1
|
+
{"version":3,"file":"create-vite-config.cjs","names":[],"sources":["../../src/vite/create-vite-config.ts"],"sourcesContent":["import { resolve } from \"node:path\";\nimport { defineConfig } from \"vite\";\nimport type { ProxyOptions, UserConfig } from \"vite\";\nimport react from \"@vitejs/plugin-react\";\n\nimport { tempestIcons, type TempestIconsOptions } from \"./tempest-icons\";\nimport { tempestVitest } from \"./tempest-vitest\";\n\n/**\n * A Vite proxy entry: either a target URL string (expanded to\n * `{ target, changeOrigin: true }`) or a raw Vite `ProxyOptions` object.\n */\nexport type ProxyEntry = string | Record<string, unknown>;\n\nexport interface CreateViteConfigOptions {\n /**\n * Source directory aliased to `@`, relative to the project root.\n * Default: `\"src\"` (so `@/components/Button` → `<root>/src/components/Button`).\n */\n srcDir?: string;\n /** Dev server port. Default: `5173`. */\n port?: number;\n /** Dev server host. Default: `\"127.0.0.1\"`. */\n host?: string | boolean;\n /** Open the browser on `dev` start. Default: `false`. */\n open?: boolean;\n /**\n * Dev proxy table. String values are expanded to\n * `{ target, changeOrigin: true }`; objects are passed through untouched.\n *\n * @example { \"/api\": \"http://127.0.0.1:8000\" }\n */\n proxy?: Record<string, ProxyEntry>;\n /** Extra path aliases merged on top of the default `@` → src alias. */\n alias?: Record<string, string>;\n /** Vite plugins appended after `@vitejs/plugin-react`. */\n plugins?: unknown[];\n /**\n * The `tempestIcons()` plugin, which generates `virtual:tempest-icons` from the\n * icon slugs your source mentions. On by default — it only ever removes\n * requests. Pass `false` to leave it out, or an options object to configure the\n * scan.\n */\n icons?: boolean | TempestIconsOptions;\n /**\n * Arbitrary Vite config (a `UserConfig` object) deep-merged last, for\n * escape-hatch overrides (build target, define, extra `server` keys, …).\n */\n overrides?: Record<string, unknown>;\n}\n\n/**\n * The resulting Vite config object. Typed loosely so the SDK's published\n * declarations stay free of `vite`'s internal types; assign it straight to a\n * `vite.config.ts` default export.\n */\nexport type TempestViteConfig = Record<string, unknown>;\n\nfunction normalizeProxy(proxy: Record<string, ProxyEntry>): Record<string, ProxyOptions> {\n const out: Record<string, ProxyOptions> = {};\n for (const [path, value] of Object.entries(proxy)) {\n out[path] =\n typeof value === \"string\"\n ? { target: value, changeOrigin: true }\n : (value as ProxyOptions);\n }\n return out;\n}\n\n/**\n * Build a Tempest-flavored Vite config for a React app: the `@vitejs/plugin-react`\n * plugin, the `@` → `src` import alias, sane dev-server defaults and\n * {@link tempestVitest}, which lets a Vitest suite import the SDK — so a\n * consuming app's `vite.config.ts` is a single call instead of repeated\n * boilerplate. Everything is overridable.\n *\n * Import it from the dedicated Node entry point:\n *\n * @example\n * // vite.config.ts\n * import { createViteConfig } from \"tempest-react-sdk/vite\";\n *\n * export default createViteConfig({\n * proxy: { \"/api\": \"http://127.0.0.1:8000\" },\n * });\n */\nexport function createViteConfig(options: CreateViteConfigOptions = {}): TempestViteConfig {\n const {\n srcDir = \"src\",\n port = 5173,\n host = \"127.0.0.1\",\n open = false,\n proxy,\n alias = {},\n plugins = [],\n icons = true,\n overrides = {},\n } = options;\n\n const overridesConfig = overrides as UserConfig;\n const iconsPlugin = icons\n ? [tempestIcons({ dir: srcDir, ...(typeof icons === \"object\" ? icons : {}) })]\n : [];\n\n const base: UserConfig = {\n plugins: [react(), ...iconsPlugin, tempestVitest(), ...plugins] as UserConfig[\"plugins\"],\n resolve: {\n alias: {\n \"@\": resolve(process.cwd(), srcDir),\n ...alias,\n },\n },\n server: {\n port,\n host,\n open,\n ...(proxy ? { proxy: normalizeProxy(proxy) } : {}),\n },\n };\n\n const merged: UserConfig = {\n ...base,\n ...overridesConfig,\n plugins: [...(base.plugins ?? []), ...(overridesConfig.plugins ?? [])],\n resolve: { ...base.resolve, ...overridesConfig.resolve },\n server: { ...base.server, ...overridesConfig.server },\n };\n\n return defineConfig(merged) as TempestViteConfig;\n}\n"],"mappings":"wNA0DA,SAAS,EAAe,EAAiE,CACrF,IAAM,EAAoC,CAAC,EAC3C,IAAK,GAAM,CAAC,EAAM,KAAU,OAAO,QAAQ,CAAK,EAC5C,EAAI,GACA,OAAO,GAAU,SACX,CAAE,OAAQ,EAAO,aAAc,EAAK,EACnC,EAEf,OAAO,CACX,CAmBA,SAAgB,EAAiB,EAAmC,CAAC,EAAsB,CACvF,GAAM,CACF,SAAS,MACT,OAAO,KACP,OAAO,YACP,OAAO,GACP,QACA,QAAQ,CAAC,EACT,UAAU,CAAC,EACX,QAAQ,GACR,YAAY,CAAC,GACb,EAEE,EAAkB,EAClB,EAAc,EACd,CAAC,EAAA,aAAa,CAAE,IAAK,EAAQ,GAAI,OAAO,GAAU,SAAW,EAAQ,CAAC,CAAG,CAAC,CAAC,EAC3E,CAAC,EAED,EAAmB,CACrB,QAAS,EAAC,EAAA,EAAA,QAAA,CAAM,EAAG,GAAG,EAAa,EAAA,cAAc,EAAG,GAAG,CAAO,EAC9D,QAAS,CACL,MAAO,CACH,KAAA,EAAK,EAAA,QAAA,CAAQ,QAAQ,IAAI,EAAG,CAAM,EAClC,GAAG,CACP,CACJ,EACA,OAAQ,CACJ,OACA,OACA,OACA,GAAI,EAAQ,CAAE,MAAO,EAAe,CAAK,CAAE,EAAI,CAAC,CACpD,CACJ,EAEM,EAAqB,CACvB,GAAG,EACH,GAAG,EACH,QAAS,CAAC,GAAI,EAAK,SAAW,CAAC,EAAI,GAAI,EAAgB,SAAW,CAAC,CAAE,EACrE,QAAS,CAAE,GAAG,EAAK,QAAS,GAAG,EAAgB,OAAQ,EACvD,OAAQ,CAAE,GAAG,EAAK,OAAQ,GAAG,EAAgB,MAAO,CACxD,EAEA,OAAA,EAAO,EAAA,aAAA,CAAa,CAAM,CAC9B"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { tempestIcons as e } from "./tempest-icons.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import r from "
|
|
2
|
+
import { tempestVitest as t } from "./tempest-vitest.js";
|
|
3
|
+
import { resolve as n } from "node:path";
|
|
4
|
+
import { defineConfig as r } from "vite";
|
|
5
|
+
import i from "@vitejs/plugin-react";
|
|
5
6
|
//#region src/vite/create-vite-config.ts
|
|
6
|
-
function
|
|
7
|
+
function a(e) {
|
|
7
8
|
let t = {};
|
|
8
9
|
for (let [n, r] of Object.entries(e)) t[n] = typeof r == "string" ? {
|
|
9
10
|
target: r,
|
|
@@ -11,42 +12,43 @@ function i(e) {
|
|
|
11
12
|
} : r;
|
|
12
13
|
return t;
|
|
13
14
|
}
|
|
14
|
-
function
|
|
15
|
-
let { srcDir:
|
|
16
|
-
dir:
|
|
17
|
-
...typeof
|
|
18
|
-
})] : [],
|
|
15
|
+
function o(o = {}) {
|
|
16
|
+
let { srcDir: s = "src", port: c = 5173, host: l = "127.0.0.1", open: u = !1, proxy: d, alias: f = {}, plugins: p = [], icons: m = !0, overrides: h = {} } = o, g = h, _ = m ? [e({
|
|
17
|
+
dir: s,
|
|
18
|
+
...typeof m == "object" ? m : {}
|
|
19
|
+
})] : [], v = {
|
|
19
20
|
plugins: [
|
|
20
|
-
|
|
21
|
-
...
|
|
22
|
-
|
|
21
|
+
i(),
|
|
22
|
+
..._,
|
|
23
|
+
t(),
|
|
24
|
+
...p
|
|
23
25
|
],
|
|
24
26
|
resolve: { alias: {
|
|
25
|
-
"@":
|
|
26
|
-
...
|
|
27
|
+
"@": n(process.cwd(), s),
|
|
28
|
+
...f
|
|
27
29
|
} },
|
|
28
30
|
server: {
|
|
29
|
-
port:
|
|
30
|
-
host:
|
|
31
|
-
open:
|
|
32
|
-
...
|
|
31
|
+
port: c,
|
|
32
|
+
host: l,
|
|
33
|
+
open: u,
|
|
34
|
+
...d ? { proxy: a(d) } : {}
|
|
33
35
|
}
|
|
34
|
-
},
|
|
35
|
-
...
|
|
36
|
-
...
|
|
37
|
-
plugins: [...
|
|
36
|
+
}, y = {
|
|
37
|
+
...v,
|
|
38
|
+
...g,
|
|
39
|
+
plugins: [...v.plugins ?? [], ...g.plugins ?? []],
|
|
38
40
|
resolve: {
|
|
39
|
-
...
|
|
40
|
-
...
|
|
41
|
+
...v.resolve,
|
|
42
|
+
...g.resolve
|
|
41
43
|
},
|
|
42
44
|
server: {
|
|
43
|
-
...
|
|
44
|
-
...
|
|
45
|
+
...v.server,
|
|
46
|
+
...g.server
|
|
45
47
|
}
|
|
46
48
|
};
|
|
47
|
-
return
|
|
49
|
+
return r(y);
|
|
48
50
|
}
|
|
49
51
|
//#endregion
|
|
50
|
-
export {
|
|
52
|
+
export { o as createViteConfig };
|
|
51
53
|
|
|
52
54
|
//# sourceMappingURL=create-vite-config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-vite-config.js","names":[],"sources":["../../src/vite/create-vite-config.ts"],"sourcesContent":["import { resolve } from \"node:path\";\nimport { defineConfig } from \"vite\";\nimport type { ProxyOptions, UserConfig } from \"vite\";\nimport react from \"@vitejs/plugin-react\";\n\nimport { tempestIcons, type TempestIconsOptions } from \"./tempest-icons\";\n\n/**\n * A Vite proxy entry: either a target URL string (expanded to\n * `{ target, changeOrigin: true }`) or a raw Vite `ProxyOptions` object.\n */\nexport type ProxyEntry = string | Record<string, unknown>;\n\nexport interface CreateViteConfigOptions {\n /**\n * Source directory aliased to `@`, relative to the project root.\n * Default: `\"src\"` (so `@/components/Button` → `<root>/src/components/Button`).\n */\n srcDir?: string;\n /** Dev server port. Default: `5173`. */\n port?: number;\n /** Dev server host. Default: `\"127.0.0.1\"`. */\n host?: string | boolean;\n /** Open the browser on `dev` start. Default: `false`. */\n open?: boolean;\n /**\n * Dev proxy table. String values are expanded to\n * `{ target, changeOrigin: true }`; objects are passed through untouched.\n *\n * @example { \"/api\": \"http://127.0.0.1:8000\" }\n */\n proxy?: Record<string, ProxyEntry>;\n /** Extra path aliases merged on top of the default `@` → src alias. */\n alias?: Record<string, string>;\n /** Vite plugins appended after `@vitejs/plugin-react`. */\n plugins?: unknown[];\n /**\n * The `tempestIcons()` plugin, which generates `virtual:tempest-icons` from the\n * icon slugs your source mentions. On by default — it only ever removes\n * requests. Pass `false` to leave it out, or an options object to configure the\n * scan.\n */\n icons?: boolean | TempestIconsOptions;\n /**\n * Arbitrary Vite config (a `UserConfig` object) deep-merged last, for\n * escape-hatch overrides (build target, define, extra `server` keys, …).\n */\n overrides?: Record<string, unknown>;\n}\n\n/**\n * The resulting Vite config object. Typed loosely so the SDK's published\n * declarations stay free of `vite`'s internal types; assign it straight to a\n * `vite.config.ts` default export.\n */\nexport type TempestViteConfig = Record<string, unknown>;\n\nfunction normalizeProxy(proxy: Record<string, ProxyEntry>): Record<string, ProxyOptions> {\n const out: Record<string, ProxyOptions> = {};\n for (const [path, value] of Object.entries(proxy)) {\n out[path] =\n typeof value === \"string\"\n ? { target: value, changeOrigin: true }\n : (value as ProxyOptions);\n }\n return out;\n}\n\n/**\n * Build a Tempest-flavored Vite config for a React app: the `@vitejs/plugin-react`\n * plugin, the `@` → `src` import alias,
|
|
1
|
+
{"version":3,"file":"create-vite-config.js","names":[],"sources":["../../src/vite/create-vite-config.ts"],"sourcesContent":["import { resolve } from \"node:path\";\nimport { defineConfig } from \"vite\";\nimport type { ProxyOptions, UserConfig } from \"vite\";\nimport react from \"@vitejs/plugin-react\";\n\nimport { tempestIcons, type TempestIconsOptions } from \"./tempest-icons\";\nimport { tempestVitest } from \"./tempest-vitest\";\n\n/**\n * A Vite proxy entry: either a target URL string (expanded to\n * `{ target, changeOrigin: true }`) or a raw Vite `ProxyOptions` object.\n */\nexport type ProxyEntry = string | Record<string, unknown>;\n\nexport interface CreateViteConfigOptions {\n /**\n * Source directory aliased to `@`, relative to the project root.\n * Default: `\"src\"` (so `@/components/Button` → `<root>/src/components/Button`).\n */\n srcDir?: string;\n /** Dev server port. Default: `5173`. */\n port?: number;\n /** Dev server host. Default: `\"127.0.0.1\"`. */\n host?: string | boolean;\n /** Open the browser on `dev` start. Default: `false`. */\n open?: boolean;\n /**\n * Dev proxy table. String values are expanded to\n * `{ target, changeOrigin: true }`; objects are passed through untouched.\n *\n * @example { \"/api\": \"http://127.0.0.1:8000\" }\n */\n proxy?: Record<string, ProxyEntry>;\n /** Extra path aliases merged on top of the default `@` → src alias. */\n alias?: Record<string, string>;\n /** Vite plugins appended after `@vitejs/plugin-react`. */\n plugins?: unknown[];\n /**\n * The `tempestIcons()` plugin, which generates `virtual:tempest-icons` from the\n * icon slugs your source mentions. On by default — it only ever removes\n * requests. Pass `false` to leave it out, or an options object to configure the\n * scan.\n */\n icons?: boolean | TempestIconsOptions;\n /**\n * Arbitrary Vite config (a `UserConfig` object) deep-merged last, for\n * escape-hatch overrides (build target, define, extra `server` keys, …).\n */\n overrides?: Record<string, unknown>;\n}\n\n/**\n * The resulting Vite config object. Typed loosely so the SDK's published\n * declarations stay free of `vite`'s internal types; assign it straight to a\n * `vite.config.ts` default export.\n */\nexport type TempestViteConfig = Record<string, unknown>;\n\nfunction normalizeProxy(proxy: Record<string, ProxyEntry>): Record<string, ProxyOptions> {\n const out: Record<string, ProxyOptions> = {};\n for (const [path, value] of Object.entries(proxy)) {\n out[path] =\n typeof value === \"string\"\n ? { target: value, changeOrigin: true }\n : (value as ProxyOptions);\n }\n return out;\n}\n\n/**\n * Build a Tempest-flavored Vite config for a React app: the `@vitejs/plugin-react`\n * plugin, the `@` → `src` import alias, sane dev-server defaults and\n * {@link tempestVitest}, which lets a Vitest suite import the SDK — so a\n * consuming app's `vite.config.ts` is a single call instead of repeated\n * boilerplate. Everything is overridable.\n *\n * Import it from the dedicated Node entry point:\n *\n * @example\n * // vite.config.ts\n * import { createViteConfig } from \"tempest-react-sdk/vite\";\n *\n * export default createViteConfig({\n * proxy: { \"/api\": \"http://127.0.0.1:8000\" },\n * });\n */\nexport function createViteConfig(options: CreateViteConfigOptions = {}): TempestViteConfig {\n const {\n srcDir = \"src\",\n port = 5173,\n host = \"127.0.0.1\",\n open = false,\n proxy,\n alias = {},\n plugins = [],\n icons = true,\n overrides = {},\n } = options;\n\n const overridesConfig = overrides as UserConfig;\n const iconsPlugin = icons\n ? [tempestIcons({ dir: srcDir, ...(typeof icons === \"object\" ? icons : {}) })]\n : [];\n\n const base: UserConfig = {\n plugins: [react(), ...iconsPlugin, tempestVitest(), ...plugins] as UserConfig[\"plugins\"],\n resolve: {\n alias: {\n \"@\": resolve(process.cwd(), srcDir),\n ...alias,\n },\n },\n server: {\n port,\n host,\n open,\n ...(proxy ? { proxy: normalizeProxy(proxy) } : {}),\n },\n };\n\n const merged: UserConfig = {\n ...base,\n ...overridesConfig,\n plugins: [...(base.plugins ?? []), ...(overridesConfig.plugins ?? [])],\n resolve: { ...base.resolve, ...overridesConfig.resolve },\n server: { ...base.server, ...overridesConfig.server },\n };\n\n return defineConfig(merged) as TempestViteConfig;\n}\n"],"mappings":";;;;;;AA0DA,SAAS,EAAe,GAAiE;CACrF,IAAM,IAAoC,CAAC;CAC3C,KAAK,IAAM,CAAC,GAAM,MAAU,OAAO,QAAQ,CAAK,GAC5C,EAAI,KACA,OAAO,KAAU,WACX;EAAE,QAAQ;EAAO,cAAc;CAAK,IACnC;CAEf,OAAO;AACX;AAmBA,SAAgB,EAAiB,IAAmC,CAAC,GAAsB;CACvF,IAAM,EACF,YAAS,OACT,UAAO,MACP,UAAO,aACP,UAAO,IACP,UACA,WAAQ,CAAC,GACT,aAAU,CAAC,GACX,WAAQ,IACR,eAAY,CAAC,MACb,GAEE,IAAkB,GAClB,IAAc,IACd,CAAC,EAAa;EAAE,KAAK;EAAQ,GAAI,OAAO,KAAU,WAAW,IAAQ,CAAC;CAAG,CAAC,CAAC,IAC3E,CAAC,GAED,IAAmB;EACrB,SAAS;GAAC,EAAM;GAAG,GAAG;GAAa,EAAc;GAAG,GAAG;EAAO;EAC9D,SAAS,EACL,OAAO;GACH,KAAK,EAAQ,QAAQ,IAAI,GAAG,CAAM;GAClC,GAAG;EACP,EACJ;EACA,QAAQ;GACJ;GACA;GACA;GACA,GAAI,IAAQ,EAAE,OAAO,EAAe,CAAK,EAAE,IAAI,CAAC;EACpD;CACJ,GAEM,IAAqB;EACvB,GAAG;EACH,GAAG;EACH,SAAS,CAAC,GAAI,EAAK,WAAW,CAAC,GAAI,GAAI,EAAgB,WAAW,CAAC,CAAE;EACrE,SAAS;GAAE,GAAG,EAAK;GAAS,GAAG,EAAgB;EAAQ;EACvD,QAAQ;GAAE,GAAG,EAAK;GAAQ,GAAG,EAAgB;EAAO;CACxD;CAEA,OAAO,EAAa,CAAM;AAC9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tempest-vitest.cjs","names":[],"sources":["../../src/vite/tempest-vitest.ts"],"sourcesContent":["import type { TempestVitePlugin } from \"./tempest-pwa-manifest\";\n\n/**\n * The `server.deps.inline` entry that makes Vitest transform the SDK instead of\n * handing it to Node.\n *\n * Vitest matches a string entry as `/node_modules/tempest-react-sdk` anywhere in\n * the module id, which covers npm, Yarn and pnpm's\n * `.pnpm/<name>@<version>/node_modules/` layout alike, without catching an app\n * that merely lives in a folder of the same name — which a bare regex would.\n */\nconst TEMPEST_VITEST_INLINE = \"tempest-react-sdk\";\n\n/** The slice of a user config this plugin reads to stay out of the way. */\ninterface VitestUserConfig {\n test?: { server?: { deps?: { inline?: unknown } } };\n}\n\n/**\n * Make Vitest load the SDK the way the app's bundler does.\n *\n * Every component module imports its own stylesheet. Vitest externalizes an ESM\n * package from `node_modules` to plain Node, and Node has no loader for `.css`, so\n * any test that imports the real barrel dies before running with\n * `TypeError: Unknown file extension \".css\"`. Inlining the package sends it through\n * Vite's pipeline, where the stylesheet import is processed like in the app.\n *\n * Measured with `tempest-react-sdk@0.70.0` and a one-line test importing `Button`:\n * Vitest 2.1.9, 3.2.7 and 4.1.11 all fail under the default config and pass with\n * this plugin.\n *\n * The entry is contributed through the `config` hook, so Vite concatenates it onto\n * whatever `test.server.deps.inline` list the app declares. The one value it must\n * not merge into is `true` (inline everything): Vite's merge would turn it into\n * `[true, \"tempest-react-sdk\"]`, and Vitest 4 then crashes with\n * `ex.test is not a function` matching ids against it. That config already inlines\n * the SDK, so the plugin contributes nothing.\n *\n * Outside Vitest the `test` key is ignored by Vite, so the plugin is inert in\n * `vite dev` and `vite build` — which is why `createViteConfig` always includes it.\n *\n * @returns A Vite plugin; add it to `plugins` in `vite.config.ts` or\n * `vitest.config.ts`.\n *\n * @example\n * // vitest.config.ts\n * import { defineConfig } from \"vitest/config\";\n * import { tempestVitest } from \"tempest-react-sdk/vite\";\n *\n * export default defineConfig({\n * plugins: [tempestVitest()],\n * test: { environment: \"jsdom\" },\n * });\n */\nexport function tempestVitest(): TempestVitePlugin {\n return {\n name: \"tempest-vitest\",\n config(userConfig: VitestUserConfig): VitestUserConfig | undefined {\n if (userConfig.test?.server?.deps?.inline === true) return undefined;\n return { test: { server: { deps: { inline: [TEMPEST_VITEST_INLINE] } } } };\n },\n };\n}\n"],"mappings":"AAsDA,SAAgB,GAAmC,CAC/C,MAAO,CACH,KAAM,iBACN,OAAO,EAA4D,CAC3D,KAAW,MAAM,QAAQ,MAAM,SAAW,GAC9C,MAAO,CAAE,KAAM,CAAE,OAAQ,CAAE,KAAM,CAAE,OAAQ,CAAC,mBAAqB,CAAE,CAAE,CAAE,CAAE,CAC7E,CACJ,CACJ"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
function e() {
|
|
2
|
+
return {
|
|
3
|
+
name: "tempest-vitest",
|
|
4
|
+
config(e) {
|
|
5
|
+
if (e.test?.server?.deps?.inline !== !0) return { test: { server: { deps: { inline: ["tempest-react-sdk"] } } } };
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { e as tempestVitest };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=tempest-vitest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tempest-vitest.js","names":[],"sources":["../../src/vite/tempest-vitest.ts"],"sourcesContent":["import type { TempestVitePlugin } from \"./tempest-pwa-manifest\";\n\n/**\n * The `server.deps.inline` entry that makes Vitest transform the SDK instead of\n * handing it to Node.\n *\n * Vitest matches a string entry as `/node_modules/tempest-react-sdk` anywhere in\n * the module id, which covers npm, Yarn and pnpm's\n * `.pnpm/<name>@<version>/node_modules/` layout alike, without catching an app\n * that merely lives in a folder of the same name — which a bare regex would.\n */\nconst TEMPEST_VITEST_INLINE = \"tempest-react-sdk\";\n\n/** The slice of a user config this plugin reads to stay out of the way. */\ninterface VitestUserConfig {\n test?: { server?: { deps?: { inline?: unknown } } };\n}\n\n/**\n * Make Vitest load the SDK the way the app's bundler does.\n *\n * Every component module imports its own stylesheet. Vitest externalizes an ESM\n * package from `node_modules` to plain Node, and Node has no loader for `.css`, so\n * any test that imports the real barrel dies before running with\n * `TypeError: Unknown file extension \".css\"`. Inlining the package sends it through\n * Vite's pipeline, where the stylesheet import is processed like in the app.\n *\n * Measured with `tempest-react-sdk@0.70.0` and a one-line test importing `Button`:\n * Vitest 2.1.9, 3.2.7 and 4.1.11 all fail under the default config and pass with\n * this plugin.\n *\n * The entry is contributed through the `config` hook, so Vite concatenates it onto\n * whatever `test.server.deps.inline` list the app declares. The one value it must\n * not merge into is `true` (inline everything): Vite's merge would turn it into\n * `[true, \"tempest-react-sdk\"]`, and Vitest 4 then crashes with\n * `ex.test is not a function` matching ids against it. That config already inlines\n * the SDK, so the plugin contributes nothing.\n *\n * Outside Vitest the `test` key is ignored by Vite, so the plugin is inert in\n * `vite dev` and `vite build` — which is why `createViteConfig` always includes it.\n *\n * @returns A Vite plugin; add it to `plugins` in `vite.config.ts` or\n * `vitest.config.ts`.\n *\n * @example\n * // vitest.config.ts\n * import { defineConfig } from \"vitest/config\";\n * import { tempestVitest } from \"tempest-react-sdk/vite\";\n *\n * export default defineConfig({\n * plugins: [tempestVitest()],\n * test: { environment: \"jsdom\" },\n * });\n */\nexport function tempestVitest(): TempestVitePlugin {\n return {\n name: \"tempest-vitest\",\n config(userConfig: VitestUserConfig): VitestUserConfig | undefined {\n if (userConfig.test?.server?.deps?.inline === true) return undefined;\n return { test: { server: { deps: { inline: [TEMPEST_VITEST_INLINE] } } } };\n },\n };\n}\n"],"mappings":"AAsDA,SAAgB,IAAmC;CAC/C,OAAO;EACH,MAAM;EACN,OAAO,GAA4D;GAC3D,MAAW,MAAM,QAAQ,MAAM,WAAW,IAC9C,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,mBAAqB,EAAE,EAAE,EAAE,EAAE;EAC7E;CACJ;AACJ"}
|
package/dist/vite.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./vite/tempest-icons.cjs"),t=require("./vite/create-vite-config.cjs"),
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./vite/tempest-icons.cjs"),t=require("./vite/tempest-vitest.cjs"),n=require("./vite/create-vite-config.cjs"),r=require("./vite/tempest-pwa-manifest.cjs"),i=require("./vite/tempest-pwa-icons.cjs"),a=require("./vite/tempest-pwa-dev-sw.cjs"),o=require("./vite/tempest-styles.cjs"),s=require("./vite/tempest-csp.cjs");exports.createViteConfig=n.createViteConfig,exports.tempestCsp=s.tempestCsp,exports.tempestIcons=e.tempestIcons,exports.tempestPwaDevSw=a.tempestPwaDevSw,exports.tempestPwaIcons=i.tempestPwaIcons,exports.tempestPwaManifest=r.tempestPwaManifest,exports.tempestStyles=o.tempestStyles,exports.tempestVitest=t.tempestVitest;
|
package/dist/vite.d.ts
CHANGED
|
@@ -10,7 +10,8 @@ export declare interface AppleSplashSpec {
|
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Build a Tempest-flavored Vite config for a React app: the `@vitejs/plugin-react`
|
|
13
|
-
* plugin, the `@` → `src` import alias,
|
|
13
|
+
* plugin, the `@` → `src` import alias, sane dev-server defaults and
|
|
14
|
+
* {@link tempestVitest}, which lets a Vitest suite import the SDK — so a
|
|
14
15
|
* consuming app's `vite.config.ts` is a single call instead of repeated
|
|
15
16
|
* boilerplate. Everything is overridable.
|
|
16
17
|
*
|
|
@@ -501,6 +502,44 @@ export declare type TempestVitePlugin = {
|
|
|
501
502
|
name: string;
|
|
502
503
|
} & Record<string, unknown>;
|
|
503
504
|
|
|
505
|
+
/**
|
|
506
|
+
* Make Vitest load the SDK the way the app's bundler does.
|
|
507
|
+
*
|
|
508
|
+
* Every component module imports its own stylesheet. Vitest externalizes an ESM
|
|
509
|
+
* package from `node_modules` to plain Node, and Node has no loader for `.css`, so
|
|
510
|
+
* any test that imports the real barrel dies before running with
|
|
511
|
+
* `TypeError: Unknown file extension ".css"`. Inlining the package sends it through
|
|
512
|
+
* Vite's pipeline, where the stylesheet import is processed like in the app.
|
|
513
|
+
*
|
|
514
|
+
* Measured with `tempest-react-sdk@0.70.0` and a one-line test importing `Button`:
|
|
515
|
+
* Vitest 2.1.9, 3.2.7 and 4.1.11 all fail under the default config and pass with
|
|
516
|
+
* this plugin.
|
|
517
|
+
*
|
|
518
|
+
* The entry is contributed through the `config` hook, so Vite concatenates it onto
|
|
519
|
+
* whatever `test.server.deps.inline` list the app declares. The one value it must
|
|
520
|
+
* not merge into is `true` (inline everything): Vite's merge would turn it into
|
|
521
|
+
* `[true, "tempest-react-sdk"]`, and Vitest 4 then crashes with
|
|
522
|
+
* `ex.test is not a function` matching ids against it. That config already inlines
|
|
523
|
+
* the SDK, so the plugin contributes nothing.
|
|
524
|
+
*
|
|
525
|
+
* Outside Vitest the `test` key is ignored by Vite, so the plugin is inert in
|
|
526
|
+
* `vite dev` and `vite build` — which is why `createViteConfig` always includes it.
|
|
527
|
+
*
|
|
528
|
+
* @returns A Vite plugin; add it to `plugins` in `vite.config.ts` or
|
|
529
|
+
* `vitest.config.ts`.
|
|
530
|
+
*
|
|
531
|
+
* @example
|
|
532
|
+
* // vitest.config.ts
|
|
533
|
+
* import { defineConfig } from "vitest/config";
|
|
534
|
+
* import { tempestVitest } from "tempest-react-sdk/vite";
|
|
535
|
+
*
|
|
536
|
+
* export default defineConfig({
|
|
537
|
+
* plugins: [tempestVitest()],
|
|
538
|
+
* test: { environment: "jsdom" },
|
|
539
|
+
* });
|
|
540
|
+
*/
|
|
541
|
+
export declare function tempestVitest(): TempestVitePlugin;
|
|
542
|
+
|
|
504
543
|
/**
|
|
505
544
|
* How much of the token sheet an app takes.
|
|
506
545
|
*
|
package/dist/vite.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { tempestIcons as e } from "./vite/tempest-icons.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
2
|
+
import { tempestVitest as t } from "./vite/tempest-vitest.js";
|
|
3
|
+
import { createViteConfig as n } from "./vite/create-vite-config.js";
|
|
4
|
+
import { tempestPwaManifest as r } from "./vite/tempest-pwa-manifest.js";
|
|
5
|
+
import { tempestPwaIcons as i } from "./vite/tempest-pwa-icons.js";
|
|
6
|
+
import { tempestPwaDevSw as a } from "./vite/tempest-pwa-dev-sw.js";
|
|
7
|
+
import { tempestStyles as o } from "./vite/tempest-styles.js";
|
|
8
|
+
import { tempestCsp as s } from "./vite/tempest-csp.js";
|
|
9
|
+
export { n as createViteConfig, s as tempestCsp, e as tempestIcons, a as tempestPwaDevSw, i as tempestPwaIcons, r as tempestPwaManifest, o as tempestStyles, t as tempestVitest };
|