@octanejs/vite-plugin 0.5.0 → 0.6.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.
- package/README.md +1 -1
- package/package.json +9 -4
- package/src/index.js +22 -13
- package/src/seeds.js +1 -0
- package/src/server/component-wrappers.js +1 -0
- package/src/server/html-stream.js +1 -1
- package/src/server/render-route.js +25 -2
- package/types/index.d.ts +9 -0
- package/types/seeds.d.ts +1 -0
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octanejs/vite-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -43,20 +43,25 @@
|
|
|
43
43
|
"types": "./types/node.d.ts",
|
|
44
44
|
"import": "./src/server/node-http.js",
|
|
45
45
|
"default": "./src/server/node-http.js"
|
|
46
|
+
},
|
|
47
|
+
"./seeds": {
|
|
48
|
+
"types": "./types/seeds.d.ts",
|
|
49
|
+
"import": "./src/seeds.js",
|
|
50
|
+
"default": "./src/seeds.js"
|
|
46
51
|
}
|
|
47
52
|
},
|
|
48
53
|
"dependencies": {
|
|
49
|
-
"@octanejs/app-core": "0.
|
|
54
|
+
"@octanejs/app-core": "0.3.1",
|
|
50
55
|
"@ripple-ts/adapter": "^0.4.0"
|
|
51
56
|
},
|
|
52
57
|
"peerDependencies": {
|
|
53
|
-
"octane": "^0.
|
|
58
|
+
"octane": "^0.18.0",
|
|
54
59
|
"vite": "^8.0.16"
|
|
55
60
|
},
|
|
56
61
|
"devDependencies": {
|
|
57
62
|
"@types/jsdom": "30.0.0",
|
|
58
63
|
"@types/node": "^24.13.3",
|
|
59
|
-
"octane": "0.
|
|
64
|
+
"octane": "0.18.0",
|
|
60
65
|
"playwright": "^1.61.1",
|
|
61
66
|
"playwright-webkit": "1.63.0",
|
|
62
67
|
"vite": "^8.1.5"
|
package/src/index.js
CHANGED
|
@@ -67,6 +67,7 @@ export {
|
|
|
67
67
|
handleRpcRequest,
|
|
68
68
|
handleServerRoute,
|
|
69
69
|
is_rpc_request,
|
|
70
|
+
routeSeed,
|
|
70
71
|
runMiddlewareChain,
|
|
71
72
|
} from '@octanejs/app-core';
|
|
72
73
|
export {
|
|
@@ -381,7 +382,7 @@ function createIslandsShellWarnings(server, projectRoot) {
|
|
|
381
382
|
|
|
382
383
|
/**
|
|
383
384
|
* Every module path the server can name in #__octane_data — page entries,
|
|
384
|
-
* layouts, the preHydrate hook, and root boundaries. The generated hydrate
|
|
385
|
+
* layouts, the preHydrate hook, the data module, and root boundaries. The generated hydrate
|
|
385
386
|
* entry maps each as a LITERAL `() => import('/src/…')`. Production needs the
|
|
386
387
|
* map so Rollup chunks and hashes the modules; dev needs it so the imports go
|
|
387
388
|
* through Vite's import analysis and share URL identity with every other
|
|
@@ -397,6 +398,7 @@ function collect_hydrate_module_paths(config) {
|
|
|
397
398
|
.filter((r) => r.type === 'render')
|
|
398
399
|
.flatMap((r) => [get_route_entry_path(/** @type {RenderRoute} */ (r).entry), r.layout]);
|
|
399
400
|
if (cfg.router.preHydrate) entries.push(cfg.router.preHydrate);
|
|
401
|
+
if (cfg.data) entries.push(cfg.data);
|
|
400
402
|
entries.push(
|
|
401
403
|
get_route_entry_path(cfg.rootBoundary.pending),
|
|
402
404
|
get_route_entry_path(cfg.rootBoundary.catch),
|
|
@@ -449,8 +451,10 @@ async function hydrate_entry_features(context, config, entries, clientBuild, pro
|
|
|
449
451
|
rootBoundary,
|
|
450
452
|
independentHydration: clientBuild.metadata().capabilities.independentHydration,
|
|
451
453
|
streamedSignals: clientBuild.hasStreamedSignals,
|
|
454
|
+
// A root boundary or the data module's DataRoot wraps the route in a body no proof covers.
|
|
452
455
|
voidRoot:
|
|
453
456
|
!rootBoundary &&
|
|
457
|
+
!config.data &&
|
|
454
458
|
imports.length > 0 &&
|
|
455
459
|
(await provenVoidImports(context, RESOLVED_VIRTUAL_HYDRATE_ID, imports)).length ===
|
|
456
460
|
imports.length,
|
|
@@ -482,7 +486,7 @@ async function hydrate_entry_features(context, config, entries, clientBuild, pro
|
|
|
482
486
|
* it). An explicit `profile` (true or false) always takes precedence over
|
|
483
487
|
* `devtools`.
|
|
484
488
|
*
|
|
485
|
-
* @param {{ hmr?: boolean, output?: 'js' | 'ts', profile?: boolean, devtools?: boolean, strong?: boolean, textTypes?: import('octane/compiler/vite').OctaneVitePluginOptions['textTypes'], knownAttributeSpreads?: import('octane/compiler/vite').OctaneVitePluginOptions['knownAttributeSpreads'], domBindingFixedProps?: import('octane/compiler/vite').OctaneVitePluginOptions['domBindingFixedProps'], opaqueSignalHandles?: boolean, exclude?: string[], requireDirective?: boolean, renderers?: import('@octanejs/app-core').ExperimentalRendererConfigOptions, cssModuleConstants?: import('octane/compiler/vite').OctaneVitePluginOptions['cssModuleConstants'] }} [inlineOptions]
|
|
489
|
+
* @param {{ hmr?: boolean, output?: 'js' | 'ts', profile?: boolean, devtools?: boolean, strong?: boolean, textTypes?: import('octane/compiler/vite').OctaneVitePluginOptions['textTypes'], knownAttributeSpreads?: import('octane/compiler/vite').OctaneVitePluginOptions['knownAttributeSpreads'], domBindingFixedProps?: import('octane/compiler/vite').OctaneVitePluginOptions['domBindingFixedProps'], opaqueSignalHandles?: boolean, exclude?: string[], requireDirective?: boolean, renderers?: import('@octanejs/app-core').ExperimentalRendererConfigOptions, cssModuleConstants?: import('octane/compiler/vite').OctaneVitePluginOptions['cssModuleConstants'], dataWorker?: string, data?: boolean }} [inlineOptions]
|
|
486
490
|
* @returns {Plugin[]}
|
|
487
491
|
*/
|
|
488
492
|
export function octane(inlineOptions = {}) {
|
|
@@ -897,10 +901,10 @@ export function octane(inlineOptions = {}) {
|
|
|
897
901
|
compilerPlugin.api.provenVoidImports,
|
|
898
902
|
)
|
|
899
903
|
: null;
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
+
const loaded = isBuild
|
|
905
|
+
? buildOctaneConfig
|
|
906
|
+
: (octaneConfig ?? (await loadStartupConfig(root))?.config ?? null);
|
|
907
|
+
if (!isBuild) entries = collect_hydrate_module_paths(loaded);
|
|
904
908
|
const file = write_project_generated_file(
|
|
905
909
|
config,
|
|
906
910
|
'client-entry.js',
|
|
@@ -910,6 +914,7 @@ export function octane(inlineOptions = {}) {
|
|
|
910
914
|
clientBuildId: clientBuild.buildId,
|
|
911
915
|
devClientBuild: !isBuild,
|
|
912
916
|
...features,
|
|
917
|
+
data: Boolean(loaded?.data),
|
|
913
918
|
}),
|
|
914
919
|
);
|
|
915
920
|
return fs.readFileSync(file, 'utf-8');
|
|
@@ -1324,6 +1329,8 @@ export function octane(inlineOptions = {}) {
|
|
|
1324
1329
|
routes: cfg.router.routes,
|
|
1325
1330
|
octaneConfigPath: getOctaneConfigPath(root),
|
|
1326
1331
|
rootBoundary: cfg.rootBoundary,
|
|
1332
|
+
data: cfg.data,
|
|
1333
|
+
dataRootModuleId: requireFromPlugin.resolve('@octanejs/app-core/data-root'),
|
|
1327
1334
|
rpcModulePaths: [...serverModuleModules],
|
|
1328
1335
|
clientAssetMap,
|
|
1329
1336
|
clientBuild: completedClientBuild,
|
|
@@ -1462,6 +1469,7 @@ export function octane(inlineOptions = {}) {
|
|
|
1462
1469
|
* output?: 'js' | 'ts',
|
|
1463
1470
|
* profile?: boolean | 'auto',
|
|
1464
1471
|
* strong?: boolean,
|
|
1472
|
+
* strongDependencies?: import('octane/compiler/vite').OctaneVitePluginOptions['strongDependencies'],
|
|
1465
1473
|
* textTypes?: import('octane/compiler/vite').OctaneVitePluginOptions['textTypes'],
|
|
1466
1474
|
* knownAttributeSpreads?: import('octane/compiler/vite').OctaneVitePluginOptions['knownAttributeSpreads'],
|
|
1467
1475
|
* domBindingFixedProps?: import('octane/compiler/vite').OctaneVitePluginOptions['domBindingFixedProps'],
|
|
@@ -1470,6 +1478,8 @@ export function octane(inlineOptions = {}) {
|
|
|
1470
1478
|
* requireDirective?: boolean,
|
|
1471
1479
|
* renderers?: import('@octanejs/app-core').ExperimentalRendererConfigOptions,
|
|
1472
1480
|
* cssModuleConstants?: import('octane/compiler/vite').OctaneVitePluginOptions['cssModuleConstants'],
|
|
1481
|
+
* dataWorker?: string,
|
|
1482
|
+
* data?: boolean,
|
|
1473
1483
|
* __onIndependentWidgets?: (id: string, environment: string, templates: any[], streamedSignals: boolean) => void,
|
|
1474
1484
|
* __clientBuildId?: () => string,
|
|
1475
1485
|
* }}
|
|
@@ -1503,22 +1513,20 @@ export function octane(inlineOptions = {}) {
|
|
|
1503
1513
|
if (inlineOptions.cssModuleConstants !== undefined) {
|
|
1504
1514
|
compilerOptions.cssModuleConstants = inlineOptions.cssModuleConstants;
|
|
1505
1515
|
}
|
|
1516
|
+
if (inlineOptions.dataWorker !== undefined) compilerOptions.dataWorker = inlineOptions.dataWorker;
|
|
1517
|
+
if (inlineOptions.data !== undefined) compilerOptions.data = inlineOptions.data;
|
|
1506
1518
|
const compilerPlugin = /** @type {Plugin} */ (octaneCompiler(compilerOptions));
|
|
1507
1519
|
const compilerConfigHook = compilerPlugin.config;
|
|
1508
1520
|
if (typeof compilerConfigHook === 'function') {
|
|
1509
1521
|
compilerPlugin.config = function compilerConfigWithAppOptions(userConfig, env) {
|
|
1510
1522
|
const projectRoot = userConfig.root ? path.resolve(userConfig.root) : process.cwd();
|
|
1511
|
-
//
|
|
1512
|
-
//
|
|
1513
|
-
if (inlineOptions.renderers !== undefined && inlineOptions.strong !== undefined) {
|
|
1514
|
-
compilerConfigWatchFiles.clear();
|
|
1515
|
-
return compilerConfigHook.call(this, userConfig, env);
|
|
1516
|
-
}
|
|
1517
|
-
|
|
1523
|
+
// Inline `renderers` and `strong` override app config independently.
|
|
1524
|
+
// `strongDependencies` comes only from octane.config.ts, so it is always read.
|
|
1518
1525
|
const configPath = getOctaneConfigPath(projectRoot);
|
|
1519
1526
|
if (!octaneConfigExists(projectRoot)) {
|
|
1520
1527
|
if (inlineOptions.renderers === undefined) delete compilerOptions.renderers;
|
|
1521
1528
|
if (inlineOptions.strong === undefined) delete compilerOptions.strong;
|
|
1529
|
+
delete compilerOptions.strongDependencies;
|
|
1522
1530
|
compilerConfigWatchFiles.clear();
|
|
1523
1531
|
// A new app config can introduce Strong mode or renderer rules.
|
|
1524
1532
|
compilerConfigWatchFiles.add(path.resolve(configPath));
|
|
@@ -1533,6 +1541,7 @@ export function octane(inlineOptions = {}) {
|
|
|
1533
1541
|
if (inlineOptions.strong === undefined) {
|
|
1534
1542
|
compilerOptions.strong = config.config.compiler.strong;
|
|
1535
1543
|
}
|
|
1544
|
+
compilerOptions.strongDependencies = config.config.compiler.strongDependencies;
|
|
1536
1545
|
compilerConfigWatchFiles.clear();
|
|
1537
1546
|
for (const file of [...config.dependencies, ...config.missingDependencies]) {
|
|
1538
1547
|
compilerConfigWatchFiles.add(path.resolve(file));
|
package/src/seeds.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { readRouteSeed, routeSeed } from '@octanejs/app-core/seeds';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { composeHtmlStream } from '@octanejs/app-core/html';
|
|
1
|
+
export { composeHtmlStream, endRoute, routeEnding } from '@octanejs/app-core/html';
|
|
@@ -3,7 +3,8 @@ import { readFile } from 'node:fs/promises';
|
|
|
3
3
|
import { randomUUID } from 'node:crypto';
|
|
4
4
|
import { join } from 'node:path';
|
|
5
5
|
import { createRpcRegistry } from '@octanejs/app-core';
|
|
6
|
-
import {
|
|
6
|
+
import { createRequire } from 'node:module';
|
|
7
|
+
import { composeHtmlStream, endRoute, routeEnding } from './html-stream.js';
|
|
7
8
|
import {
|
|
8
9
|
getContextNonce,
|
|
9
10
|
injectHydrationEntry,
|
|
@@ -16,6 +17,7 @@ import {
|
|
|
16
17
|
createLayoutWrapper,
|
|
17
18
|
createPropsWrapper,
|
|
18
19
|
createRootBoundaryWrapper,
|
|
20
|
+
provideRouteData,
|
|
19
21
|
} from './component-wrappers.js';
|
|
20
22
|
import {
|
|
21
23
|
get_component_export,
|
|
@@ -23,6 +25,9 @@ import {
|
|
|
23
25
|
get_route_entry_path,
|
|
24
26
|
} from '../routes.js';
|
|
25
27
|
|
|
28
|
+
/** App-core's `DataRoot`, compiled for the server through Vite's SSR loader. */
|
|
29
|
+
const DATA_ROOT_MODULE = createRequire(import.meta.url).resolve('@octanejs/app-core/data-root');
|
|
30
|
+
|
|
26
31
|
/**
|
|
27
32
|
* @typedef {import('@octanejs/vite-plugin').Context} Context
|
|
28
33
|
* @typedef {import('@octanejs/vite-plugin').RenderRoute} RenderRoute
|
|
@@ -208,6 +213,16 @@ export async function handleRenderRoute(
|
|
|
208
213
|
{ pending: PendingComponent, catch: CatchComponent },
|
|
209
214
|
/** @type {any} */ (serverRuntime),
|
|
210
215
|
);
|
|
216
|
+
const dataPath = octaneConfig?.data;
|
|
217
|
+
if (dataPath) {
|
|
218
|
+
const dataModule = await vite.ssrLoadModule(dataPath);
|
|
219
|
+
const { DataRoot } = await vite.ssrLoadModule(DATA_ROOT_MODULE);
|
|
220
|
+
RootComponent = provideRouteData(
|
|
221
|
+
context,
|
|
222
|
+
{ path: dataPath, open: dataModule.default, Root: DataRoot },
|
|
223
|
+
RootComponent,
|
|
224
|
+
);
|
|
225
|
+
}
|
|
211
226
|
// Discovery runs while loading the page/layout above. Snapshot capability
|
|
212
227
|
// afterwards; its live registry also resolves widgets compiled lazily later.
|
|
213
228
|
const clientBuild = getClientBuild?.();
|
|
@@ -232,6 +247,7 @@ export async function handleRenderRoute(
|
|
|
232
247
|
params: context.params,
|
|
233
248
|
url: requestUrl,
|
|
234
249
|
preHydrate: octaneConfig?.router.preHydrate ?? null,
|
|
250
|
+
data: octaneConfig?.data ?? null,
|
|
235
251
|
rootBoundary: {
|
|
236
252
|
pending: serializeComponentEntry(pendingEntry),
|
|
237
253
|
catch: serializeComponentEntry(catchEntry),
|
|
@@ -314,10 +330,17 @@ export async function handleRenderRoute(
|
|
|
314
330
|
|
|
315
331
|
// Feature-bearing documents activate after the complete shell and its
|
|
316
332
|
// selection authority; open result channels must not hold input hostage.
|
|
317
|
-
const body = composeHtmlStream(
|
|
333
|
+
const body = composeHtmlStream(
|
|
334
|
+
prefix,
|
|
335
|
+
renderStream,
|
|
336
|
+
suffix,
|
|
337
|
+
preparedTemplate.afterShell,
|
|
338
|
+
routeEnding(context, nonceAttribute(nonce)),
|
|
339
|
+
);
|
|
318
340
|
|
|
319
341
|
return new Response(body, { status, headers });
|
|
320
342
|
} catch (error) {
|
|
343
|
+
endRoute(context);
|
|
321
344
|
console.error('[octane] SSR render error:', error);
|
|
322
345
|
|
|
323
346
|
const errorHtml = generateErrorHtml(error, route);
|
package/types/index.d.ts
CHANGED
|
@@ -55,6 +55,15 @@ export interface OctanePluginOptions {
|
|
|
55
55
|
renderers?: ExperimentalRendererConfigOptions;
|
|
56
56
|
/** @experimental Authenticate immutable CSS-module exports in production builds. */
|
|
57
57
|
cssModuleConstants?: OctaneVitePluginOptions['cssModuleConstants'];
|
|
58
|
+
/**
|
|
59
|
+
* The app's data worker module, which calls `serveDataOwner` from
|
|
60
|
+
* `octane/data`. Client builds emit it at `/_octane/data-worker.js`, and the
|
|
61
|
+
* dev server serves it there, so every deploy's tabs share one owner through
|
|
62
|
+
* `sharedOwner`. Resolved from the Vite project root.
|
|
63
|
+
*/
|
|
64
|
+
dataWorker?: OctaneVitePluginOptions['dataWorker'];
|
|
65
|
+
/** The `octane/data` contract check and generated `octane/data/manifest`. */
|
|
66
|
+
data?: OctaneVitePluginOptions['data'];
|
|
58
67
|
}
|
|
59
68
|
|
|
60
69
|
/** The Octane compiler plugin plus Vite app/metaframework integration. */
|
package/types/seeds.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@octanejs/app-core/seeds';
|