@adonisjs/inertia 4.2.0 → 5.0.0-next.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/build/{define_config-Du2hAFGX.js → define_config-Dv9Dx2Yq.js} +0 -1
- package/build/factories/main.js +2 -2
- package/build/index.js +2 -2
- package/build/{inertia_manager-BGHA4cDP.js → inertia_manager-BdcjpKFf.js} +13 -29
- package/build/providers/inertia_provider.js +1 -1
- package/build/src/client/react/context.d.ts +1 -1
- package/build/src/client/react/form.d.ts +1 -1
- package/build/src/client/react/link.d.ts +1 -1
- package/build/src/define_config.d.ts +1 -1
- package/build/src/inertia_middleware.js +1 -1
- package/build/src/plugins/edge/plugin.js +2 -3
- package/build/src/server_renderer.d.ts +4 -28
- package/build/src/types.d.ts +7 -7
- package/build/tests/helpers.d.ts +26 -0
- package/build/tests/v3_client_contract.spec.d.ts +1 -0
- package/package.json +8 -9
- package/build/src/client/vite.d.ts +0 -65
- package/build/src/client/vite.js +0 -21
package/build/factories/main.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { n as ServerRenderer, r as Inertia } from "../inertia_manager-
|
|
1
|
+
import { n as ServerRenderer, r as Inertia } from "../inertia_manager-BdcjpKFf.js";
|
|
2
2
|
import { t as InertiaHeaders } from "../headers-DafWEpBh.js";
|
|
3
3
|
import "../debug-CBMTuPUm.js";
|
|
4
|
-
import { t as defineConfig } from "../define_config-
|
|
4
|
+
import { t as defineConfig } from "../define_config-Dv9Dx2Yq.js";
|
|
5
5
|
import "../index.js";
|
|
6
6
|
import { HttpContextFactory } from "@adonisjs/core/factories/http";
|
|
7
7
|
var InertiaFactory = class {
|
package/build/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as symbols_exports, n as ServerRenderer, r as Inertia, t as InertiaManager } from "./inertia_manager-
|
|
1
|
+
import { i as symbols_exports, n as ServerRenderer, r as Inertia, t as InertiaManager } from "./inertia_manager-BdcjpKFf.js";
|
|
2
2
|
import { t as InertiaHeaders } from "./headers-DafWEpBh.js";
|
|
3
3
|
import "./debug-CBMTuPUm.js";
|
|
4
|
-
import { n as indexPages, t as defineConfig } from "./define_config-
|
|
4
|
+
import { n as indexPages, t as defineConfig } from "./define_config-Dv9Dx2Yq.js";
|
|
5
5
|
export { Inertia, InertiaHeaders, InertiaManager, ServerRenderer, defineConfig, indexPages, symbols_exports as symbols };
|
|
@@ -3,7 +3,6 @@ import { t as debug_default } from "./debug-CBMTuPUm.js";
|
|
|
3
3
|
import "node:module";
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
5
5
|
import { BaseSerializer } from "@adonisjs/core/transformers";
|
|
6
|
-
import { pathToFileURL } from "node:url";
|
|
7
6
|
var __defProp = Object.defineProperty;
|
|
8
7
|
var __exportAll = (all, no_symbols) => {
|
|
9
8
|
let target = {};
|
|
@@ -43,6 +42,9 @@ function defer(fn, group = "default") {
|
|
|
43
42
|
merge() {
|
|
44
43
|
return merge(this);
|
|
45
44
|
},
|
|
45
|
+
deepMerge() {
|
|
46
|
+
return deepMerge(this);
|
|
47
|
+
},
|
|
46
48
|
[DEFERRED_PROP]: true
|
|
47
49
|
};
|
|
48
50
|
}
|
|
@@ -85,6 +87,7 @@ function isOptionalProp(propValue) {
|
|
|
85
87
|
return OPTIONAL_PROP in propValue;
|
|
86
88
|
}
|
|
87
89
|
async function unpackPropValue(value, containerResolver) {
|
|
90
|
+
if (value === null) return null;
|
|
88
91
|
return inertiaSerializer.serialize(value, containerResolver);
|
|
89
92
|
}
|
|
90
93
|
async function buildStandardVisitProps(pageProps, containerResolver) {
|
|
@@ -113,11 +116,9 @@ async function buildStandardVisitProps(pageProps, containerResolver) {
|
|
|
113
116
|
if (isObject(value.value) && isDeferredProp(value.value)) {
|
|
114
117
|
deferredProps[value.value.group] = deferredProps[value.value.group] ?? [];
|
|
115
118
|
deferredProps[value.value.group].push(key);
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
});
|
|
120
|
-
} else unpackedValues.push({
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
unpackedValues.push({
|
|
121
122
|
key,
|
|
122
123
|
value: value.value
|
|
123
124
|
});
|
|
@@ -337,17 +338,18 @@ var Inertia = class {
|
|
|
337
338
|
async page(page, pageProps) {
|
|
338
339
|
const requestInfo = this.requestInfo();
|
|
339
340
|
const { props, mergeProps, deferredProps, deepMergeProps } = await this.#buildPageProps(page, requestInfo, pageProps);
|
|
340
|
-
|
|
341
|
+
const pageObject = {
|
|
341
342
|
component: page,
|
|
342
343
|
url: this.ctx.request.url(true),
|
|
343
344
|
version: this.getVersion(),
|
|
344
|
-
clearHistory: this.#shouldClearHistory,
|
|
345
|
-
encryptHistory: this.#shouldEncryptHistory,
|
|
346
345
|
props,
|
|
347
346
|
deferredProps,
|
|
348
347
|
mergeProps,
|
|
349
348
|
deepMergeProps
|
|
350
349
|
};
|
|
350
|
+
if (this.#shouldClearHistory) pageObject.clearHistory = true;
|
|
351
|
+
if (this.#shouldEncryptHistory) pageObject.encryptHistory = true;
|
|
352
|
+
return pageObject;
|
|
351
353
|
}
|
|
352
354
|
async render(page, pageProps, viewProps) {
|
|
353
355
|
const requestInfo = this.requestInfo();
|
|
@@ -368,8 +370,6 @@ var Inertia = class {
|
|
|
368
370
|
}
|
|
369
371
|
};
|
|
370
372
|
var ServerRenderer = class {
|
|
371
|
-
#runtime;
|
|
372
|
-
#ssrEnvironment;
|
|
373
373
|
#config;
|
|
374
374
|
#vite;
|
|
375
375
|
constructor(config, vite) {
|
|
@@ -377,24 +377,8 @@ var ServerRenderer = class {
|
|
|
377
377
|
this.#vite = vite;
|
|
378
378
|
}
|
|
379
379
|
async render(pageObject) {
|
|
380
|
-
|
|
381
|
-
const
|
|
382
|
-
if (devServer) {
|
|
383
|
-
debug_default("creating SSR bundle using dev-server");
|
|
384
|
-
const currentSsrEnv = devServer.environments.ssr;
|
|
385
|
-
if (this.#ssrEnvironment !== currentSsrEnv) {
|
|
386
|
-
if (this.#runtime) await this.#runtime.close();
|
|
387
|
-
this.#runtime = void 0;
|
|
388
|
-
this.#ssrEnvironment = currentSsrEnv;
|
|
389
|
-
}
|
|
390
|
-
this.#runtime ??= await this.#vite.createModuleRunner();
|
|
391
|
-
this.#runtime.clearCache();
|
|
392
|
-
render = await this.#runtime.import(this.#config.ssr.entrypoint);
|
|
393
|
-
} else {
|
|
394
|
-
debug_default("creating SSR bundle using production build");
|
|
395
|
-
render = await import(pathToFileURL(this.#config.ssr.bundle).href);
|
|
396
|
-
}
|
|
397
|
-
const result = await render.default(pageObject);
|
|
380
|
+
debug_default("rendering page through SSR entrypoint %s", this.#config.ssr.entrypoint);
|
|
381
|
+
const result = await (await this.#vite.loadServerModule(this.#config.ssr.entrypoint)).default(pageObject);
|
|
398
382
|
debug_default("SSR bundle %o", result);
|
|
399
383
|
return {
|
|
400
384
|
head: result.head,
|
|
@@ -11,7 +11,7 @@ import type { TuyauRegistry } from '@tuyau/core/types';
|
|
|
11
11
|
export declare function TuyauProvider<R extends TuyauRegistry>(props: {
|
|
12
12
|
children: React.ReactNode;
|
|
13
13
|
client: Tuyau<R>;
|
|
14
|
-
}):
|
|
14
|
+
}): React.JSX.Element;
|
|
15
15
|
/**
|
|
16
16
|
* Hook to access the Tuyau client from any component within a TuyauProvider.
|
|
17
17
|
*
|
|
@@ -27,7 +27,7 @@ export type FormProps<Route extends keyof Routes = keyof Routes> = FormRouteProp
|
|
|
27
27
|
* for Inertia form submission when using route-based navigation.
|
|
28
28
|
* Falls back to standard InertiaForm when action is provided directly.
|
|
29
29
|
*/
|
|
30
|
-
declare function FormInner<Route extends keyof Routes>(props: FormProps<Route>, ref?: React.ForwardedRef<React.ElementRef<typeof InertiaForm>>):
|
|
30
|
+
declare function FormInner<Route extends keyof Routes>(props: FormProps<Route>, ref?: React.ForwardedRef<React.ElementRef<typeof InertiaForm>>): React.JSX.Element;
|
|
31
31
|
/**
|
|
32
32
|
* Type-safe Form component for Inertia.js form submissions.
|
|
33
33
|
*
|
|
@@ -30,7 +30,7 @@ export type LinkProps<Route extends keyof Routes = keyof Routes> = LinkRouteProp
|
|
|
30
30
|
* @param props - Link properties including route and parameters, or direct href
|
|
31
31
|
* @param ref - Forward ref for the underlying InertiaLink component
|
|
32
32
|
*/
|
|
33
|
-
declare function LinkInner<Route extends keyof Routes>(props: LinkProps<Route>, ref?: React.ForwardedRef<React.ElementRef<typeof InertiaLink>>):
|
|
33
|
+
declare function LinkInner<Route extends keyof Routes>(props: LinkProps<Route>, ref?: React.ForwardedRef<React.ElementRef<typeof InertiaLink>>): React.JSX.Element;
|
|
34
34
|
/**
|
|
35
35
|
* Type-safe Link component for Inertia.js navigation.
|
|
36
36
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as InertiaManager } from "../inertia_manager-
|
|
1
|
+
import { t as InertiaManager } from "../inertia_manager-BdcjpKFf.js";
|
|
2
2
|
import { t as InertiaHeaders } from "../headers-DafWEpBh.js";
|
|
3
3
|
import { t as debug_default } from "../debug-CBMTuPUm.js";
|
|
4
4
|
const MUTATION_METHODS = [
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { t as debug_default } from "../../../debug-CBMTuPUm.js";
|
|
2
|
-
import { encode } from "html-entities";
|
|
3
2
|
import { EdgeError } from "edge-error";
|
|
4
3
|
function isSubsetOf(expression, expressions, errorCallback) {
|
|
5
4
|
if (!expressions.includes(expression.type)) errorCallback();
|
|
@@ -41,9 +40,9 @@ const edgePluginInertia = () => {
|
|
|
41
40
|
edge.global("inertia", (page = {}, attributes = {}) => {
|
|
42
41
|
if (page.ssrBody) return page.ssrBody;
|
|
43
42
|
const className = attributes?.class ? ` class="${attributes.class}"` : "";
|
|
44
|
-
const id = attributes?.id
|
|
43
|
+
const id = attributes?.id || "app";
|
|
45
44
|
const tag = attributes?.as || "div";
|
|
46
|
-
return
|
|
45
|
+
return `<script data-page="${id}" type="application/json">${JSON.stringify(page).replace(/\//g, "\\/")}<\/script><${tag} id="${id}"${className}></${tag}>`;
|
|
47
46
|
});
|
|
48
47
|
edge.global("inertiaHead", (page) => {
|
|
49
48
|
const { ssrHead = [] } = page || {};
|
|
@@ -3,8 +3,10 @@ import type { PageObject, InertiaConfig } from './types.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* Server-side renderer for Inertia.js applications.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* Resolves the SSR entrypoint through `vite.loadServerModule` so the same
|
|
7
|
+
* code path works in dev (Vite module runner) and in production (pre-built
|
|
8
|
+
* SSR bundle on disk). The entry must be declared under `serverEntrypoints`
|
|
9
|
+
* on the AdonisJS Vite plugin so it gets bundled for production.
|
|
8
10
|
*
|
|
9
11
|
* @example
|
|
10
12
|
* ```typescript
|
|
@@ -14,38 +16,12 @@ import type { PageObject, InertiaConfig } from './types.js';
|
|
|
14
16
|
*/
|
|
15
17
|
export declare class ServerRenderer {
|
|
16
18
|
#private;
|
|
17
|
-
/**
|
|
18
|
-
* Creates a new ServerRenderer instance.
|
|
19
|
-
*
|
|
20
|
-
* @param config - Inertia configuration object containing SSR settings
|
|
21
|
-
* @param vite - Vite instance for development mode rendering and asset management
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```js
|
|
25
|
-
* const renderer = new ServerRenderer(config, vite)
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
19
|
constructor(config: InertiaConfig, vite: Vite);
|
|
29
20
|
/**
|
|
30
21
|
* Renders an Inertia page on the server.
|
|
31
22
|
*
|
|
32
|
-
* In development mode, uses Vite's Runtime API to execute the SSR entrypoint.
|
|
33
|
-
* In production mode, imports and uses the pre-built SSR bundle.
|
|
34
|
-
*
|
|
35
23
|
* @param pageObject - The Inertia page object containing component, props, and metadata
|
|
36
24
|
* @returns Promise resolving to an object with rendered head and body HTML
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* ```js
|
|
40
|
-
* const pageObject = {
|
|
41
|
-
* component: 'Home',
|
|
42
|
-
* props: { user: { name: 'John' } },
|
|
43
|
-
* url: '/dashboard',
|
|
44
|
-
* version: '1.0.0'
|
|
45
|
-
* }
|
|
46
|
-
*
|
|
47
|
-
* const { head, body } = await renderer.render(pageObject)
|
|
48
|
-
* ```
|
|
49
25
|
*/
|
|
50
26
|
render(pageObject: PageObject<any>): Promise<{
|
|
51
27
|
head: string[];
|
package/build/src/types.d.ts
CHANGED
|
@@ -82,6 +82,8 @@ export type DeferProp<T extends UnPackedPageProps> = {
|
|
|
82
82
|
compute: () => AsyncOrSync<T>;
|
|
83
83
|
/** Creates a mergeable version of this deferred prop */
|
|
84
84
|
merge(): MergeableProp<DeferProp<T>>;
|
|
85
|
+
/** Creates a deep-mergeable version of this deferred prop */
|
|
86
|
+
deepMerge(): MergeableProp<DeferProp<T>>;
|
|
85
87
|
/** Brand symbol to identify this as a deferred prop */
|
|
86
88
|
[DEFERRED_PROP]: true;
|
|
87
89
|
};
|
|
@@ -258,15 +260,13 @@ export type InertiaConfig = {
|
|
|
258
260
|
*/
|
|
259
261
|
pages?: string[] | ((ctx: HttpContext, page: string) => AsyncOrSync<boolean>);
|
|
260
262
|
/**
|
|
261
|
-
* The entrypoint file
|
|
262
|
-
* the
|
|
263
|
+
* The entrypoint file that boots the frontend application on the server.
|
|
264
|
+
* Must also be declared under `serverEntrypoints` on the AdonisJS Vite
|
|
265
|
+
* plugin so it gets bundled for production. The value is passed to
|
|
266
|
+
* `vite.loadServerModule()` to evaluate the module in dev and import
|
|
267
|
+
* the bundle in production.
|
|
263
268
|
*/
|
|
264
269
|
entrypoint: string;
|
|
265
|
-
/**
|
|
266
|
-
* The SSR bundle output to load during production. This bundle is created
|
|
267
|
-
* using Vite
|
|
268
|
-
*/
|
|
269
|
-
bundle: string;
|
|
270
270
|
};
|
|
271
271
|
};
|
|
272
272
|
/**
|
package/build/tests/helpers.d.ts
CHANGED
|
@@ -32,4 +32,30 @@ export declare function setupApp(providers?: ProviderNode[]): Promise<{
|
|
|
32
32
|
app: ApplicationService;
|
|
33
33
|
ignitor: import("@adonisjs/core").Ignitor;
|
|
34
34
|
}>;
|
|
35
|
+
/**
|
|
36
|
+
* Minimal, faithful DOM shim that implements just enough of
|
|
37
|
+
* `document.querySelector` for the real `@inertiajs/core` `getInitialPageFromDOM`
|
|
38
|
+
* helper to run against a server-rendered HTML string.
|
|
39
|
+
*
|
|
40
|
+
* It parses every `<script>...</script>` block out of the markup and matches
|
|
41
|
+
* the `script[attr="value"]...` selector the v3 client builds. The regex stops
|
|
42
|
+
* at the first *unescaped* `</script>`, which is exactly the boundary the
|
|
43
|
+
* browser's HTML parser uses — so an escaped `<\/script>` inside the JSON
|
|
44
|
+
* payload does not terminate the element early.
|
|
45
|
+
*/
|
|
46
|
+
export declare function createDocumentFrom(html: string): {
|
|
47
|
+
querySelector(selector: string): {
|
|
48
|
+
attributes: Record<string, string>;
|
|
49
|
+
textContent: string;
|
|
50
|
+
} | null;
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Render a page object the way an application root view does, through the real
|
|
54
|
+
* `@inertia()` Edge global, then hand the resulting markup to the real v3
|
|
55
|
+
* client helper and return whatever it reconstructs.
|
|
56
|
+
*/
|
|
57
|
+
export declare function roundTripThroughClient(page: Record<string, any>, attributes?: Record<string, any>): Promise<{
|
|
58
|
+
html: string;
|
|
59
|
+
page: any;
|
|
60
|
+
}>;
|
|
35
61
|
export declare const setupFakeAdonisProject: () => Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adonisjs/inertia",
|
|
3
3
|
"description": "Official Inertia.js adapter for AdonisJS",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "5.0.0-next.0",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=24.0.0"
|
|
7
7
|
},
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
"./inertia_provider": "./build/providers/inertia_provider.js",
|
|
18
18
|
"./plugins/edge": "./build/src/plugins/edge/plugin.js",
|
|
19
19
|
"./plugins/api_client": "./build/src/plugins/japa/api_client.js",
|
|
20
|
-
"./vite": "./build/src/client/vite.js",
|
|
21
20
|
"./helpers": "./build/src/client/helpers.js",
|
|
22
21
|
"./react": "./build/src/client/react/index.js",
|
|
23
22
|
"./vue": "./build/src/client/vue/index.js",
|
|
@@ -52,9 +51,9 @@
|
|
|
52
51
|
"@adonisjs/prettier-config": "^1.4.5",
|
|
53
52
|
"@adonisjs/session": "^8.0.0",
|
|
54
53
|
"@adonisjs/tsconfig": "^2.0.0",
|
|
55
|
-
"@adonisjs/vite": "^
|
|
56
|
-
"@inertiajs/react": "^
|
|
57
|
-
"@inertiajs/vue3": "^
|
|
54
|
+
"@adonisjs/vite": "^6.0.0-next.0",
|
|
55
|
+
"@inertiajs/react": "^3.4.0",
|
|
56
|
+
"@inertiajs/vue3": "^3.4.0",
|
|
58
57
|
"@japa/api-client": "^3.2.1",
|
|
59
58
|
"@japa/assert": "4.2.0",
|
|
60
59
|
"@japa/expect-type": "^2.0.4",
|
|
@@ -81,7 +80,7 @@
|
|
|
81
80
|
"supertest": "^7.2.2",
|
|
82
81
|
"tsdown": "^0.20.3",
|
|
83
82
|
"typescript": "~5.9.3",
|
|
84
|
-
"vite": "^
|
|
83
|
+
"vite": "^8.0.0",
|
|
85
84
|
"vue": "^3.5.29"
|
|
86
85
|
},
|
|
87
86
|
"dependencies": {
|
|
@@ -93,9 +92,9 @@
|
|
|
93
92
|
"@adonisjs/assembler": "^8.0.0-next.29 || ^8.0.0",
|
|
94
93
|
"@adonisjs/core": "^7.0.0-next.23 || ^7.0.0",
|
|
95
94
|
"@adonisjs/session": "^8.0.0-next.2 || ^8.0.0",
|
|
96
|
-
"@adonisjs/vite": "^
|
|
97
|
-
"@inertiajs/react": "^
|
|
98
|
-
"@inertiajs/vue3": "^
|
|
95
|
+
"@adonisjs/vite": "^6.0.0-next.0 || ^6.0.0",
|
|
96
|
+
"@inertiajs/react": "^3.4.0",
|
|
97
|
+
"@inertiajs/vue3": "^3.4.0",
|
|
99
98
|
"@japa/api-client": "^3.1.1",
|
|
100
99
|
"@japa/plugin-adonisjs": "^5.1.0-next.1 || ^5.1.0",
|
|
101
100
|
"@tuyau/core": "^1.0.0-beta.10 || ^1.0.0",
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import type { PluginOption } from 'vite';
|
|
2
|
-
/**
|
|
3
|
-
* Configuration options for the Inertia Vite plugin
|
|
4
|
-
*/
|
|
5
|
-
export type InertiaPluginOptions = {
|
|
6
|
-
/**
|
|
7
|
-
* Server-side rendering configuration
|
|
8
|
-
*/
|
|
9
|
-
ssr?: {
|
|
10
|
-
/**
|
|
11
|
-
* Whether or not to enable server-side rendering
|
|
12
|
-
*/
|
|
13
|
-
enabled: true;
|
|
14
|
-
/**
|
|
15
|
-
* The entrypoint for the server-side rendering
|
|
16
|
-
*/
|
|
17
|
-
entrypoint: string;
|
|
18
|
-
/**
|
|
19
|
-
* The output directory for the server-side rendering bundle
|
|
20
|
-
*/
|
|
21
|
-
output?: string;
|
|
22
|
-
} | {
|
|
23
|
-
enabled: false;
|
|
24
|
-
entrypoint?: string;
|
|
25
|
-
output?: string;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Inertia plugin for Vite that is tailored for AdonisJS
|
|
30
|
-
*
|
|
31
|
-
* Configures Vite for Inertia.js development with proper build settings,
|
|
32
|
-
* SSR support, and AdonisJS-specific optimizations.
|
|
33
|
-
*
|
|
34
|
-
* @param options - Configuration options for the plugin
|
|
35
|
-
* @returns Vite plugin configuration object
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```js
|
|
39
|
-
* // Basic configuration
|
|
40
|
-
* import inertia from '@adonisjs/inertia/plugins/vite'
|
|
41
|
-
*
|
|
42
|
-
* export default defineConfig({
|
|
43
|
-
* plugins: [inertia()]
|
|
44
|
-
* })
|
|
45
|
-
* ```
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
* ```js
|
|
49
|
-
* // With SSR enabled
|
|
50
|
-
* import inertia from '@adonisjs/inertia/plugins/vite'
|
|
51
|
-
*
|
|
52
|
-
* export default defineConfig({
|
|
53
|
-
* plugins: [
|
|
54
|
-
* inertia({
|
|
55
|
-
* ssr: {
|
|
56
|
-
* enabled: true,
|
|
57
|
-
* entrypoint: 'inertia/ssr.tsx',
|
|
58
|
-
* output: 'build/ssr'
|
|
59
|
-
* }
|
|
60
|
-
* })
|
|
61
|
-
* ]
|
|
62
|
-
* })
|
|
63
|
-
* ```
|
|
64
|
-
*/
|
|
65
|
-
export default function inertia(options?: InertiaPluginOptions): PluginOption;
|
package/build/src/client/vite.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
function inertia(options) {
|
|
2
|
-
return {
|
|
3
|
-
name: "vite-plugin-inertia",
|
|
4
|
-
config: (_, { command }) => {
|
|
5
|
-
if (command === "build") process.env.NODE_ENV = "production";
|
|
6
|
-
return {
|
|
7
|
-
builder: { buildApp: async (builder) => {
|
|
8
|
-
await builder.build(builder.environments.client);
|
|
9
|
-
if (options?.ssr?.enabled) await builder.build(builder.environments.ssr);
|
|
10
|
-
} },
|
|
11
|
-
build: { outDir: "build/public/assets" },
|
|
12
|
-
environments: { ...options?.ssr?.enabled && { ssr: { build: {
|
|
13
|
-
ssr: true,
|
|
14
|
-
outDir: options.ssr.output || "build/ssr",
|
|
15
|
-
rollupOptions: { input: options.ssr.entrypoint }
|
|
16
|
-
} } } }
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
export { inertia as default };
|