@octanejs/vite-plugin 0.3.3 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/src/client-build.js +30 -2
- package/src/index.js +12 -2
- package/types/index.d.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octanejs/vite-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -46,17 +46,17 @@
|
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@octanejs/app-core": "0.1.
|
|
49
|
+
"@octanejs/app-core": "0.1.7",
|
|
50
50
|
"@ripple-ts/adapter": "^0.4.0"
|
|
51
51
|
},
|
|
52
52
|
"peerDependencies": {
|
|
53
|
-
"octane": "^0.
|
|
53
|
+
"octane": "^0.13.2",
|
|
54
54
|
"vite": "^8.0.16"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/jsdom": "30.0.0",
|
|
58
58
|
"@types/node": "^24.13.3",
|
|
59
|
-
"octane": "0.
|
|
59
|
+
"octane": "0.13.2",
|
|
60
60
|
"playwright": "^1.61.1",
|
|
61
61
|
"playwright-webkit": "1.63.0",
|
|
62
62
|
"vite": "^8.1.5"
|
package/src/client-build.js
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* A production client entry embeds this until every chunk is rendered. It has
|
|
7
|
+
* the length of the content id `seal` returns, so the swap moves no mappings.
|
|
8
|
+
*/
|
|
9
|
+
export const PENDING_CLIENT_BUILD_ID = '__octane_pending_client_build_id__'.padEnd(43, '_');
|
|
10
|
+
// Rolldown labels rendered modules with cwd-relative paths that minifying drops.
|
|
11
|
+
const REGION_COMMENT = /^\/\/#(?:end)?region\b.*$/gm;
|
|
12
|
+
|
|
5
13
|
/**
|
|
6
14
|
* One identity per actual Vite client generation. Discovery is replaceable per
|
|
7
15
|
* source, so deleting a widget cannot leave an old activation record behind.
|
|
@@ -9,6 +17,7 @@ import path from 'node:path';
|
|
|
9
17
|
* @param {(buildId: string) => void} [onIncompatibleDiscovery]
|
|
10
18
|
*/
|
|
11
19
|
export function createClientBuildState(onIncompatibleDiscovery) {
|
|
20
|
+
/** @type {string} */
|
|
12
21
|
let buildId = randomUUID();
|
|
13
22
|
let hadHotUpdates = false;
|
|
14
23
|
/** @type {Map<string, Map<string, { moduleId: string, styles: string[] }>>} */
|
|
@@ -22,7 +31,7 @@ export function createClientBuildState(onIncompatibleDiscovery) {
|
|
|
22
31
|
return sources.size !== 0 || signalSources.size !== 0;
|
|
23
32
|
},
|
|
24
33
|
begin() {
|
|
25
|
-
buildId =
|
|
34
|
+
buildId = PENDING_CLIENT_BUILD_ID;
|
|
26
35
|
hadHotUpdates = false;
|
|
27
36
|
sources.clear();
|
|
28
37
|
signalSources.clear();
|
|
@@ -37,6 +46,25 @@ export function createClientBuildState(onIncompatibleDiscovery) {
|
|
|
37
46
|
noteHotUpdate() {
|
|
38
47
|
hadHotUpdates = true;
|
|
39
48
|
},
|
|
49
|
+
/**
|
|
50
|
+
* Name a production generation by its rendered client graph, so identical
|
|
51
|
+
* inputs reproduce identical output. Rolldown hashes file names after
|
|
52
|
+
* renderChunk, so the entries that embed this id are named by it too.
|
|
53
|
+
* @param {Record<string, import('vite').Rollup.RenderedChunk>} chunks
|
|
54
|
+
*/
|
|
55
|
+
seal(chunks) {
|
|
56
|
+
if (buildId !== PENDING_CLIENT_BUILD_ID) return buildId;
|
|
57
|
+
const graph = Object.keys(chunks)
|
|
58
|
+
.sort()
|
|
59
|
+
.map((file) => [
|
|
60
|
+
file,
|
|
61
|
+
Object.values(chunks[file].modules).map((module) =>
|
|
62
|
+
module.code?.replace(REGION_COMMENT, ''),
|
|
63
|
+
),
|
|
64
|
+
]);
|
|
65
|
+
buildId = createHash('sha256').update(JSON.stringify(graph)).digest('base64url');
|
|
66
|
+
return buildId;
|
|
67
|
+
},
|
|
40
68
|
/** @param {string} root @param {string} id @param {any[]} templates @param {boolean} [streamedSignals] */
|
|
41
69
|
record(root, id, templates, streamedSignals = false) {
|
|
42
70
|
// Sliced activation modules have no children of their own. They must
|
package/src/index.js
CHANGED
|
@@ -45,7 +45,7 @@ import {
|
|
|
45
45
|
write_project_generated_file,
|
|
46
46
|
} from './project-codegen.js';
|
|
47
47
|
import { createClientAssetMap } from './client-assets.js';
|
|
48
|
-
import { createClientBuildState } from './client-build.js';
|
|
48
|
+
import { PENDING_CLIENT_BUILD_ID, createClientBuildState } from './client-build.js';
|
|
49
49
|
|
|
50
50
|
import { patch_global_fetch, is_rpc_request } from '@ripple-ts/adapter/rpc';
|
|
51
51
|
|
|
@@ -429,7 +429,7 @@ function collect_hydrate_module_paths(config) {
|
|
|
429
429
|
* it). An explicit `profile` (true or false) always takes precedence over
|
|
430
430
|
* `devtools`.
|
|
431
431
|
*
|
|
432
|
-
* @param {{ hmr?: boolean, 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]
|
|
432
|
+
* @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]
|
|
433
433
|
* @returns {Plugin[]}
|
|
434
434
|
*/
|
|
435
435
|
export function octane(inlineOptions = {}) {
|
|
@@ -677,6 +677,14 @@ export function octane(inlineOptions = {}) {
|
|
|
677
677
|
}
|
|
678
678
|
},
|
|
679
679
|
|
|
680
|
+
renderChunk(code, _chunk, _options, meta) {
|
|
681
|
+
if (!code.includes(PENDING_CLIENT_BUILD_ID)) return null;
|
|
682
|
+
return {
|
|
683
|
+
code: code.replaceAll(PENDING_CLIENT_BUILD_ID, clientBuild.seal(meta.chunks)),
|
|
684
|
+
map: null,
|
|
685
|
+
};
|
|
686
|
+
},
|
|
687
|
+
|
|
680
688
|
writeBundle() {
|
|
681
689
|
clientBuildWritten = true;
|
|
682
690
|
},
|
|
@@ -1385,6 +1393,7 @@ export function octane(inlineOptions = {}) {
|
|
|
1385
1393
|
/**
|
|
1386
1394
|
* @type {{
|
|
1387
1395
|
* hmr?: boolean,
|
|
1396
|
+
* output?: 'js' | 'ts',
|
|
1388
1397
|
* profile?: boolean | 'auto',
|
|
1389
1398
|
* strong?: boolean,
|
|
1390
1399
|
* textTypes?: import('octane/compiler/vite').OctaneVitePluginOptions['textTypes'],
|
|
@@ -1404,6 +1413,7 @@ export function octane(inlineOptions = {}) {
|
|
|
1404
1413
|
__clientBuildId: () => clientBuild.buildId,
|
|
1405
1414
|
};
|
|
1406
1415
|
if (inlineOptions.hmr !== undefined) compilerOptions.hmr = inlineOptions.hmr;
|
|
1416
|
+
if (inlineOptions.output !== undefined) compilerOptions.output = inlineOptions.output;
|
|
1407
1417
|
// Explicit `profile` wins; otherwise `devtools: true` opts into the
|
|
1408
1418
|
// command-aware `'auto'` signal the compiler resolves to DEV-only profiling.
|
|
1409
1419
|
if (inlineOptions.profile !== undefined) compilerOptions.profile = inlineOptions.profile;
|
package/types/index.d.ts
CHANGED
|
@@ -11,6 +11,8 @@ import type {
|
|
|
11
11
|
export * from '@octanejs/app-core';
|
|
12
12
|
|
|
13
13
|
export interface OctanePluginOptions {
|
|
14
|
+
/** Compile through a typed intermediate; Vite emits JavaScript and composed maps. */
|
|
15
|
+
output?: OctaneVitePluginOptions['output'];
|
|
14
16
|
/** Override the client HMR default (on in serve mode, off for SSR). */
|
|
15
17
|
hmr?: boolean;
|
|
16
18
|
/** Enable component profiling in client transforms. */
|