@moostjs/vite 0.6.22 → 0.6.24
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 +3 -1
- package/dist/index.cjs +16 -3
- package/dist/index.mjs +16 -3
- package/dist/prod-server.cjs +1 -0
- package/dist/prod-server.mjs +1 -0
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -184,11 +184,13 @@ You can also opt out of bundle-everything by setting `ssr.noExternal` to an expl
|
|
|
184
184
|
|
|
185
185
|
```ts
|
|
186
186
|
ssr: {
|
|
187
|
-
noExternal: [
|
|
187
|
+
noExternal: [/^@aooth\//, /^@atscript\//],
|
|
188
188
|
external: ['vue', 'vue-router'],
|
|
189
189
|
}
|
|
190
190
|
```
|
|
191
191
|
|
|
192
|
+
When you use an explicit `noExternal` list, the plugin automatically keeps the **moost/wooks runtime** (`moost`, `@moostjs/*`, `@wooksjs/*`, `wooks`) bundled alongside your listed packages, so there is always a single runtime instance. This avoids a subtle production-only failure: if any `noExternal` package imports `@wooksjs/*` (e.g. `@aooth/*` and other `.as`-shipping libs do), it would otherwise pull in a second copy while externalized `moost` uses the first — splitting the event context so `useRequest()` / `useHeaders()` / `useAuthorization()` read `undefined`. If you would rather externalize the runtime instead, list it under `ssr.external` (e.g. `['@wooksjs/event-http', '@wooksjs/event-core', 'wooks', ...]`) and add those packages as direct dependencies — the plugin detects an externalized runtime and leaves your all-external setup intact.
|
|
193
|
+
|
|
192
194
|
## SSR Local Fetch
|
|
193
195
|
|
|
194
196
|
When `ssrFetch` is enabled (default: `true`), the plugin patches `globalThis.fetch` so that local paths are routed in-process through Moost instead of making a real HTTP request. This is useful for SSR where server-side code fetches from its own API:
|
package/dist/index.cjs
CHANGED
|
@@ -385,12 +385,17 @@ function moostVite(options) {
|
|
|
385
385
|
enforce: "pre",
|
|
386
386
|
config(cfg, env) {
|
|
387
387
|
if (options.middleware) {
|
|
388
|
+
const entryKeyBase = entryBasename(options.entry).replace(/\.js$/, "");
|
|
389
|
+
const entryKey = entryKeyBase === "server" ? "moost-entry" : entryKeyBase;
|
|
388
390
|
const serverDefines = {
|
|
389
391
|
"process.env.MOOST_DEFERRED_ENV": "\"production\"",
|
|
390
|
-
__MOOST_ENTRY__: JSON.stringify(
|
|
392
|
+
__MOOST_ENTRY__: JSON.stringify(`./${entryKey}.js`),
|
|
391
393
|
__MOOST_PREFIX__: JSON.stringify(prefix || "/api")
|
|
392
394
|
};
|
|
393
|
-
const ssrInput = {
|
|
395
|
+
const ssrInput = {
|
|
396
|
+
server: options.serverEntry || generatedServerEntry(cfg.root),
|
|
397
|
+
[entryKey]: options.entry
|
|
398
|
+
};
|
|
394
399
|
if (options.ssrEntry) {
|
|
395
400
|
const ssrBasename = entryBasename(options.ssrEntry);
|
|
396
401
|
ssrInput[`ssr/${ssrBasename.replace(/\.js$/, "")}`] = options.ssrEntry;
|
|
@@ -402,9 +407,17 @@ function moostVite(options) {
|
|
|
402
407
|
const isBuild = env.command === "build";
|
|
403
408
|
const ourPlugin = /^@moostjs\/vite($|\/)/;
|
|
404
409
|
const userNoExternal = cfg.ssr?.noExternal;
|
|
405
|
-
|
|
410
|
+
let ssrNoExternal = userNoExternal === true ? true : userNoExternal !== void 0 ? [...Array.isArray(userNoExternal) ? userNoExternal : [userNoExternal], ourPlugin] : isBuild ? true : [ourPlugin];
|
|
406
411
|
const userExternal = cfg.ssr?.external;
|
|
407
412
|
const ssrExternal = isBuild ? [...Array.isArray(userExternal) ? userExternal : [], ...options.ssrExternal ?? []] : void 0;
|
|
413
|
+
const runtimeNoExternal = [
|
|
414
|
+
/^moost($|\/)/,
|
|
415
|
+
/^@moostjs\//,
|
|
416
|
+
/^@wooksjs\//,
|
|
417
|
+
/^wooks($|\/)/
|
|
418
|
+
];
|
|
419
|
+
const runtimeExternalized = (ssrExternal ?? []).some((e) => typeof e === "string" && runtimeNoExternal.some((re) => re.test(e)));
|
|
420
|
+
if (isBuild && Array.isArray(ssrNoExternal) && !runtimeExternalized) ssrNoExternal = [...ssrNoExternal, ...runtimeNoExternal];
|
|
408
421
|
return {
|
|
409
422
|
...options.ssrEntry && { appType: "custom" },
|
|
410
423
|
ssr: {
|
package/dist/index.mjs
CHANGED
|
@@ -354,12 +354,17 @@ function moostVite(options) {
|
|
|
354
354
|
enforce: "pre",
|
|
355
355
|
config(cfg, env) {
|
|
356
356
|
if (options.middleware) {
|
|
357
|
+
const entryKeyBase = entryBasename(options.entry).replace(/\.js$/, "");
|
|
358
|
+
const entryKey = entryKeyBase === "server" ? "moost-entry" : entryKeyBase;
|
|
357
359
|
const serverDefines = {
|
|
358
360
|
"process.env.MOOST_DEFERRED_ENV": "\"production\"",
|
|
359
|
-
__MOOST_ENTRY__: JSON.stringify(
|
|
361
|
+
__MOOST_ENTRY__: JSON.stringify(`./${entryKey}.js`),
|
|
360
362
|
__MOOST_PREFIX__: JSON.stringify(prefix || "/api")
|
|
361
363
|
};
|
|
362
|
-
const ssrInput = {
|
|
364
|
+
const ssrInput = {
|
|
365
|
+
server: options.serverEntry || generatedServerEntry(cfg.root),
|
|
366
|
+
[entryKey]: options.entry
|
|
367
|
+
};
|
|
363
368
|
if (options.ssrEntry) {
|
|
364
369
|
const ssrBasename = entryBasename(options.ssrEntry);
|
|
365
370
|
ssrInput[`ssr/${ssrBasename.replace(/\.js$/, "")}`] = options.ssrEntry;
|
|
@@ -371,9 +376,17 @@ function moostVite(options) {
|
|
|
371
376
|
const isBuild = env.command === "build";
|
|
372
377
|
const ourPlugin = /^@moostjs\/vite($|\/)/;
|
|
373
378
|
const userNoExternal = cfg.ssr?.noExternal;
|
|
374
|
-
|
|
379
|
+
let ssrNoExternal = userNoExternal === true ? true : userNoExternal !== void 0 ? [...Array.isArray(userNoExternal) ? userNoExternal : [userNoExternal], ourPlugin] : isBuild ? true : [ourPlugin];
|
|
375
380
|
const userExternal = cfg.ssr?.external;
|
|
376
381
|
const ssrExternal = isBuild ? [...Array.isArray(userExternal) ? userExternal : [], ...options.ssrExternal ?? []] : void 0;
|
|
382
|
+
const runtimeNoExternal = [
|
|
383
|
+
/^moost($|\/)/,
|
|
384
|
+
/^@moostjs\//,
|
|
385
|
+
/^@wooksjs\//,
|
|
386
|
+
/^wooks($|\/)/
|
|
387
|
+
];
|
|
388
|
+
const runtimeExternalized = (ssrExternal ?? []).some((e) => typeof e === "string" && runtimeNoExternal.some((re) => re.test(e)));
|
|
389
|
+
if (isBuild && Array.isArray(ssrNoExternal) && !runtimeExternalized) ssrNoExternal = [...ssrNoExternal, ...runtimeNoExternal];
|
|
377
390
|
return {
|
|
378
391
|
...options.ssrEntry && { appType: "custom" },
|
|
379
392
|
ssr: {
|
package/dist/prod-server.cjs
CHANGED
|
@@ -89,6 +89,7 @@ async function createSSRServer(options) {
|
|
|
89
89
|
setTimeout(() => args.filter((a) => typeof a === "function").forEach((a) => a()), 1);
|
|
90
90
|
return Promise.resolve();
|
|
91
91
|
};
|
|
92
|
+
// @vite-ignore keeps rolldown from trying to resolve the substituted literal
|
|
92
93
|
if (typeof opts.entry === "function") await opts.entry();
|
|
93
94
|
else if (typeof opts.entry === "string") await import(
|
|
94
95
|
/* @vite-ignore */
|
package/dist/prod-server.mjs
CHANGED
|
@@ -90,6 +90,7 @@ async function createSSRServer(options) {
|
|
|
90
90
|
setTimeout(() => args.filter((a) => typeof a === "function").forEach((a) => a()), 1);
|
|
91
91
|
return Promise.resolve();
|
|
92
92
|
};
|
|
93
|
+
// @vite-ignore keeps rolldown from trying to resolve the substituted literal
|
|
93
94
|
if (typeof opts.entry === "function") await opts.entry();
|
|
94
95
|
else if (typeof opts.entry === "string") await import(
|
|
95
96
|
/* @vite-ignore */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moostjs/vite",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.24",
|
|
4
4
|
"description": "Vite Dev plugin for moostjs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"composables",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"sirv": "^3.0.0",
|
|
60
60
|
"vite": "^8.0.0",
|
|
61
|
-
"@moostjs/event-http": "^0.6.
|
|
62
|
-
"moost": "^0.6.
|
|
61
|
+
"@moostjs/event-http": "^0.6.24",
|
|
62
|
+
"moost": "^0.6.24"
|
|
63
63
|
},
|
|
64
64
|
"peerDependenciesMeta": {
|
|
65
65
|
"sirv": {
|