@octanejs/rsbuild-plugin 0.1.13 → 0.1.15
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 +13 -0
- package/package.json +5 -5
- package/src/index.js +22 -6
- package/types/index.d.ts +5 -0
package/README.md
CHANGED
|
@@ -75,9 +75,22 @@ Options are declarative and cache-stable:
|
|
|
75
75
|
|
|
76
76
|
- `hmr` controls browser component handoff;
|
|
77
77
|
- `profile` enables component profiling in the browser environment;
|
|
78
|
+
- `strong` overrides the app's `compiler.strong` setting;
|
|
78
79
|
- `exclude` skips path fragments in the plain `.ts`/`.js` hook-slot pass; and
|
|
79
80
|
- `clientEnvironment` / `serverEnvironment` rename the generated environments.
|
|
80
81
|
|
|
82
|
+
Enable Strong mode for the whole app in `octane.config.ts`:
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
export default defineConfig({
|
|
86
|
+
compiler: { strong: true },
|
|
87
|
+
});
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
You can also pass `pluginOctane({ strong: true })`. The plugin option takes
|
|
91
|
+
priority over the app config. Dependencies are unaffected unless they begin a
|
|
92
|
+
module with `"use strong"`.
|
|
93
|
+
|
|
81
94
|
App mode currently serves from the root path and uses Rsbuild's default asset
|
|
82
95
|
prefix. Keep `server.base` at `/` and `output.assetPrefix` at `auto` or `/`; for
|
|
83
96
|
a subpath deployment, rewrite that prefix to the app root in the hosting proxy.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octanejs/rsbuild-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -48,12 +48,12 @@
|
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@octanejs/app-core": "0.0.
|
|
52
|
-
"@octanejs/rspack-plugin": "0.1.
|
|
51
|
+
"@octanejs/app-core": "0.0.16",
|
|
52
|
+
"@octanejs/rspack-plugin": "0.1.15"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"@rsbuild/core": "^2.0.0",
|
|
56
|
-
"octane": "0.1.
|
|
56
|
+
"octane": "0.1.20"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@rsbuild/core": "^2.1.6",
|
|
@@ -62,6 +62,6 @@
|
|
|
62
62
|
"playwright": "^1.61.1",
|
|
63
63
|
"type-fest": "^5.8.0",
|
|
64
64
|
"vitest": "^4.1.10",
|
|
65
|
-
"octane": "0.1.
|
|
65
|
+
"octane": "0.1.20"
|
|
66
66
|
}
|
|
67
67
|
}
|
package/src/index.js
CHANGED
|
@@ -132,8 +132,11 @@ function hasRoutes(config) {
|
|
|
132
132
|
return (config?.router.routes.length ?? 0) > 0;
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
/**
|
|
136
|
-
|
|
135
|
+
/**
|
|
136
|
+
* @param {import('@octanejs/app-core').ResolvedOctaneConfig} config
|
|
137
|
+
* @param {boolean | undefined} strongOverride
|
|
138
|
+
*/
|
|
139
|
+
function configSignature(config, strongOverride) {
|
|
137
140
|
return JSON.stringify({
|
|
138
141
|
build: config.build,
|
|
139
142
|
routes: config.router.routes.map((route) =>
|
|
@@ -150,7 +153,10 @@ function configSignature(config) {
|
|
|
150
153
|
preHydrate: config.router.preHydrate,
|
|
151
154
|
rootBoundary: config.rootBoundary,
|
|
152
155
|
server: config.server,
|
|
153
|
-
compiler: {
|
|
156
|
+
compiler: {
|
|
157
|
+
renderers: config.compiler.renderers.signature,
|
|
158
|
+
strong: strongOverride ?? config.compiler.strong,
|
|
159
|
+
},
|
|
154
160
|
});
|
|
155
161
|
}
|
|
156
162
|
|
|
@@ -228,6 +234,7 @@ function assertRootPublicPaths(config, clientEnvironment) {
|
|
|
228
234
|
* @param {{
|
|
229
235
|
* hmr?: boolean,
|
|
230
236
|
* profile?: boolean,
|
|
237
|
+
* strong?: boolean,
|
|
231
238
|
* exclude?: string[],
|
|
232
239
|
* requireDirective?: boolean,
|
|
233
240
|
* clientEnvironment?: string,
|
|
@@ -236,6 +243,9 @@ function assertRootPublicPaths(config, clientEnvironment) {
|
|
|
236
243
|
* @returns {import('@rsbuild/core').RsbuildPlugin}
|
|
237
244
|
*/
|
|
238
245
|
export function pluginOctane(inlineOptions = {}) {
|
|
246
|
+
if (inlineOptions.strong !== undefined && typeof inlineOptions.strong !== 'boolean') {
|
|
247
|
+
throw new TypeError('[@octanejs/rsbuild-plugin] `strong` must be a boolean.');
|
|
248
|
+
}
|
|
239
249
|
return {
|
|
240
250
|
name: PLUGIN_NAME,
|
|
241
251
|
enforce: 'pre',
|
|
@@ -253,14 +263,19 @@ export function pluginOctane(inlineOptions = {}) {
|
|
|
253
263
|
})
|
|
254
264
|
: null;
|
|
255
265
|
const initialConfig = initialLoaded?.config ?? null;
|
|
266
|
+
const strong = inlineOptions.strong ?? initialConfig?.compiler.strong;
|
|
256
267
|
const appEnabled = hasRoutes(initialConfig);
|
|
257
268
|
const buildTargetPlan =
|
|
258
269
|
initialConfig?.build.target === undefined
|
|
259
270
|
? null
|
|
260
271
|
: createBuildTargetPlan(initialConfig.build.target);
|
|
261
|
-
const neutralCompiler = appEnabled
|
|
272
|
+
const neutralCompiler = appEnabled
|
|
273
|
+
? createOctaneCompiler({ root, ...(strong === undefined ? null : { strong }) })
|
|
274
|
+
: null;
|
|
262
275
|
let currentConfig = initialConfig;
|
|
263
|
-
let lastConfigSignature = initialLoaded
|
|
276
|
+
let lastConfigSignature = initialLoaded
|
|
277
|
+
? configSignature(initialLoaded.config, inlineOptions.strong)
|
|
278
|
+
: '';
|
|
264
279
|
let configNeedsReload = false;
|
|
265
280
|
/** @type {import('@rsbuild/core').RsbuildDevServer | null} */
|
|
266
281
|
let devServer = null;
|
|
@@ -307,7 +322,7 @@ export function pluginOctane(inlineOptions = {}) {
|
|
|
307
322
|
throw error;
|
|
308
323
|
}
|
|
309
324
|
registerConfigDependencies(context, loaded);
|
|
310
|
-
const signature = configSignature(loaded.config);
|
|
325
|
+
const signature = configSignature(loaded.config, inlineOptions.strong);
|
|
311
326
|
if (lastConfigSignature && signature !== lastConfigSignature) configNeedsReload = true;
|
|
312
327
|
lastConfigSignature = signature;
|
|
313
328
|
currentConfig = loaded.config;
|
|
@@ -531,6 +546,7 @@ export function pluginOctane(inlineOptions = {}) {
|
|
|
531
546
|
root,
|
|
532
547
|
environment,
|
|
533
548
|
transpile: false,
|
|
549
|
+
...(strong === undefined ? null : { strong }),
|
|
534
550
|
...(inlineOptions.hmr === undefined ? null : { hmr: inlineOptions.hmr }),
|
|
535
551
|
...(inlineOptions.profile === undefined
|
|
536
552
|
? null
|
package/types/index.d.ts
CHANGED
|
@@ -13,6 +13,11 @@ export interface OctaneRsbuildPluginOptions {
|
|
|
13
13
|
hmr?: boolean;
|
|
14
14
|
/** Enable component profiling in the browser environment. */
|
|
15
15
|
profile?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Override `compiler.strong` for this integration. Strong mode applies to
|
|
18
|
+
* project-owned modules; dependencies can opt in with `"use strong"`.
|
|
19
|
+
*/
|
|
20
|
+
strong?: boolean;
|
|
16
21
|
/**
|
|
17
22
|
* Ad-hoc path fragments skipped by the plain TypeScript/JavaScript
|
|
18
23
|
* hook-slot pass. With `requireDirective`, excluded paths are exempt from
|