vitrify 0.13.2 → 0.14.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/dist/bin/cli.js +1 -1
- package/dist/bin/dev.js +2 -2
- package/dist/frameworks/vue/fastify-csr-plugin.js +1 -2
- package/dist/frameworks/vue/fastify-ssr-plugin.js +2 -3
- package/dist/index.js +27 -11
- package/dist/plugins/quasar.js +4 -4
- package/dist/types/bin/dev.d.ts +3 -3
- package/dist/types/frameworks/vue/fastify-csr-plugin.d.ts +2 -2
- package/dist/types/frameworks/vue/fastify-ssr-plugin.d.ts +2 -2
- package/package.json +35 -34
- package/src/node/bin/cli.ts +1 -1
- package/src/node/bin/dev.ts +1 -1
- package/src/node/frameworks/vue/fastify-csr-plugin.ts +3 -9
- package/src/node/frameworks/vue/fastify-ssr-plugin.ts +4 -11
- package/src/node/index.ts +33 -10
- package/src/node/plugins/quasar.ts +3 -4
package/dist/bin/cli.js
CHANGED
|
@@ -80,7 +80,7 @@ cli
|
|
|
80
80
|
prerender({
|
|
81
81
|
outDir: fileURLToPath(new URL('static/', baseOutDir)),
|
|
82
82
|
templatePath: fileURLToPath(new URL('static/index.html', baseOutDir)),
|
|
83
|
-
manifestPath: fileURLToPath(new URL('static/ssr-manifest.json', baseOutDir)),
|
|
83
|
+
manifestPath: fileURLToPath(new URL('static/.vite/ssr-manifest.json', baseOutDir)),
|
|
84
84
|
entryServerPath: new URL('ssr/server/entry-server.mjs', baseOutDir),
|
|
85
85
|
onRendered
|
|
86
86
|
});
|
package/dist/bin/dev.js
CHANGED
|
@@ -52,7 +52,7 @@ ssr, framework = 'vue', host, appDir, publicDir, base }) {
|
|
|
52
52
|
// middlewareMode: mode === 'ssr' ? 'ssr' : undefined,
|
|
53
53
|
middlewareMode: ssr ? true : false,
|
|
54
54
|
fs: {
|
|
55
|
-
strict: false,
|
|
55
|
+
strict: false, // https://github.com/vitejs/vite/issues/8175
|
|
56
56
|
allow: [
|
|
57
57
|
searchForWorkspaceRoot(process.cwd()),
|
|
58
58
|
searchForWorkspaceRoot(fileURLToPath(appDir)),
|
|
@@ -138,7 +138,7 @@ ssr, framework = 'vue', host, appDir, publicDir, vite }) {
|
|
|
138
138
|
if (vite && app) {
|
|
139
139
|
await app.ready();
|
|
140
140
|
await app.close();
|
|
141
|
-
({ app, server } = await createServer({
|
|
141
|
+
({ app, server, vite } = await createServer({
|
|
142
142
|
ssr: 'fastify',
|
|
143
143
|
host: host,
|
|
144
144
|
appDir,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fastifyStatic from '@fastify/static';
|
|
2
2
|
import { fileURLToPath } from 'url';
|
|
3
|
-
const fastifyCsrPlugin = async (fastify, options
|
|
3
|
+
const fastifyCsrPlugin = async (fastify, options) => {
|
|
4
4
|
options.vitrifyDir =
|
|
5
5
|
options.vitrifyDir || (await import('vitrify')).vitrifyDir;
|
|
6
6
|
const frameworkDir = new URL('src/vite/vue/', options.vitrifyDir);
|
|
@@ -35,6 +35,5 @@ const fastifyCsrPlugin = async (fastify, options, done) => {
|
|
|
35
35
|
prefix: options.baseUrl
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
|
-
done();
|
|
39
38
|
};
|
|
40
39
|
export { fastifyCsrPlugin };
|
|
@@ -2,7 +2,7 @@ import fastifyStatic from '@fastify/static';
|
|
|
2
2
|
import { readFileSync } from 'fs';
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
import { addOrReplaceAppDiv, appendToBody, appendToHead } from '../../helpers/utils.js';
|
|
5
|
-
const fastifySsrPlugin = async (fastify, options
|
|
5
|
+
const fastifySsrPlugin = async (fastify, options) => {
|
|
6
6
|
options.baseUrl = options.baseUrl || '/';
|
|
7
7
|
options.mode = options.mode || process.env.MODE || import.meta.env.MODE;
|
|
8
8
|
options.appDir = options.appDir || new URL('../../..', import.meta.url);
|
|
@@ -113,7 +113,7 @@ const fastifySsrPlugin = async (fastify, options, done) => {
|
|
|
113
113
|
provide
|
|
114
114
|
};
|
|
115
115
|
const template = readFileSync(fileURLToPath(new URL('./dist/ssr/client/index.html', options.appDir))).toString();
|
|
116
|
-
const manifest = JSON.parse(readFileSync(new URL('./dist/ssr/client/ssr-manifest.json', options.appDir)).toString());
|
|
116
|
+
const manifest = JSON.parse(readFileSync(new URL('./dist/ssr/client/.vite/ssr-manifest.json', options.appDir)).toString());
|
|
117
117
|
const render = (await import(fileURLToPath(new URL('./dist/ssr/server/entry-server.mjs', options.appDir)))).render;
|
|
118
118
|
const [appHtml, preloadLinks] = await render(url, manifest, ssrContext);
|
|
119
119
|
if (!ssrContext.initialState)
|
|
@@ -144,6 +144,5 @@ const fastifySsrPlugin = async (fastify, options, done) => {
|
|
|
144
144
|
res.send(html);
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
|
-
done();
|
|
148
147
|
};
|
|
149
148
|
export { fastifySsrPlugin };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import vuePlugin from '@vitejs/plugin-vue';
|
|
2
|
-
import {
|
|
2
|
+
import { findDepPkgJsonPath } from 'vitefu';
|
|
3
3
|
import { mergeConfig } from 'vite';
|
|
4
4
|
import { build } from 'esbuild';
|
|
5
5
|
import fs from 'fs';
|
|
@@ -190,9 +190,9 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
190
190
|
const packageUrls = vitrifyConfig.vitrify?.urls?.packages || {};
|
|
191
191
|
await (async () => {
|
|
192
192
|
for (const val of localPackages) {
|
|
193
|
-
const
|
|
194
|
-
if (
|
|
195
|
-
packageUrls[val] = new URL(`file://${
|
|
193
|
+
const pkgDir = await findDepPkgJsonPath(val, fileURLToPath(appDir));
|
|
194
|
+
if (pkgDir)
|
|
195
|
+
packageUrls[val] = new URL(`file://${pkgDir}`);
|
|
196
196
|
}
|
|
197
197
|
})();
|
|
198
198
|
// await (async () => {
|
|
@@ -384,8 +384,8 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
384
384
|
name: 'html-transform',
|
|
385
385
|
enforce: 'pre',
|
|
386
386
|
transformIndexHtml: {
|
|
387
|
-
|
|
388
|
-
|
|
387
|
+
order: 'pre',
|
|
388
|
+
handler: (html) => {
|
|
389
389
|
let entry;
|
|
390
390
|
switch (ssr) {
|
|
391
391
|
case 'ssg':
|
|
@@ -436,16 +436,31 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
436
436
|
if (debug)
|
|
437
437
|
plugins.push(visualizer());
|
|
438
438
|
}
|
|
439
|
+
// Vue now only exports CJS for Node
|
|
440
|
+
// Add the deps as devDependency
|
|
441
|
+
const vueInternalPkgs = [
|
|
442
|
+
'@vue/runtime-dom',
|
|
443
|
+
'@vue/runtime-core',
|
|
444
|
+
'@vue/reactivity',
|
|
445
|
+
'@vue/shared',
|
|
446
|
+
'@vue/server-renderer'
|
|
447
|
+
];
|
|
448
|
+
const vuePkgAliases = [];
|
|
449
|
+
for (const pkg of vueInternalPkgs) {
|
|
450
|
+
const specifier = pkg.split('/').at(-1);
|
|
451
|
+
const pkgJsonPath = await findDepPkgJsonPath(pkg, fileURLToPath(appDir));
|
|
452
|
+
if (pkgJsonPath)
|
|
453
|
+
vuePkgAliases.push({
|
|
454
|
+
find: pkg,
|
|
455
|
+
replacement: fileURLToPath(new URL(`./dist/${specifier}.esm-bundler.js`, `file://${pkgJsonPath}` || ''))
|
|
456
|
+
});
|
|
457
|
+
}
|
|
439
458
|
const alias = [
|
|
440
459
|
{ find: 'src', replacement: fileURLToPath(srcDir) },
|
|
441
460
|
{ find: 'app', replacement: fileURLToPath(appDir) },
|
|
442
461
|
{ find: 'cwd', replacement: fileURLToPath(cwd) },
|
|
443
462
|
{ find: 'boot', replacement: fileURLToPath(new URL('boot/', srcDir)) },
|
|
444
463
|
{ find: 'assets', replacement: fileURLToPath(new URL('assets/', srcDir)) },
|
|
445
|
-
// ...Object.entries(packageUrls).map(([key, value]) => ({
|
|
446
|
-
// find: key,
|
|
447
|
-
// replacement: value.pathname
|
|
448
|
-
// }))
|
|
449
464
|
{
|
|
450
465
|
find: new RegExp('^vue$'),
|
|
451
466
|
replacement: fileURLToPath(new URL('./dist/vue.runtime.esm-bundler.js', packageUrls['vue']))
|
|
@@ -453,7 +468,8 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
453
468
|
{
|
|
454
469
|
find: new RegExp('^vue-router$'),
|
|
455
470
|
replacement: fileURLToPath(new URL('./dist/vue-router.esm-bundler.js', packageUrls['vue-router']))
|
|
456
|
-
}
|
|
471
|
+
},
|
|
472
|
+
...vuePkgAliases
|
|
457
473
|
];
|
|
458
474
|
if (mode === 'development' && vitrifyConfig.vitrify?.dev?.alias)
|
|
459
475
|
alias.push(...vitrifyConfig.vitrify.dev.alias);
|
package/dist/plugins/quasar.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { resolvePackageData } from 'vite';
|
|
2
1
|
import { fileURLToPath } from 'url';
|
|
2
|
+
import { findDepPkgJsonPath } from 'vitefu';
|
|
3
3
|
export const injectSsrContext = (html, ssrContext) => html
|
|
4
4
|
.replace(/(<html[^>]*)(>)/i, (found, start, end) => {
|
|
5
5
|
let matches;
|
|
@@ -52,9 +52,9 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
|
|
|
52
52
|
// const localPackages: string[] = []
|
|
53
53
|
await (async () => {
|
|
54
54
|
for (const val of localPackages) {
|
|
55
|
-
const
|
|
56
|
-
if (
|
|
57
|
-
urls.packages[val] = new URL(`file://${
|
|
55
|
+
const pkgDir = await findDepPkgJsonPath(val, fileURLToPath(config.vitrify.urls.app));
|
|
56
|
+
if (pkgDir)
|
|
57
|
+
urls.packages[val] = new URL(`file://${pkgDir}`);
|
|
58
58
|
}
|
|
59
59
|
})();
|
|
60
60
|
const onMountedHooks = [
|
package/dist/types/bin/dev.d.ts
CHANGED
|
@@ -47,8 +47,8 @@ export declare function createServer({ port, logLevel, ssr, framework, host, app
|
|
|
47
47
|
resolve: Required<import("vite").ResolveOptions> & {
|
|
48
48
|
alias: import("vite").Alias[];
|
|
49
49
|
};
|
|
50
|
-
plugins: readonly import("vite").Plugin[];
|
|
51
|
-
css: import("vite").ResolvedCSSOptions
|
|
50
|
+
plugins: readonly import("vite").Plugin<any>[];
|
|
51
|
+
css: import("vite").ResolvedCSSOptions;
|
|
52
52
|
esbuild: false | import("vite").ESBuildOptions;
|
|
53
53
|
server: import("vite").ResolvedServerOptions;
|
|
54
54
|
build: import("vite").ResolvedBuildOptions;
|
|
@@ -58,7 +58,7 @@ export declare function createServer({ port, logLevel, ssr, framework, host, app
|
|
|
58
58
|
logger: import("vite").Logger;
|
|
59
59
|
createResolver: (options?: Partial<import("vite").InternalResolveOptions> | undefined) => import("vite").ResolveFn;
|
|
60
60
|
optimizeDeps: import("vite").DepOptimizationOptions;
|
|
61
|
-
worker: import("vite").
|
|
61
|
+
worker: import("vite").ResolvedWorkerOptions;
|
|
62
62
|
appType: import("vite").AppType;
|
|
63
63
|
experimental: import("vite").ExperimentalOptions;
|
|
64
64
|
} & import("vite").PluginHookUtils>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FastifyPluginAsync, FastifyRequest, FastifyReply } from 'fastify';
|
|
2
2
|
import type { ViteDevServer } from 'vite';
|
|
3
3
|
export interface FastifySsrOptions {
|
|
4
4
|
baseUrl?: string;
|
|
@@ -10,6 +10,6 @@ export interface FastifySsrOptions {
|
|
|
10
10
|
productName?: string;
|
|
11
11
|
mode?: string;
|
|
12
12
|
}
|
|
13
|
-
declare const fastifyCsrPlugin:
|
|
13
|
+
declare const fastifyCsrPlugin: FastifyPluginAsync<FastifySsrOptions>;
|
|
14
14
|
export { fastifyCsrPlugin };
|
|
15
15
|
export type FastifyCsrPlugin = typeof fastifyCsrPlugin;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FastifyPluginAsync, FastifyRequest, FastifyReply } from 'fastify';
|
|
2
2
|
import type { ViteDevServer } from 'vite';
|
|
3
3
|
import type { OnRenderedHook } from '../../vitrify-config.js';
|
|
4
4
|
export interface FastifySsrOptions {
|
|
@@ -14,6 +14,6 @@ export interface FastifySsrOptions {
|
|
|
14
14
|
mode?: string;
|
|
15
15
|
host?: string;
|
|
16
16
|
}
|
|
17
|
-
declare const fastifySsrPlugin:
|
|
17
|
+
declare const fastifySsrPlugin: FastifyPluginAsync<FastifySsrOptions>;
|
|
18
18
|
export { fastifySsrPlugin };
|
|
19
19
|
export type FastifySsrPlugin = typeof fastifySsrPlugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitrify",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Stefan van Herwijnen",
|
|
6
6
|
"description": "Vite as your Full Stack development tool",
|
|
@@ -48,52 +48,53 @@
|
|
|
48
48
|
"test": "vitest test/"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@fastify/middie": "^8.
|
|
52
|
-
"@fastify/static": "^6.
|
|
53
|
-
"@
|
|
54
|
-
"@vitejs/plugin-vue": "^4.2.1",
|
|
51
|
+
"@fastify/middie": "^8.3.0",
|
|
52
|
+
"@fastify/static": "^6.12.0",
|
|
53
|
+
"@vitejs/plugin-vue": "^5.0.3",
|
|
55
54
|
"ajv": "^8.12.0",
|
|
56
55
|
"builtin-modules": "^3.3.0",
|
|
57
56
|
"cac": "^6.7.14",
|
|
58
|
-
"chalk": "^5.
|
|
59
|
-
"critters": "^0.0.
|
|
57
|
+
"chalk": "^5.3.0",
|
|
58
|
+
"critters": "^0.0.20",
|
|
60
59
|
"cross-env": "^7.0.3",
|
|
61
|
-
"esbuild": "^0.
|
|
62
|
-
"fastify": "^4.
|
|
63
|
-
"glob": "^10.
|
|
64
|
-
"happy-dom": "^
|
|
60
|
+
"esbuild": "^0.20.0",
|
|
61
|
+
"fastify": "^4.25.2",
|
|
62
|
+
"glob": "^10.3.10",
|
|
63
|
+
"happy-dom": "^13.3.4",
|
|
65
64
|
"is-port-reachable": "^4.0.0",
|
|
66
|
-
"magic-string": "^0.30.
|
|
65
|
+
"magic-string": "^0.30.5",
|
|
67
66
|
"merge-deep": "^3.0.3",
|
|
68
67
|
"readline": "^1.3.0",
|
|
69
|
-
"rollup-plugin-visualizer": "^5.
|
|
70
|
-
"sass": "1.
|
|
71
|
-
"ts-node": "^10.9.
|
|
72
|
-
"unplugin-vue-components": "^0.
|
|
73
|
-
"vite": "^
|
|
74
|
-
"vite-plugin-pwa": "^0.
|
|
75
|
-
"
|
|
68
|
+
"rollup-plugin-visualizer": "^5.12.0",
|
|
69
|
+
"sass": "1.70.0",
|
|
70
|
+
"ts-node": "^10.9.2",
|
|
71
|
+
"unplugin-vue-components": "^0.26.0",
|
|
72
|
+
"vite": "^5.0.12",
|
|
73
|
+
"vite-plugin-pwa": "^0.17.5",
|
|
74
|
+
"vitefu": "^0.2.5",
|
|
75
|
+
"vitest": "^1.2.2",
|
|
76
76
|
"workbox-window": "^7.0.0"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
|
-
"@
|
|
79
|
+
"@quasar/extras": "^1.16.9",
|
|
80
|
+
"@types/connect": "^3.4.38",
|
|
80
81
|
"@types/glob": "^8.1.0",
|
|
81
|
-
"@types/merge-deep": "^3.0.
|
|
82
|
-
"@types/node": "^
|
|
83
|
-
"@types/ws": "^8.5.
|
|
84
|
-
"@vue/runtime-core": "^3.
|
|
85
|
-
"quasar": "^2.
|
|
86
|
-
"rollup": "^
|
|
87
|
-
"typescript": "^5.
|
|
88
|
-
"vue": "^3.
|
|
89
|
-
"vue-router": "^4.
|
|
82
|
+
"@types/merge-deep": "^3.0.3",
|
|
83
|
+
"@types/node": "^20.11.10",
|
|
84
|
+
"@types/ws": "^8.5.10",
|
|
85
|
+
"@vue/runtime-core": "^3.4.15",
|
|
86
|
+
"quasar": "^2.14.3",
|
|
87
|
+
"rollup": "^4.9.6",
|
|
88
|
+
"typescript": "^5.3.3",
|
|
89
|
+
"vue": "^3.4.15",
|
|
90
|
+
"vue-router": "^4.2.5"
|
|
90
91
|
},
|
|
91
92
|
"peerDependencies": {
|
|
92
|
-
"@fastify/static": "^6.
|
|
93
|
-
"fastify": "^4.
|
|
94
|
-
"quasar": "^2.
|
|
95
|
-
"vue": "^3.
|
|
96
|
-
"vue-router": "^4.
|
|
93
|
+
"@fastify/static": "^6.12.0",
|
|
94
|
+
"fastify": "^4.26.0",
|
|
95
|
+
"quasar": "^2.14.3",
|
|
96
|
+
"vue": "^3.4.15",
|
|
97
|
+
"vue-router": "^4.2.5"
|
|
97
98
|
},
|
|
98
99
|
"publishConfig": {
|
|
99
100
|
"access": "public",
|
package/src/node/bin/cli.ts
CHANGED
|
@@ -96,7 +96,7 @@ cli
|
|
|
96
96
|
outDir: fileURLToPath(new URL('static/', baseOutDir)),
|
|
97
97
|
templatePath: fileURLToPath(new URL('static/index.html', baseOutDir)),
|
|
98
98
|
manifestPath: fileURLToPath(
|
|
99
|
-
new URL('static/ssr-manifest.json', baseOutDir)
|
|
99
|
+
new URL('static/.vite/ssr-manifest.json', baseOutDir)
|
|
100
100
|
),
|
|
101
101
|
entryServerPath: new URL('ssr/server/entry-server.mjs', baseOutDir),
|
|
102
102
|
onRendered
|
package/src/node/bin/dev.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
FastifyPluginCallback,
|
|
3
|
-
FastifyRequest,
|
|
4
|
-
FastifyReply
|
|
5
|
-
} from 'fastify'
|
|
1
|
+
import type { FastifyPluginAsync, FastifyRequest, FastifyReply } from 'fastify'
|
|
6
2
|
import fastifyStatic from '@fastify/static'
|
|
7
3
|
import type { ViteDevServer } from 'vite'
|
|
8
4
|
import { fileURLToPath } from 'url'
|
|
@@ -21,10 +17,9 @@ export interface FastifySsrOptions {
|
|
|
21
17
|
mode?: string
|
|
22
18
|
}
|
|
23
19
|
|
|
24
|
-
const fastifyCsrPlugin:
|
|
20
|
+
const fastifyCsrPlugin: FastifyPluginAsync<FastifySsrOptions> = async (
|
|
25
21
|
fastify,
|
|
26
|
-
options
|
|
27
|
-
done
|
|
22
|
+
options
|
|
28
23
|
) => {
|
|
29
24
|
options.vitrifyDir =
|
|
30
25
|
options.vitrifyDir || (await import('vitrify')).vitrifyDir
|
|
@@ -64,7 +59,6 @@ const fastifyCsrPlugin: FastifyPluginCallback<FastifySsrOptions> = async (
|
|
|
64
59
|
prefix: options.baseUrl
|
|
65
60
|
})
|
|
66
61
|
}
|
|
67
|
-
done()
|
|
68
62
|
}
|
|
69
63
|
|
|
70
64
|
export { fastifyCsrPlugin }
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
FastifyPluginCallback,
|
|
3
|
-
FastifyRequest,
|
|
4
|
-
FastifyReply
|
|
5
|
-
} from 'fastify'
|
|
1
|
+
import type { FastifyPluginAsync, FastifyRequest, FastifyReply } from 'fastify'
|
|
6
2
|
import fastifyStatic from '@fastify/static'
|
|
7
3
|
import { readFileSync } from 'fs'
|
|
8
4
|
import { fileURLToPath } from 'url'
|
|
@@ -31,10 +27,9 @@ export interface FastifySsrOptions {
|
|
|
31
27
|
host?: string
|
|
32
28
|
}
|
|
33
29
|
|
|
34
|
-
const fastifySsrPlugin:
|
|
30
|
+
const fastifySsrPlugin: FastifyPluginAsync<FastifySsrOptions> = async (
|
|
35
31
|
fastify,
|
|
36
|
-
options
|
|
37
|
-
done
|
|
32
|
+
options
|
|
38
33
|
) => {
|
|
39
34
|
options.baseUrl = options.baseUrl || '/'
|
|
40
35
|
options.mode = options.mode || process.env.MODE || import.meta.env.MODE
|
|
@@ -174,7 +169,7 @@ const fastifySsrPlugin: FastifyPluginCallback<FastifySsrOptions> = async (
|
|
|
174
169
|
).toString()
|
|
175
170
|
const manifest = JSON.parse(
|
|
176
171
|
readFileSync(
|
|
177
|
-
new URL('./dist/ssr/client/ssr-manifest.json', options.appDir)
|
|
172
|
+
new URL('./dist/ssr/client/.vite/ssr-manifest.json', options.appDir)
|
|
178
173
|
).toString()
|
|
179
174
|
)
|
|
180
175
|
const render = (
|
|
@@ -223,8 +218,6 @@ const fastifySsrPlugin: FastifyPluginCallback<FastifySsrOptions> = async (
|
|
|
223
218
|
res.send(html)
|
|
224
219
|
})
|
|
225
220
|
}
|
|
226
|
-
|
|
227
|
-
done()
|
|
228
221
|
}
|
|
229
222
|
|
|
230
223
|
export { fastifySsrPlugin }
|
package/src/node/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import vuePlugin from '@vitejs/plugin-vue'
|
|
2
2
|
import type { Alias, InlineConfig, UserConfig } from 'vite'
|
|
3
|
-
import {
|
|
3
|
+
import { findDepPkgJsonPath } from 'vitefu'
|
|
4
4
|
import { mergeConfig } from 'vite'
|
|
5
5
|
import { build } from 'esbuild'
|
|
6
6
|
import fs from 'fs'
|
|
@@ -261,8 +261,8 @@ export const baseConfig = async ({
|
|
|
261
261
|
vitrifyConfig.vitrify?.urls?.packages || {}
|
|
262
262
|
await (async () => {
|
|
263
263
|
for (const val of localPackages) {
|
|
264
|
-
const
|
|
265
|
-
if (
|
|
264
|
+
const pkgDir = await findDepPkgJsonPath(val, fileURLToPath(appDir))
|
|
265
|
+
if (pkgDir) packageUrls![val] = new URL(`file://${pkgDir}`)
|
|
266
266
|
}
|
|
267
267
|
})()
|
|
268
268
|
|
|
@@ -475,8 +475,8 @@ export const baseConfig = async ({
|
|
|
475
475
|
name: 'html-transform',
|
|
476
476
|
enforce: 'pre',
|
|
477
477
|
transformIndexHtml: {
|
|
478
|
-
|
|
479
|
-
|
|
478
|
+
order: 'pre',
|
|
479
|
+
handler: (html) => {
|
|
480
480
|
let entry: string
|
|
481
481
|
switch (ssr) {
|
|
482
482
|
case 'ssg':
|
|
@@ -531,16 +531,38 @@ export const baseConfig = async ({
|
|
|
531
531
|
if (debug) plugins.push(visualizer())
|
|
532
532
|
}
|
|
533
533
|
|
|
534
|
+
// Vue now only exports CJS for Node
|
|
535
|
+
// Add the deps as devDependency
|
|
536
|
+
const vueInternalPkgs = [
|
|
537
|
+
'@vue/runtime-dom',
|
|
538
|
+
'@vue/runtime-core',
|
|
539
|
+
'@vue/reactivity',
|
|
540
|
+
'@vue/shared',
|
|
541
|
+
'@vue/server-renderer'
|
|
542
|
+
]
|
|
543
|
+
|
|
544
|
+
const vuePkgAliases: Alias[] = []
|
|
545
|
+
for (const pkg of vueInternalPkgs) {
|
|
546
|
+
const specifier = pkg.split('/').at(-1)
|
|
547
|
+
const pkgJsonPath = await findDepPkgJsonPath(pkg, fileURLToPath(appDir!))
|
|
548
|
+
if (pkgJsonPath)
|
|
549
|
+
vuePkgAliases.push({
|
|
550
|
+
find: pkg,
|
|
551
|
+
replacement: fileURLToPath(
|
|
552
|
+
new URL(
|
|
553
|
+
`./dist/${specifier}.esm-bundler.js`,
|
|
554
|
+
`file://${pkgJsonPath}` || ''
|
|
555
|
+
)
|
|
556
|
+
)
|
|
557
|
+
})
|
|
558
|
+
}
|
|
559
|
+
|
|
534
560
|
const alias: Alias[] = [
|
|
535
561
|
{ find: 'src', replacement: fileURLToPath(srcDir) },
|
|
536
562
|
{ find: 'app', replacement: fileURLToPath(appDir) },
|
|
537
563
|
{ find: 'cwd', replacement: fileURLToPath(cwd) },
|
|
538
564
|
{ find: 'boot', replacement: fileURLToPath(new URL('boot/', srcDir)) },
|
|
539
565
|
{ find: 'assets', replacement: fileURLToPath(new URL('assets/', srcDir)) },
|
|
540
|
-
// ...Object.entries(packageUrls).map(([key, value]) => ({
|
|
541
|
-
// find: key,
|
|
542
|
-
// replacement: value.pathname
|
|
543
|
-
// }))
|
|
544
566
|
{
|
|
545
567
|
find: new RegExp('^vue$'),
|
|
546
568
|
replacement: fileURLToPath(
|
|
@@ -552,7 +574,8 @@ export const baseConfig = async ({
|
|
|
552
574
|
replacement: fileURLToPath(
|
|
553
575
|
new URL('./dist/vue-router.esm-bundler.js', packageUrls['vue-router'])
|
|
554
576
|
)
|
|
555
|
-
}
|
|
577
|
+
},
|
|
578
|
+
...vuePkgAliases
|
|
556
579
|
]
|
|
557
580
|
if (mode === 'development' && vitrifyConfig.vitrify?.dev?.alias)
|
|
558
581
|
alias.push(...vitrifyConfig.vitrify.dev.alias)
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import type { Plugin } from 'vite'
|
|
2
|
-
import { resolvePackageData } from 'vite'
|
|
3
2
|
import { fileURLToPath } from 'url'
|
|
4
|
-
import Components from 'unplugin-vue-components/vite'
|
|
5
3
|
import type {
|
|
6
4
|
OnBootHook,
|
|
7
5
|
OnMountedHook,
|
|
8
6
|
VitrifyConfig
|
|
9
7
|
} from '../vitrify-config.js'
|
|
10
8
|
import type { VitrifyPlugin } from './index.js'
|
|
9
|
+
import { findDepPkgJsonPath } from 'vitefu'
|
|
11
10
|
export interface QuasarConf {
|
|
12
11
|
ctx?: Record<string, any>
|
|
13
12
|
css?: string[]
|
|
@@ -114,11 +113,11 @@ export const QuasarPlugin: VitrifyPlugin = async ({
|
|
|
114
113
|
// const localPackages: string[] = []
|
|
115
114
|
await (async () => {
|
|
116
115
|
for (const val of localPackages) {
|
|
117
|
-
const
|
|
116
|
+
const pkgDir = await findDepPkgJsonPath(
|
|
118
117
|
val,
|
|
119
118
|
fileURLToPath(config.vitrify!.urls!.app!)
|
|
120
119
|
)
|
|
121
|
-
if (
|
|
120
|
+
if (pkgDir) urls!.packages![val] = new URL(`file://${pkgDir}`)
|
|
122
121
|
}
|
|
123
122
|
})()
|
|
124
123
|
|