@dudousxd/nestjs-inertia-vite 1.4.3 → 1.5.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/CHANGELOG.md +25 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/plugin/plugin.d.cts +27 -0
- package/package.json +22 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# Changelog — @dudousxd/nestjs-inertia-vite
|
|
2
2
|
|
|
3
|
+
## 1.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#29](https://github.com/DavideCarvalho/nestjs-inertia/pull/29) [`7def22b`](https://github.com/DavideCarvalho/nestjs-inertia/commit/7def22b2df24a472f0e0bcef457aa3b1e60f9fe9) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - A broad set of ecosystem improvements across the server adapter, typed client, codegen, testing, and Vite packages.
|
|
8
|
+
|
|
9
|
+
**Server (`@dudousxd/nestjs-inertia`)**
|
|
10
|
+
|
|
11
|
+
- General flash messages: the flash store now carries arbitrary flash payloads (success, info, warning, etc.) instead of being limited to errors.
|
|
12
|
+
- Stable asset-version fallback: the asset-version provider derives a deterministic fallback version so SSR/CSR markup stays consistent when no explicit version is configured.
|
|
13
|
+
- `matchOn: string | string[]`: partial-reload / scope matching accepts either a single key or an array of keys.
|
|
14
|
+
- `lazy()` deprecation: deprecated usages now emit a warning through the Nest `Logger` to guide migration.
|
|
15
|
+
- SSR streaming: streaming SSR render is supported on both the Express and Fastify adapters, with a retryable SSR loader that falls back to buffered SSR when streaming setup fails.
|
|
16
|
+
- Packaging hygiene: dual ESM/CJS `exports` maps and build config cleaned up across the package set.
|
|
17
|
+
|
|
18
|
+
**Client (`@dudousxd/nestjs-inertia-client`)**
|
|
19
|
+
|
|
20
|
+
- Typed `useForm` end-to-end for React, Vue, and Svelte.
|
|
21
|
+
- Typed `<Deferred>` / `<WhenVisible>` components with shared deferred types across frameworks.
|
|
22
|
+
- Native `router.poll` and prefetch helpers (typed poll + prefetch-route utilities).
|
|
23
|
+
|
|
24
|
+
**Codegen, testing, and Vite**
|
|
25
|
+
|
|
26
|
+
- Codegen extension, testing helpers (Jest + Vitest), and the Vite plugin updated to support the new typed client surface and packaging conventions.
|
|
27
|
+
|
|
3
28
|
## 1.4.3
|
|
4
29
|
|
|
5
30
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -181,7 +181,7 @@ function nestInertia(options = {}) {
|
|
|
181
181
|
__name(nestInertia, "nestInertia");
|
|
182
182
|
|
|
183
183
|
// src/index.ts
|
|
184
|
-
var VERSION = "1.
|
|
184
|
+
var VERSION = "1.5.0";
|
|
185
185
|
// Annotate the CommonJS export names for ESM import in node:
|
|
186
186
|
0 && (module.exports = {
|
|
187
187
|
InvalidViteConfigException,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/setup.ts","../src/plugin/plugin.ts"],"sourcesContent":["export const VERSION = '1.4.3';\nexport { setupInertiaVite } from './setup.js';\nexport type { SetupInertiaViteOptions } from './setup.js';\nexport { default as nestInertia } from './plugin/plugin.js';\nexport type { NestInertiaPluginOptions } from './plugin/plugin.js';\nexport { InvalidViteConfigException } from './plugin/plugin.js';\n","import { resolve } from 'node:path';\n\nexport interface SetupInertiaViteOptions {\n mode: string | undefined;\n root: string;\n publicDir: string;\n outDir: string;\n hmrPort?: number;\n configFile?: string;\n}\n\ntype NestApp = {\n use: (pathOrMiddleware: unknown, middleware?: unknown) => void;\n};\n\nexport async function setupInertiaVite(\n app: NestApp,\n options: SetupInertiaViteOptions,\n): Promise<void> {\n if (options.mode !== 'production') {\n const { createServer: createViteServer } = await import('vite');\n const vite = await createViteServer({\n configFile: options.configFile ?? resolve(process.cwd(), 'vite.config.ts'),\n root: options.root,\n server: {\n middlewareMode: true,\n hmr: { port: options.hmrPort ?? 24679 },\n },\n appType: 'custom',\n });\n app.use((vite as { middlewares: unknown }).middlewares);\n return;\n }\n\n // Production: serve dist/<outDir>/client\n const express = await import('express');\n const clientDir = resolve(process.cwd(), options.outDir, 'client');\n app.use(\n '/assets',\n (express.default ?? express).static(resolve(clientDir, 'assets'), {\n maxAge: '1y',\n immutable: true,\n }),\n );\n app.use(\n (express.default ?? express).static(clientDir, {\n maxAge: '1h',\n index: false,\n fallthrough: true,\n }),\n );\n}\n","import { createRequire } from 'node:module';\nimport { resolve } from 'node:path';\nimport type { Plugin, UserConfig } from 'vite';\n\nconst require = createRequire(import.meta.url);\n\nexport interface NestInertiaPluginOptions {\n ssr?: boolean;\n react?: boolean;\n vue?: boolean;\n svelte?: boolean;\n /**\n * When `true`, the nestInertia plugin will skip auto-loading the framework\n * Vite plugin. Use this when the framework plugin (e.g. @sveltejs/vite-plugin-svelte)\n * needs to be added manually in the vite config alongside nestInertia().\n *\n * @default false\n */\n skipFrameworkPlugin?: boolean;\n clientEntry?: string;\n ssrEntry?: string;\n alias?: Record<string, string>;\n root?: string;\n entry?: string;\n}\n\nexport class InvalidViteConfigException extends Error {\n constructor(message: string) {\n super(`[nestjs-inertia-vite] ${message}`);\n this.name = 'InvalidViteConfigException';\n }\n}\n\nfunction loadFrameworkPlugin(framework: 'react' | 'vue' | 'svelte'): Plugin {\n const pkg =\n framework === 'react'\n ? '@vitejs/plugin-react'\n : framework === 'vue'\n ? '@vitejs/plugin-vue'\n : '@sveltejs/vite-plugin-svelte';\n try {\n const mod = require(pkg) as { default?: () => Plugin; svelte?: () => Plugin };\n // @sveltejs/vite-plugin-svelte v3+ exports a named `svelte` export rather than default\n const factory =\n mod.default ??\n (framework === 'svelte' ? mod.svelte : undefined) ??\n (mod as unknown as () => Plugin);\n return (factory as () => Plugin)();\n } catch {\n throw new InvalidViteConfigException(`Plugin \"${pkg}\" not installed. Run: pnpm add ${pkg}`);\n }\n}\n\nexport default function nestInertia(options: NestInertiaPluginOptions = {}): Plugin[] {\n const frameworkFlags = [options.react, options.vue, options.svelte].filter(Boolean);\n if (frameworkFlags.length !== 1) {\n throw new InvalidViteConfigException(\n 'nestInertia requires exactly one framework flag: react, vue, or svelte',\n );\n }\n\n const defaultRoot = 'inertia';\n const alias = {\n '@': resolve(process.cwd(), options.root ?? defaultRoot),\n ...(options.alias ?? {}),\n };\n\n const configurer: Plugin = {\n name: 'nestjs-inertia',\n config: (userConfig: UserConfig): Omit<UserConfig, 'plugins'> => {\n const resolvedRoot = options.root ?? defaultRoot;\n const defaultEntry = options.entry ?? options.clientEntry ?? `${resolvedRoot}/app/client.tsx`;\n\n const buildConfig: NonNullable<UserConfig['build']> = {\n manifest: true,\n rollupOptions: {},\n };\n\n // Only set outDir if the user hasn't already defined it\n if (!userConfig.build?.outDir) {\n buildConfig.outDir = 'dist/inertia/client';\n }\n\n // Only set rollupOptions.input if the user hasn't already defined it\n if (!userConfig.build?.rollupOptions?.input) {\n buildConfig.rollupOptions = {\n input: resolve(process.cwd(), defaultEntry),\n };\n }\n\n const result: Omit<UserConfig, 'plugins'> = {\n build: buildConfig,\n resolve: { alias },\n server: {\n middlewareMode: true,\n hmr: { port: 24679 },\n },\n };\n\n // Only set root if the user hasn't already defined it in their vite config\n if (!userConfig.root) {\n result.root = resolve(process.cwd(), resolvedRoot);\n }\n\n return result;\n },\n };\n\n const codegenHmr: Plugin = {\n name: 'nestjs-inertia:codegen-hmr',\n configureServer(server) {\n const codegenDir = resolve(process.cwd(), '.nestjs-inertia');\n const { watcher } = server;\n watcher.add(codegenDir);\n watcher.on('change', (file) => {\n if (!file.startsWith(codegenDir)) return;\n const mods = server.moduleGraph.getModulesByFile(file);\n if (mods) {\n for (const mod of mods) {\n server.moduleGraph.invalidateModule(mod);\n }\n }\n server.ws.send({ type: 'full-reload' });\n });\n },\n };\n\n if (options.skipFrameworkPlugin) {\n return [configurer, codegenHmr];\n }\n\n const frameworkPlugin = options.react\n ? loadFrameworkPlugin('react')\n : options.vue\n ? loadFrameworkPlugin('vue')\n : loadFrameworkPlugin('svelte');\n\n return [configurer, frameworkPlugin, codegenHmr];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;ACAA,uBAAwB;AAexB,eAAsBA,iBACpBC,KACAC,SAAgC;AAEhC,MAAIA,QAAQC,SAAS,cAAc;AACjC,UAAM,EAAEC,cAAcC,iBAAgB,IAAK,MAAM,OAAO,MAAA;AACxD,UAAMC,OAAO,MAAMD,iBAAiB;MAClCE,YAAYL,QAAQK,kBAAcC,0BAAQC,QAAQC,IAAG,GAAI,gBAAA;MACzDC,MAAMT,QAAQS;MACdC,QAAQ;QACNC,gBAAgB;QAChBC,KAAK;UAAEC,MAAMb,QAAQc,WAAW;QAAM;MACxC;MACAC,SAAS;IACX,CAAA;AACAhB,QAAIiB,IAAKZ,KAAkCa,WAAW;AACtD;EACF;AAGA,QAAMC,UAAU,MAAM,OAAO,SAAA;AAC7B,QAAMC,gBAAYb,0BAAQC,QAAQC,IAAG,GAAIR,QAAQoB,QAAQ,QAAA;AACzDrB,MAAIiB,IACF,YACCE,QAAQG,WAAWH,SAASI,WAAOhB,0BAAQa,WAAW,QAAA,GAAW;IAChEI,QAAQ;IACRC,WAAW;EACb,CAAA,CAAA;AAEFzB,MAAIiB,KACDE,QAAQG,WAAWH,SAASI,OAAOH,WAAW;IAC7CI,QAAQ;IACRE,OAAO;IACPC,aAAa;EACf,CAAA,CAAA;AAEJ;AApCsB5B;;;ACftB,yBAA8B;AAC9B,IAAA6B,oBAAwB;AAGxB,IAAMC,eAAUC,kCAAc,eAAe;AAsBtC,IAAMC,6BAAN,cAAyCC,MAAAA;EA1BhD,OA0BgDA;;;EAC9C,YAAYC,SAAiB;AAC3B,UAAM,yBAAyBA,OAAAA,EAAS;AACxC,SAAKC,OAAO;EACd;AACF;AAEA,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AACf,WAAWH,MAAM;AACpBc,eAAOd,WAAOH,2BAAQC,QAAQC,IAAG,GAAIK,YAAAA;MACvC;AAEA,aAAOU;IACT,GApCQ;EAqCV;AAEA,QAAMK,aAAqB;IACzBxC,MAAM;IACNyC,gBAAgBL,QAAM;AACpB,YAAMM,iBAAaxB,2BAAQC,QAAQC,IAAG,GAAI,iBAAA;AAC1C,YAAM,EAAEuB,QAAO,IAAKP;AACpBO,cAAQC,IAAIF,UAAAA;AACZC,cAAQE,GAAG,UAAU,CAACC,SAAAA;AACpB,YAAI,CAACA,KAAKC,WAAWL,UAAAA,EAAa;AAClC,cAAMM,OAAOZ,OAAOa,YAAYC,iBAAiBJ,IAAAA;AACjD,YAAIE,MAAM;AACR,qBAAW5C,OAAO4C,MAAM;AACtBZ,mBAAOa,YAAYE,iBAAiB/C,GAAAA;UACtC;QACF;AACAgC,eAAOgB,GAAGC,KAAK;UAAEC,MAAM;QAAc,CAAA;MACvC,CAAA;IACF;EACF;AAEA,MAAI7C,QAAQ8C,qBAAqB;AAC/B,WAAO;MAACjC;MAAYkB;;EACtB;AAEA,QAAMgB,kBAAkB/C,QAAQE,QAC5BV,oBAAoB,OAAA,IACpBQ,QAAQG,MACNX,oBAAoB,KAAA,IACpBA,oBAAoB,QAAA;AAE1B,SAAO;IAACqB;IAAYkC;IAAiBhB;;AACvC;AArFwBiB;;;AFrDjB,IAAMC,UAAU;","names":["setupInertiaVite","app","options","mode","createServer","createViteServer","vite","configFile","resolve","process","cwd","root","server","middlewareMode","hmr","port","hmrPort","appType","use","middlewares","express","clientDir","outDir","default","static","maxAge","immutable","index","fallthrough","import_node_path","require","createRequire","InvalidViteConfigException","Error","message","name","loadFrameworkPlugin","framework","pkg","mod","factory","default","svelte","undefined","options","frameworkFlags","react","vue","filter","Boolean","length","defaultRoot","alias","resolve","process","cwd","root","configurer","config","userConfig","resolvedRoot","defaultEntry","entry","clientEntry","buildConfig","manifest","rollupOptions","build","outDir","input","result","server","middlewareMode","hmr","port","codegenHmr","configureServer","codegenDir","watcher","add","on","file","startsWith","mods","moduleGraph","getModulesByFile","invalidateModule","ws","send","type","skipFrameworkPlugin","frameworkPlugin","nestInertia","VERSION"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/setup.ts","../src/plugin/plugin.ts"],"sourcesContent":["export const VERSION = '1.5.0';\nexport { setupInertiaVite } from './setup.js';\nexport type { SetupInertiaViteOptions } from './setup.js';\nexport { default as nestInertia } from './plugin/plugin.js';\nexport type { NestInertiaPluginOptions } from './plugin/plugin.js';\nexport { InvalidViteConfigException } from './plugin/plugin.js';\n","import { resolve } from 'node:path';\n\nexport interface SetupInertiaViteOptions {\n mode: string | undefined;\n root: string;\n publicDir: string;\n outDir: string;\n hmrPort?: number;\n configFile?: string;\n}\n\ntype NestApp = {\n use: (pathOrMiddleware: unknown, middleware?: unknown) => void;\n};\n\nexport async function setupInertiaVite(\n app: NestApp,\n options: SetupInertiaViteOptions,\n): Promise<void> {\n if (options.mode !== 'production') {\n const { createServer: createViteServer } = await import('vite');\n const vite = await createViteServer({\n configFile: options.configFile ?? resolve(process.cwd(), 'vite.config.ts'),\n root: options.root,\n server: {\n middlewareMode: true,\n hmr: { port: options.hmrPort ?? 24679 },\n },\n appType: 'custom',\n });\n app.use((vite as { middlewares: unknown }).middlewares);\n return;\n }\n\n // Production: serve dist/<outDir>/client\n const express = await import('express');\n const clientDir = resolve(process.cwd(), options.outDir, 'client');\n app.use(\n '/assets',\n (express.default ?? express).static(resolve(clientDir, 'assets'), {\n maxAge: '1y',\n immutable: true,\n }),\n );\n app.use(\n (express.default ?? express).static(clientDir, {\n maxAge: '1h',\n index: false,\n fallthrough: true,\n }),\n );\n}\n","import { createRequire } from 'node:module';\nimport { resolve } from 'node:path';\nimport type { Plugin, UserConfig } from 'vite';\n\nconst require = createRequire(import.meta.url);\n\nexport interface NestInertiaPluginOptions {\n ssr?: boolean;\n react?: boolean;\n vue?: boolean;\n svelte?: boolean;\n /**\n * When `true`, the nestInertia plugin will skip auto-loading the framework\n * Vite plugin. Use this when the framework plugin (e.g. @sveltejs/vite-plugin-svelte)\n * needs to be added manually in the vite config alongside nestInertia().\n *\n * @default false\n */\n skipFrameworkPlugin?: boolean;\n clientEntry?: string;\n ssrEntry?: string;\n alias?: Record<string, string>;\n root?: string;\n entry?: string;\n}\n\nexport class InvalidViteConfigException extends Error {\n constructor(message: string) {\n super(`[nestjs-inertia-vite] ${message}`);\n this.name = 'InvalidViteConfigException';\n }\n}\n\nfunction loadFrameworkPlugin(framework: 'react' | 'vue' | 'svelte'): Plugin {\n const pkg =\n framework === 'react'\n ? '@vitejs/plugin-react'\n : framework === 'vue'\n ? '@vitejs/plugin-vue'\n : '@sveltejs/vite-plugin-svelte';\n try {\n const mod = require(pkg) as { default?: () => Plugin; svelte?: () => Plugin };\n // @sveltejs/vite-plugin-svelte v3+ exports a named `svelte` export rather than default\n const factory =\n mod.default ??\n (framework === 'svelte' ? mod.svelte : undefined) ??\n (mod as unknown as () => Plugin);\n return (factory as () => Plugin)();\n } catch {\n throw new InvalidViteConfigException(`Plugin \"${pkg}\" not installed. Run: pnpm add ${pkg}`);\n }\n}\n\nexport default function nestInertia(options: NestInertiaPluginOptions = {}): Plugin[] {\n const frameworkFlags = [options.react, options.vue, options.svelte].filter(Boolean);\n if (frameworkFlags.length !== 1) {\n throw new InvalidViteConfigException(\n 'nestInertia requires exactly one framework flag: react, vue, or svelte',\n );\n }\n\n const defaultRoot = 'inertia';\n const alias = {\n '@': resolve(process.cwd(), options.root ?? defaultRoot),\n ...(options.alias ?? {}),\n };\n\n const configurer: Plugin = {\n name: 'nestjs-inertia',\n config: (userConfig: UserConfig): Omit<UserConfig, 'plugins'> => {\n const resolvedRoot = options.root ?? defaultRoot;\n const defaultEntry = options.entry ?? options.clientEntry ?? `${resolvedRoot}/app/client.tsx`;\n\n const buildConfig: NonNullable<UserConfig['build']> = {\n manifest: true,\n rollupOptions: {},\n };\n\n // Only set outDir if the user hasn't already defined it\n if (!userConfig.build?.outDir) {\n buildConfig.outDir = 'dist/inertia/client';\n }\n\n // Only set rollupOptions.input if the user hasn't already defined it\n if (!userConfig.build?.rollupOptions?.input) {\n buildConfig.rollupOptions = {\n input: resolve(process.cwd(), defaultEntry),\n };\n }\n\n const result: Omit<UserConfig, 'plugins'> = {\n build: buildConfig,\n resolve: { alias },\n server: {\n middlewareMode: true,\n hmr: { port: 24679 },\n },\n };\n\n // Only set root if the user hasn't already defined it in their vite config\n if (!userConfig.root) {\n result.root = resolve(process.cwd(), resolvedRoot);\n }\n\n return result;\n },\n };\n\n const codegenHmr: Plugin = {\n name: 'nestjs-inertia:codegen-hmr',\n configureServer(server) {\n const codegenDir = resolve(process.cwd(), '.nestjs-inertia');\n const { watcher } = server;\n watcher.add(codegenDir);\n watcher.on('change', (file) => {\n if (!file.startsWith(codegenDir)) return;\n const mods = server.moduleGraph.getModulesByFile(file);\n if (mods) {\n for (const mod of mods) {\n server.moduleGraph.invalidateModule(mod);\n }\n }\n server.ws.send({ type: 'full-reload' });\n });\n },\n };\n\n if (options.skipFrameworkPlugin) {\n return [configurer, codegenHmr];\n }\n\n const frameworkPlugin = options.react\n ? loadFrameworkPlugin('react')\n : options.vue\n ? loadFrameworkPlugin('vue')\n : loadFrameworkPlugin('svelte');\n\n return [configurer, frameworkPlugin, codegenHmr];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;ACAA,uBAAwB;AAexB,eAAsBA,iBACpBC,KACAC,SAAgC;AAEhC,MAAIA,QAAQC,SAAS,cAAc;AACjC,UAAM,EAAEC,cAAcC,iBAAgB,IAAK,MAAM,OAAO,MAAA;AACxD,UAAMC,OAAO,MAAMD,iBAAiB;MAClCE,YAAYL,QAAQK,kBAAcC,0BAAQC,QAAQC,IAAG,GAAI,gBAAA;MACzDC,MAAMT,QAAQS;MACdC,QAAQ;QACNC,gBAAgB;QAChBC,KAAK;UAAEC,MAAMb,QAAQc,WAAW;QAAM;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K;UAAEC,MAAM;QAAc,CAAA;MACvC,CAAA;IACF;EACF;AAEA,MAAI7C,QAAQ8C,qBAAqB;AAC/B,WAAO;MAACjC;MAAYkB;;EACtB;AAEA,QAAMgB,kBAAkB/C,QAAQE,QAC5BV,oBAAoB,OAAA,IACpBQ,QAAQG,MACNX,oBAAoB,KAAA,IACpBA,oBAAoB,QAAA;AAE1B,SAAO;IAACqB;IAAYkC;IAAiBhB;;AACvC;AArFwBiB;;;AFrDjB,IAAMC,UAAU;","names":["setupInertiaVite","app","options","mode","createServer","createViteServer","vite","configFile","resolve","process","cwd","root","server","middlewareMode","hmr","port","hmrPort","appType","use","middlewares","express","clientDir","outDir","default","static","maxAge","immutable","index","fallthrough","import_node_path","require","createRequire","InvalidViteConfigException","Error","message","name","loadFrameworkPlugin","framework","pkg","mod","factory","default","svelte","undefined","options","frameworkFlags","react","vue","filter","Boolean","length","defaultRoot","alias","resolve","process","cwd","root","configurer","config","userConfig","resolvedRoot","defaultEntry","entry","clientEntry","buildConfig","manifest","rollupOptions","build","outDir","input","result","server","middlewareMode","hmr","port","codegenHmr","configureServer","codegenDir","watcher","add","on","file","startsWith","mods","moduleGraph","getModulesByFile","invalidateModule","ws","send","type","skipFrameworkPlugin","frameworkPlugin","nestInertia","VERSION"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { InvalidViteConfigException, NestInertiaPluginOptions, default as nestInertia } from './plugin/plugin.cjs';
|
|
2
|
+
import 'vite';
|
|
3
|
+
|
|
4
|
+
interface SetupInertiaViteOptions {
|
|
5
|
+
mode: string | undefined;
|
|
6
|
+
root: string;
|
|
7
|
+
publicDir: string;
|
|
8
|
+
outDir: string;
|
|
9
|
+
hmrPort?: number;
|
|
10
|
+
configFile?: string;
|
|
11
|
+
}
|
|
12
|
+
type NestApp = {
|
|
13
|
+
use: (pathOrMiddleware: unknown, middleware?: unknown) => void;
|
|
14
|
+
};
|
|
15
|
+
declare function setupInertiaVite(app: NestApp, options: SetupInertiaViteOptions): Promise<void>;
|
|
16
|
+
|
|
17
|
+
declare const VERSION = "1.5.0";
|
|
18
|
+
|
|
19
|
+
export { type SetupInertiaViteOptions, VERSION, setupInertiaVite };
|
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,6 @@ type NestApp = {
|
|
|
14
14
|
};
|
|
15
15
|
declare function setupInertiaVite(app: NestApp, options: SetupInertiaViteOptions): Promise<void>;
|
|
16
16
|
|
|
17
|
-
declare const VERSION = "1.
|
|
17
|
+
declare const VERSION = "1.5.0";
|
|
18
18
|
|
|
19
19
|
export { type SetupInertiaViteOptions, VERSION, setupInertiaVite };
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/setup.ts","../src/plugin/plugin.ts","../src/index.ts"],"sourcesContent":["import { resolve } from 'node:path';\n\nexport interface SetupInertiaViteOptions {\n mode: string | undefined;\n root: string;\n publicDir: string;\n outDir: string;\n hmrPort?: number;\n configFile?: string;\n}\n\ntype NestApp = {\n use: (pathOrMiddleware: unknown, middleware?: unknown) => void;\n};\n\nexport async function setupInertiaVite(\n app: NestApp,\n options: SetupInertiaViteOptions,\n): Promise<void> {\n if (options.mode !== 'production') {\n const { createServer: createViteServer } = await import('vite');\n const vite = await createViteServer({\n configFile: options.configFile ?? resolve(process.cwd(), 'vite.config.ts'),\n root: options.root,\n server: {\n middlewareMode: true,\n hmr: { port: options.hmrPort ?? 24679 },\n },\n appType: 'custom',\n });\n app.use((vite as { middlewares: unknown }).middlewares);\n return;\n }\n\n // Production: serve dist/<outDir>/client\n const express = await import('express');\n const clientDir = resolve(process.cwd(), options.outDir, 'client');\n app.use(\n '/assets',\n (express.default ?? express).static(resolve(clientDir, 'assets'), {\n maxAge: '1y',\n immutable: true,\n }),\n );\n app.use(\n (express.default ?? express).static(clientDir, {\n maxAge: '1h',\n index: false,\n fallthrough: true,\n }),\n );\n}\n","import { createRequire } from 'node:module';\nimport { resolve } from 'node:path';\nimport type { Plugin, UserConfig } from 'vite';\n\nconst require = createRequire(import.meta.url);\n\nexport interface NestInertiaPluginOptions {\n ssr?: boolean;\n react?: boolean;\n vue?: boolean;\n svelte?: boolean;\n /**\n * When `true`, the nestInertia plugin will skip auto-loading the framework\n * Vite plugin. Use this when the framework plugin (e.g. @sveltejs/vite-plugin-svelte)\n * needs to be added manually in the vite config alongside nestInertia().\n *\n * @default false\n */\n skipFrameworkPlugin?: boolean;\n clientEntry?: string;\n ssrEntry?: string;\n alias?: Record<string, string>;\n root?: string;\n entry?: string;\n}\n\nexport class InvalidViteConfigException extends Error {\n constructor(message: string) {\n super(`[nestjs-inertia-vite] ${message}`);\n this.name = 'InvalidViteConfigException';\n }\n}\n\nfunction loadFrameworkPlugin(framework: 'react' | 'vue' | 'svelte'): Plugin {\n const pkg =\n framework === 'react'\n ? '@vitejs/plugin-react'\n : framework === 'vue'\n ? '@vitejs/plugin-vue'\n : '@sveltejs/vite-plugin-svelte';\n try {\n const mod = require(pkg) as { default?: () => Plugin; svelte?: () => Plugin };\n // @sveltejs/vite-plugin-svelte v3+ exports a named `svelte` export rather than default\n const factory =\n mod.default ??\n (framework === 'svelte' ? mod.svelte : undefined) ??\n (mod as unknown as () => Plugin);\n return (factory as () => Plugin)();\n } catch {\n throw new InvalidViteConfigException(`Plugin \"${pkg}\" not installed. Run: pnpm add ${pkg}`);\n }\n}\n\nexport default function nestInertia(options: NestInertiaPluginOptions = {}): Plugin[] {\n const frameworkFlags = [options.react, options.vue, options.svelte].filter(Boolean);\n if (frameworkFlags.length !== 1) {\n throw new InvalidViteConfigException(\n 'nestInertia requires exactly one framework flag: react, vue, or svelte',\n );\n }\n\n const defaultRoot = 'inertia';\n const alias = {\n '@': resolve(process.cwd(), options.root ?? defaultRoot),\n ...(options.alias ?? {}),\n };\n\n const configurer: Plugin = {\n name: 'nestjs-inertia',\n config: (userConfig: UserConfig): Omit<UserConfig, 'plugins'> => {\n const resolvedRoot = options.root ?? defaultRoot;\n const defaultEntry = options.entry ?? options.clientEntry ?? `${resolvedRoot}/app/client.tsx`;\n\n const buildConfig: NonNullable<UserConfig['build']> = {\n manifest: true,\n rollupOptions: {},\n };\n\n // Only set outDir if the user hasn't already defined it\n if (!userConfig.build?.outDir) {\n buildConfig.outDir = 'dist/inertia/client';\n }\n\n // Only set rollupOptions.input if the user hasn't already defined it\n if (!userConfig.build?.rollupOptions?.input) {\n buildConfig.rollupOptions = {\n input: resolve(process.cwd(), defaultEntry),\n };\n }\n\n const result: Omit<UserConfig, 'plugins'> = {\n build: buildConfig,\n resolve: { alias },\n server: {\n middlewareMode: true,\n hmr: { port: 24679 },\n },\n };\n\n // Only set root if the user hasn't already defined it in their vite config\n if (!userConfig.root) {\n result.root = resolve(process.cwd(), resolvedRoot);\n }\n\n return result;\n },\n };\n\n const codegenHmr: Plugin = {\n name: 'nestjs-inertia:codegen-hmr',\n configureServer(server) {\n const codegenDir = resolve(process.cwd(), '.nestjs-inertia');\n const { watcher } = server;\n watcher.add(codegenDir);\n watcher.on('change', (file) => {\n if (!file.startsWith(codegenDir)) return;\n const mods = server.moduleGraph.getModulesByFile(file);\n if (mods) {\n for (const mod of mods) {\n server.moduleGraph.invalidateModule(mod);\n }\n }\n server.ws.send({ type: 'full-reload' });\n });\n },\n };\n\n if (options.skipFrameworkPlugin) {\n return [configurer, codegenHmr];\n }\n\n const frameworkPlugin = options.react\n ? loadFrameworkPlugin('react')\n : options.vue\n ? loadFrameworkPlugin('vue')\n : loadFrameworkPlugin('svelte');\n\n return [configurer, frameworkPlugin, codegenHmr];\n}\n","export const VERSION = '1.4.3';\nexport { setupInertiaVite } from './setup.js';\nexport type { SetupInertiaViteOptions } from './setup.js';\nexport { default as nestInertia } from './plugin/plugin.js';\nexport type { NestInertiaPluginOptions } from './plugin/plugin.js';\nexport { InvalidViteConfigException } from './plugin/plugin.js';\n"],"mappings":";;;;AAAA,SAASA,eAAe;AAexB,eAAsBC,iBACpBC,KACAC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IAAKP;AACpBO,cAAQC,IAAIF,UAAAA;AACZC,cAAQE,GAAG,UAAU,CAACC,SAAAA;AACpB,YAAI,CAACA,KAAKC,WAAWL,UAAAA,EAAa;AAClC,cAAMM,OAAOZ,OAAOa,YAAYC,iBAAiBJ,IAAAA;AACjD,YAAIE,MAAM;AACR,qBAAW5C,OAAO4C,MAAM;AACtBZ,mBAAOa,YAAYE,iBAAiB/C,GAAAA;UACtC;QACF;AACAgC,eAAOgB,GAAGC,KAAK;UAAEC,MAAM;QAAc,CAAA;MACvC,CAAA;IACF;EACF;AAEA,MAAI7C,QAAQ8C,qBAAqB;AAC/B,WAAO;MAACjC;MAAYkB;;EACtB;AAEA,QAAMgB,kBAAkB/C,QAAQE,QAC5BV,oBAAoB,OAAA,IACpBQ,QAAQG,MACNX,oBAAoB,KAAA,IACpBA,oBAAoB,QAAA;AAE1B,SAAO;IAACqB;IAAYkC;IAAiBhB;;AACvC;AArFwBiB;;;ACrDjB,IAAMC,UAAU;","names":["resolve","setupInertiaVite","app","options","mode","createServer","createViteServer","vite","configFile","resolve","process","cwd","root","server","middlewareMode","hmr","port","hmrPort","appType","use","middlewares","express","clientDir","outDir","default","static","maxAge","immutable","index","fallthrough","createRequire","resolve","require","createRequire","url","InvalidViteConfigException","Error","message","name","loadFrameworkPlugin","framework","pkg","mod","factory","default","svelte","undefined","options","frameworkFlags","react","vue","filter","Boolean","length","defaultRoot","alias","resolve","process","cwd","root","configurer","config","userConfig","resolvedRoot","defaultEntry","entry","clientEntry","buildConfig","manifest","rollupOptions","build","outDir","input","result","server","middlewareMode","hmr","port","codegenHmr","configureServer","codegenDir","watcher","add","on","file","startsWith","mods","moduleGraph","getModulesByFile","invalidateModule","ws","send","type","skipFrameworkPlugin","frameworkPlugin","nestInertia","VERSION"]}
|
|
1
|
+
{"version":3,"sources":["../src/setup.ts","../src/plugin/plugin.ts","../src/index.ts"],"sourcesContent":["import { resolve } from 'node:path';\n\nexport interface SetupInertiaViteOptions {\n mode: string | undefined;\n root: string;\n publicDir: string;\n outDir: string;\n hmrPort?: number;\n configFile?: string;\n}\n\ntype NestApp = {\n use: (pathOrMiddleware: unknown, middleware?: unknown) => void;\n};\n\nexport async function setupInertiaVite(\n app: NestApp,\n options: SetupInertiaViteOptions,\n): Promise<void> {\n if (options.mode !== 'production') {\n const { createServer: createViteServer } = await import('vite');\n const vite = await createViteServer({\n configFile: options.configFile ?? resolve(process.cwd(), 'vite.config.ts'),\n root: options.root,\n server: {\n middlewareMode: true,\n hmr: { port: options.hmrPort ?? 24679 },\n },\n appType: 'custom',\n });\n app.use((vite as { middlewares: unknown }).middlewares);\n return;\n }\n\n // Production: serve dist/<outDir>/client\n const express = await import('express');\n const clientDir = resolve(process.cwd(), options.outDir, 'client');\n app.use(\n '/assets',\n (express.default ?? express).static(resolve(clientDir, 'assets'), {\n maxAge: '1y',\n immutable: true,\n }),\n );\n app.use(\n (express.default ?? express).static(clientDir, {\n maxAge: '1h',\n index: false,\n fallthrough: true,\n }),\n );\n}\n","import { createRequire } from 'node:module';\nimport { resolve } from 'node:path';\nimport type { Plugin, UserConfig } from 'vite';\n\nconst require = createRequire(import.meta.url);\n\nexport interface NestInertiaPluginOptions {\n ssr?: boolean;\n react?: boolean;\n vue?: boolean;\n svelte?: boolean;\n /**\n * When `true`, the nestInertia plugin will skip auto-loading the framework\n * Vite plugin. Use this when the framework plugin (e.g. @sveltejs/vite-plugin-svelte)\n * needs to be added manually in the vite config alongside nestInertia().\n *\n * @default false\n */\n skipFrameworkPlugin?: boolean;\n clientEntry?: string;\n ssrEntry?: string;\n alias?: Record<string, string>;\n root?: string;\n entry?: string;\n}\n\nexport class InvalidViteConfigException extends Error {\n constructor(message: string) {\n super(`[nestjs-inertia-vite] ${message}`);\n this.name = 'InvalidViteConfigException';\n }\n}\n\nfunction loadFrameworkPlugin(framework: 'react' | 'vue' | 'svelte'): Plugin {\n const pkg =\n framework === 'react'\n ? '@vitejs/plugin-react'\n : framework === 'vue'\n ? '@vitejs/plugin-vue'\n : '@sveltejs/vite-plugin-svelte';\n try {\n const mod = require(pkg) as { default?: () => Plugin; svelte?: () => Plugin };\n // @sveltejs/vite-plugin-svelte v3+ exports a named `svelte` export rather than default\n const factory =\n mod.default ??\n (framework === 'svelte' ? mod.svelte : undefined) ??\n (mod as unknown as () => Plugin);\n return (factory as () => Plugin)();\n } catch {\n throw new InvalidViteConfigException(`Plugin \"${pkg}\" not installed. Run: pnpm add ${pkg}`);\n }\n}\n\nexport default function nestInertia(options: NestInertiaPluginOptions = {}): Plugin[] {\n const frameworkFlags = [options.react, options.vue, options.svelte].filter(Boolean);\n if (frameworkFlags.length !== 1) {\n throw new InvalidViteConfigException(\n 'nestInertia requires exactly one framework flag: react, vue, or svelte',\n );\n }\n\n const defaultRoot = 'inertia';\n const alias = {\n '@': resolve(process.cwd(), options.root ?? defaultRoot),\n ...(options.alias ?? {}),\n };\n\n const configurer: Plugin = {\n name: 'nestjs-inertia',\n config: (userConfig: UserConfig): Omit<UserConfig, 'plugins'> => {\n const resolvedRoot = options.root ?? defaultRoot;\n const defaultEntry = options.entry ?? options.clientEntry ?? `${resolvedRoot}/app/client.tsx`;\n\n const buildConfig: NonNullable<UserConfig['build']> = {\n manifest: true,\n rollupOptions: {},\n };\n\n // Only set outDir if the user hasn't already defined it\n if (!userConfig.build?.outDir) {\n buildConfig.outDir = 'dist/inertia/client';\n }\n\n // Only set rollupOptions.input if the user hasn't already defined it\n if (!userConfig.build?.rollupOptions?.input) {\n buildConfig.rollupOptions = {\n input: resolve(process.cwd(), defaultEntry),\n };\n }\n\n const result: Omit<UserConfig, 'plugins'> = {\n build: buildConfig,\n resolve: { alias },\n server: {\n middlewareMode: true,\n hmr: { port: 24679 },\n },\n };\n\n // Only set root if the user hasn't already defined it in their vite config\n if (!userConfig.root) {\n result.root = resolve(process.cwd(), resolvedRoot);\n }\n\n return result;\n },\n };\n\n const codegenHmr: Plugin = {\n name: 'nestjs-inertia:codegen-hmr',\n configureServer(server) {\n const codegenDir = resolve(process.cwd(), '.nestjs-inertia');\n const { watcher } = server;\n watcher.add(codegenDir);\n watcher.on('change', (file) => {\n if (!file.startsWith(codegenDir)) return;\n const mods = server.moduleGraph.getModulesByFile(file);\n if (mods) {\n for (const mod of mods) {\n server.moduleGraph.invalidateModule(mod);\n }\n }\n server.ws.send({ type: 'full-reload' });\n });\n },\n };\n\n if (options.skipFrameworkPlugin) {\n return [configurer, codegenHmr];\n }\n\n const frameworkPlugin = options.react\n ? loadFrameworkPlugin('react')\n : options.vue\n ? loadFrameworkPlugin('vue')\n : loadFrameworkPlugin('svelte');\n\n return [configurer, frameworkPlugin, codegenHmr];\n}\n","export const VERSION = '1.5.0';\nexport { setupInertiaVite } from './setup.js';\nexport type { SetupInertiaViteOptions } from './setup.js';\nexport { default as nestInertia } from './plugin/plugin.js';\nexport type { NestInertiaPluginOptions } from './plugin/plugin.js';\nexport { InvalidViteConfigException } from './plugin/plugin.js';\n"],"mappings":";;;;AAAA,SAASA,eAAe;AAexB,eAAsBC,iBACpBC,KACAC,SAAgC;AAEhC,MAAIA,QAAQC,SAAS,cAAc;AACjC,UAAM,EAAEC,cAAcC,iBAAgB,IAAK,MAAM,OAAO,MAAA;AACxD,UAAMC,OAAO,MAAMD,iBAAiB;MAClCE,YAAYL,QAAQK,cAAcC,QAAQC,QAAQC,IAAG,GAAI,gBAAA;MACzDC,MAAMT,QAAQS;MACdC,QAAQ;QACNC,gBAAgB;QAChBC,KAAK;UAAEC,MAAMb,QAAQc,WAAW;QAAM;MACxC;MACAC,SAAS;IACX,CAAA;AACAhB,QAAIiB,IAAKZ,KAAkCa,WAAW;AACtD;EACF;AAGA,QAAMC,UAAU,MAAM,OAAO,SAAA;AAC7B,QAAMC,YAAYb,QAAQC,QAAQC,IAAG,GAAIR,QAAQoB,QAAQ,QAAA;AACzDrB,MAAIiB,IACF,YACCE,QAAQG,WAAWH,SAASI,OAAOhB,QAAQa,WAAW,QAAA,GAAW;IAChEI,QAAQ;IACRC,WAAW;E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ACrDjB,IAAMC,UAAU;","names":["resolve","setupInertiaVite","app","options","mode","createServer","createViteServer","vite","configFile","resolve","process","cwd","root","server","middlewareMode","hmr","port","hmrPort","appType","use","middlewares","express","clientDir","outDir","default","static","maxAge","immutable","index","fallthrough","createRequire","resolve","require","createRequire","url","InvalidViteConfigException","Error","message","name","loadFrameworkPlugin","framework","pkg","mod","factory","default","svelte","undefined","options","frameworkFlags","react","vue","filter","Boolean","length","defaultRoot","alias","resolve","process","cwd","root","configurer","config","userConfig","resolvedRoot","defaultEntry","entry","clientEntry","buildConfig","manifest","rollupOptions","build","outDir","input","result","server","middlewareMode","hmr","port","codegenHmr","configureServer","codegenDir","watcher","add","on","file","startsWith","mods","moduleGraph","getModulesByFile","invalidateModule","ws","send","type","skipFrameworkPlugin","frameworkPlugin","nestInertia","VERSION"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Plugin } from 'vite';
|
|
2
|
+
|
|
3
|
+
interface NestInertiaPluginOptions {
|
|
4
|
+
ssr?: boolean;
|
|
5
|
+
react?: boolean;
|
|
6
|
+
vue?: boolean;
|
|
7
|
+
svelte?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* When `true`, the nestInertia plugin will skip auto-loading the framework
|
|
10
|
+
* Vite plugin. Use this when the framework plugin (e.g. @sveltejs/vite-plugin-svelte)
|
|
11
|
+
* needs to be added manually in the vite config alongside nestInertia().
|
|
12
|
+
*
|
|
13
|
+
* @default false
|
|
14
|
+
*/
|
|
15
|
+
skipFrameworkPlugin?: boolean;
|
|
16
|
+
clientEntry?: string;
|
|
17
|
+
ssrEntry?: string;
|
|
18
|
+
alias?: Record<string, string>;
|
|
19
|
+
root?: string;
|
|
20
|
+
entry?: string;
|
|
21
|
+
}
|
|
22
|
+
declare class InvalidViteConfigException extends Error {
|
|
23
|
+
constructor(message: string);
|
|
24
|
+
}
|
|
25
|
+
declare function nestInertia(options?: NestInertiaPluginOptions): Plugin[];
|
|
26
|
+
|
|
27
|
+
export { InvalidViteConfigException, type NestInertiaPluginOptions, nestInertia as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dudousxd/nestjs-inertia-vite",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Vite integration for @dudousxd/nestjs-inertia — dev middleware, prod static serving, plugin.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -15,23 +15,34 @@
|
|
|
15
15
|
"types": "./dist/index.d.ts",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
"import": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"default": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"require": {
|
|
23
|
+
"types": "./dist/index.d.cts",
|
|
24
|
+
"default": "./dist/index.cjs"
|
|
25
|
+
}
|
|
21
26
|
},
|
|
22
27
|
"./plugin": {
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
"import": {
|
|
29
|
+
"types": "./dist/plugin/plugin.d.ts",
|
|
30
|
+
"default": "./dist/plugin/plugin.js"
|
|
31
|
+
},
|
|
32
|
+
"require": {
|
|
33
|
+
"types": "./dist/plugin/plugin.d.cts",
|
|
34
|
+
"default": "./dist/plugin/plugin.cjs"
|
|
35
|
+
}
|
|
26
36
|
}
|
|
27
37
|
},
|
|
38
|
+
"sideEffects": false,
|
|
28
39
|
"files": [
|
|
29
40
|
"dist/",
|
|
30
41
|
"README.md",
|
|
31
42
|
"CHANGELOG.md"
|
|
32
43
|
],
|
|
33
44
|
"peerDependencies": {
|
|
34
|
-
"@dudousxd/nestjs-inertia": ">=1.4.
|
|
45
|
+
"@dudousxd/nestjs-inertia": ">=1.4.5",
|
|
35
46
|
"@nestjs/common": ">=10.0.0",
|
|
36
47
|
"@nestjs/core": ">=10.0.0",
|
|
37
48
|
"vite": ">=5.0.0",
|
|
@@ -58,9 +69,9 @@
|
|
|
58
69
|
"@vitejs/plugin-react": "^4.3.0",
|
|
59
70
|
"express": "^4.19.2",
|
|
60
71
|
"typescript": "^5.4.0",
|
|
61
|
-
"vite": "^
|
|
62
|
-
"vitest": "^
|
|
63
|
-
"@dudousxd/nestjs-inertia": "1.
|
|
72
|
+
"vite": "^7.0.0",
|
|
73
|
+
"vitest": "^4.1.0",
|
|
74
|
+
"@dudousxd/nestjs-inertia": "1.7.0"
|
|
64
75
|
},
|
|
65
76
|
"engines": {
|
|
66
77
|
"node": ">=20"
|