vitrify 0.26.0 → 0.26.2
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 → node/bin}/cli.js +0 -0
- package/dist/{bin → node/bin}/dev.js +5 -1
- package/dist/{frameworks → node/frameworks}/vue/fastify-ssr-plugin.js +1 -1
- package/dist/{index.js → node/index.js} +67 -33
- package/dist/types/{frameworks → node/frameworks}/vue/prerender.d.ts +1 -1
- package/dist/types/{plugins → node/plugins}/quasar/index.d.ts +2 -1
- package/package.json +36 -36
- package/src/node/bin/dev.ts +5 -1
- package/src/node/frameworks/vue/fastify-ssr-plugin.ts +3 -1
- package/src/node/frameworks/vue/prerender.ts +1 -1
- package/src/node/index.ts +72 -38
- package/src/node/plugins/quasar/index.ts +1 -1
- package/src/vite/fastify/entry.ts +5 -3
- package/src/vite/vue/RootComponent.vue +5 -3
- package/src/vite/vue/csr/app.ts +2 -2
- package/src/vite/vue/main.ts +5 -3
- package/src/vite/vue/ssr/app.ts +5 -9
- package/src/vite/vue/ssr/prerender.ts +2 -2
- package/src/vite/vue/ssr/server.ts +3 -0
- /package/dist/{app-urls.js → node/app-urls.js} +0 -0
- /package/dist/{bin → node/bin}/build.js +0 -0
- /package/dist/{bin → node/bin}/run.js +0 -0
- /package/dist/{bin → node/bin}/test.js +0 -0
- /package/dist/{frameworks → node/frameworks}/vue/fastify-csr-plugin.js +0 -0
- /package/dist/{frameworks → node/frameworks}/vue/prerender.js +0 -0
- /package/dist/{frameworks → node/frameworks}/vue/server.js +0 -0
- /package/dist/{helpers → node/helpers}/collect-css-ssr.js +0 -0
- /package/dist/{helpers → node/helpers}/logger.js +0 -0
- /package/dist/{helpers → node/helpers}/routes.js +0 -0
- /package/dist/{helpers → node/helpers}/utils.js +0 -0
- /package/dist/{hooks → node/hooks}/index.js +0 -0
- /package/dist/{plugins → node/plugins}/index.js +0 -0
- /package/dist/{plugins → node/plugins}/pinia/index.js +0 -0
- /package/dist/{plugins → node/plugins}/quasar/index.js +0 -0
- /package/dist/{prerender.js → node/prerender.js} +0 -0
- /package/dist/{vitrify-config.js → node/vitrify-config.js} +0 -0
- /package/dist/types/{app-urls.d.ts → node/app-urls.d.ts} +0 -0
- /package/dist/types/{bin → node/bin}/build.d.ts +0 -0
- /package/dist/types/{bin → node/bin}/cli.d.ts +0 -0
- /package/dist/types/{bin → node/bin}/dev.d.ts +0 -0
- /package/dist/types/{bin → node/bin}/run.d.ts +0 -0
- /package/dist/types/{bin → node/bin}/test.d.ts +0 -0
- /package/dist/types/{frameworks → node/frameworks}/vue/fastify-csr-plugin.d.ts +0 -0
- /package/dist/types/{frameworks → node/frameworks}/vue/fastify-ssr-plugin.d.ts +0 -0
- /package/dist/types/{frameworks → node/frameworks}/vue/server.d.ts +0 -0
- /package/dist/types/{helpers → node/helpers}/collect-css-ssr.d.ts +0 -0
- /package/dist/types/{helpers → node/helpers}/logger.d.ts +0 -0
- /package/dist/types/{helpers → node/helpers}/routes.d.ts +0 -0
- /package/dist/types/{helpers → node/helpers}/utils.d.ts +0 -0
- /package/dist/types/{hooks → node/hooks}/index.d.ts +0 -0
- /package/dist/types/{index.d.ts → node/index.d.ts} +0 -0
- /package/dist/types/{plugins → node/plugins}/index.d.ts +0 -0
- /package/dist/types/{plugins → node/plugins}/pinia/index.d.ts +0 -0
- /package/dist/types/{prerender.d.ts → node/prerender.d.ts} +0 -0
- /package/dist/types/{vitrify-config.d.ts → node/vitrify-config.d.ts} +0 -0
|
File without changes
|
|
@@ -98,7 +98,11 @@ ssr, framework = 'vue', host, appDir, publicDir, vite }) {
|
|
|
98
98
|
? fileURLToPath(new URL('src/vite/fastify/entry.ts', cliDir))
|
|
99
99
|
: fileURLToPath(new URL(`src/vite/${framework}/ssr/app.ts`, cliDir));
|
|
100
100
|
const environment = vite.environments.ssr;
|
|
101
|
-
({
|
|
101
|
+
({
|
|
102
|
+
setup,
|
|
103
|
+
hooks: { onTemplateRendered, onAppRendered },
|
|
104
|
+
vitrifyConfig
|
|
105
|
+
} =
|
|
102
106
|
// @ts-expect-error missing types
|
|
103
107
|
await environment.runner.import(entryUrl));
|
|
104
108
|
app = fastify({
|
|
@@ -191,7 +191,7 @@ const loadSSRAssets = async ({ mode, distDir } = {
|
|
|
191
191
|
const manifest = JSON.parse(readFileSync(manifestPath).toString());
|
|
192
192
|
const entryServer = await import(entryServerPath);
|
|
193
193
|
const { render, getRoutes } = entryServer;
|
|
194
|
-
const { onTemplateRendered, onAppRendered } = await import(vitrifyHooksPath);
|
|
194
|
+
const { hooks: { onTemplateRendered, onAppRendered } } = await import(vitrifyHooksPath);
|
|
195
195
|
return {
|
|
196
196
|
template,
|
|
197
197
|
manifest,
|
|
@@ -31,8 +31,8 @@ const internalServerModules = [
|
|
|
31
31
|
const manualChunkNames = [
|
|
32
32
|
'prerender',
|
|
33
33
|
'fastify-ssr-plugin',
|
|
34
|
-
'fastify-csr-plugin'
|
|
35
|
-
'server'
|
|
34
|
+
'fastify-csr-plugin'
|
|
35
|
+
// 'server'
|
|
36
36
|
];
|
|
37
37
|
const moduleChunks = {
|
|
38
38
|
vue: [
|
|
@@ -53,28 +53,6 @@ const moduleChunks = {
|
|
|
53
53
|
quasar: ['quasar'],
|
|
54
54
|
atQuasar: ['@quasar']
|
|
55
55
|
};
|
|
56
|
-
const manualChunksFn = (manualChunkList) => {
|
|
57
|
-
return (id) => {
|
|
58
|
-
const matchedModule = Object.entries(moduleChunks).find(([chunkName, moduleNames]) => moduleNames.some((moduleName) => new RegExp(`\/${moduleName}\/`).test(id)));
|
|
59
|
-
if (id.includes('vitrify/src/')) {
|
|
60
|
-
const name = id.split('/').at(-1)?.split('.').at(0);
|
|
61
|
-
if (name && manualChunkNames.includes(name))
|
|
62
|
-
return name;
|
|
63
|
-
}
|
|
64
|
-
else if (VIRTUAL_MODULES.some((virtualModule) => id.includes(virtualModule))) {
|
|
65
|
-
return VIRTUAL_MODULES.find((name) => id.includes(name));
|
|
66
|
-
}
|
|
67
|
-
else if (manualChunkList?.some((file) => id.includes(file))) {
|
|
68
|
-
return manualChunkList.find((file) => id.includes(file));
|
|
69
|
-
}
|
|
70
|
-
else if (id.includes('node_modules')) {
|
|
71
|
-
if (matchedModule) {
|
|
72
|
-
return matchedModule[0];
|
|
73
|
-
}
|
|
74
|
-
return 'vendor';
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
56
|
export const VIRTUAL_MODULES = [
|
|
79
57
|
'virtual:vitrify-hooks',
|
|
80
58
|
'virtual:static-imports',
|
|
@@ -82,6 +60,49 @@ export const VIRTUAL_MODULES = [
|
|
|
82
60
|
'vitrify.sass',
|
|
83
61
|
'vitrify.css'
|
|
84
62
|
];
|
|
63
|
+
/**
|
|
64
|
+
* Advanced chunking may no longer be necessary.
|
|
65
|
+
* @param ssr
|
|
66
|
+
* @returns
|
|
67
|
+
*/
|
|
68
|
+
const createCodeSplittingGroups = (ssr) => {
|
|
69
|
+
return [
|
|
70
|
+
...VIRTUAL_MODULES.map((m) => ({
|
|
71
|
+
name: m,
|
|
72
|
+
test: new RegExp(m),
|
|
73
|
+
priority: 30
|
|
74
|
+
})),
|
|
75
|
+
{
|
|
76
|
+
test: /(?<!@)quasar/,
|
|
77
|
+
name: 'quasar'
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
test: /@quasar/,
|
|
81
|
+
name: 'at_quasar'
|
|
82
|
+
}
|
|
83
|
+
// ...manualChunkNames.map((m) => ({
|
|
84
|
+
// name: m,
|
|
85
|
+
// test: new RegExp(m),
|
|
86
|
+
// priority: 20
|
|
87
|
+
// })),
|
|
88
|
+
// ...Object.entries(moduleChunks).map(([key, value]) => ({
|
|
89
|
+
// name: key,
|
|
90
|
+
// test: new RegExp(value.join('|')),
|
|
91
|
+
// priority: 20,
|
|
92
|
+
// maxSize: ssr === 'client' || ssr === 'ssg' ? 1000000 : Infinity
|
|
93
|
+
// })),
|
|
94
|
+
// {
|
|
95
|
+
// name: 'vendor',
|
|
96
|
+
// test: /node_modules/,
|
|
97
|
+
// priority: 1
|
|
98
|
+
// },
|
|
99
|
+
// {
|
|
100
|
+
// name: 'typst',
|
|
101
|
+
// test: /\.typ/,
|
|
102
|
+
// priority: 40
|
|
103
|
+
// }
|
|
104
|
+
];
|
|
105
|
+
};
|
|
85
106
|
export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command = 'build', mode = 'production', framework = 'vue', debug = false, productName }) => {
|
|
86
107
|
const { getAppDir, getCliDir, getCliViteDir, getSrcDir, getCwd } = await import('./app-urls.js');
|
|
87
108
|
if (!appDir) {
|
|
@@ -280,7 +301,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
280
301
|
},
|
|
281
302
|
load(id) {
|
|
282
303
|
if (id === 'virtual:vitrify-hooks') {
|
|
283
|
-
return `
|
|
304
|
+
return `const onAppMounted = [${onAppMountedHooks
|
|
284
305
|
.map((fn) => `${String(fn)}`)
|
|
285
306
|
.join(', ')}]
|
|
286
307
|
${onAppMountedFiles
|
|
@@ -296,7 +317,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
296
317
|
return `import ${varName} from '${new URL(url, appDir).href}'; onAppMounted.push(${varName});`;
|
|
297
318
|
})
|
|
298
319
|
.join('\n')}
|
|
299
|
-
|
|
320
|
+
const onAppRendered = [${onAppRenderedHooks
|
|
300
321
|
.map((fn) => `${String(fn)}`)
|
|
301
322
|
.join(', ')}]
|
|
302
323
|
${onAppRenderedFiles
|
|
@@ -312,7 +333,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
312
333
|
return `import ${varName} from '${new URL(url, appDir).href}'; onAppRendered.push(${varName});`;
|
|
313
334
|
})
|
|
314
335
|
.join('\n')}
|
|
315
|
-
|
|
336
|
+
const onTemplateRendered = [${onTemplateRenderedHooks
|
|
316
337
|
.map((fn) => `${String(fn)}`)
|
|
317
338
|
.join(', ')}]
|
|
318
339
|
${onTemplateRenderedFiles
|
|
@@ -328,7 +349,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
328
349
|
return `import ${varName} from '${new URL(url, appDir).href}'; onTemplateRendered.push(${varName});`;
|
|
329
350
|
})
|
|
330
351
|
.join('\n')}
|
|
331
|
-
|
|
352
|
+
const onAppCreated = [${OnAppCreatedHooks.map((fn) => `${String(fn)}`).join(', ')}]
|
|
332
353
|
${onAppCreatedFiles
|
|
333
354
|
.map((url, index) => {
|
|
334
355
|
const varName = fileURLToPath(url)
|
|
@@ -342,7 +363,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
342
363
|
return `import ${varName} from '${new URL(url, appDir).href}'; onAppCreated.push(${varName});`;
|
|
343
364
|
})
|
|
344
365
|
.join('\n')}
|
|
345
|
-
|
|
366
|
+
const onSetup = []
|
|
346
367
|
${onSetupFiles
|
|
347
368
|
.map((url, index) => {
|
|
348
369
|
const varName = fileURLToPath(url)
|
|
@@ -355,7 +376,14 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
355
376
|
.replaceAll('+', '');
|
|
356
377
|
return `import ${varName} from '${new URL(url, appDir).href}'; onSetup.push(${varName});`;
|
|
357
378
|
})
|
|
358
|
-
.join('\n')}
|
|
379
|
+
.join('\n')}
|
|
380
|
+
export const hooks = {
|
|
381
|
+
onAppMounted,
|
|
382
|
+
onAppRendered,
|
|
383
|
+
onAppCreated,
|
|
384
|
+
onTemplateRendered,
|
|
385
|
+
onSetup
|
|
386
|
+
}`;
|
|
359
387
|
}
|
|
360
388
|
else if (id === 'virtual:static-imports') {
|
|
361
389
|
return `${Object.entries(staticImports)
|
|
@@ -522,7 +550,9 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
522
550
|
entryFileNames: '[name].mjs',
|
|
523
551
|
chunkFileNames: '[name].mjs',
|
|
524
552
|
format: 'es',
|
|
525
|
-
|
|
553
|
+
codeSplitting: {
|
|
554
|
+
groups: createCodeSplittingGroups(ssr)
|
|
555
|
+
}
|
|
526
556
|
}
|
|
527
557
|
};
|
|
528
558
|
// Create a SSR bundle
|
|
@@ -540,7 +570,9 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
540
570
|
entryFileNames: '[name].mjs',
|
|
541
571
|
chunkFileNames: '[name].mjs',
|
|
542
572
|
format: 'es',
|
|
543
|
-
|
|
573
|
+
codeSplitting: {
|
|
574
|
+
groups: createCodeSplittingGroups(ssr)
|
|
575
|
+
}
|
|
544
576
|
}
|
|
545
577
|
};
|
|
546
578
|
// Create a SSR bundle
|
|
@@ -557,7 +589,9 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
557
589
|
entryFileNames: '[name].mjs',
|
|
558
590
|
chunkFileNames: '[name].mjs',
|
|
559
591
|
format: 'es',
|
|
560
|
-
|
|
592
|
+
codeSplitting: {
|
|
593
|
+
groups: createCodeSplittingGroups(ssr)
|
|
594
|
+
}
|
|
561
595
|
}
|
|
562
596
|
};
|
|
563
597
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { OnTemplateRenderedHook } from '
|
|
1
|
+
import type { OnTemplateRenderedHook } from '../../../node/vitrify-config.js';
|
|
2
2
|
import { type RouteRecordRaw } from 'vue-router';
|
|
3
3
|
export declare const prerender: ({ outDir, template, manifest, render, routes, onTemplateRendered }: {
|
|
4
4
|
outDir: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { OnTemplateRenderedHook } from '../../vitrify-config.js';
|
|
2
2
|
import type { VitrifyPlugin } from '../index.js';
|
|
3
|
-
import { type
|
|
3
|
+
import { type QuasarComponents, type QuasarDirectives, type QuasarIconSets, type QuasarPlugins, type GlobalQuasarIconMapFn, type QuasarIconSet } from 'quasar';
|
|
4
|
+
import type { QuasarFonts } from '@quasar/extras';
|
|
4
5
|
export interface QuasarPluginOptions {
|
|
5
6
|
framework: {
|
|
6
7
|
components?: (keyof QuasarComponents)[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitrify",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Stefan van Herwijnen",
|
|
6
6
|
"description": "Vite as your Full Stack development tool",
|
|
@@ -52,72 +52,72 @@
|
|
|
52
52
|
},
|
|
53
53
|
"homepage": "https://github.com/simsustech/vitrify/tree/main/#readme",
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@fastify/middie": "^9.3.
|
|
55
|
+
"@fastify/middie": "^9.3.2",
|
|
56
56
|
"@fastify/one-line-logger": "^2.1.0",
|
|
57
|
-
"@fastify/static": "^9.
|
|
58
|
-
"@unocss/core": "^66.6.
|
|
59
|
-
"@unocss/preset-uno": "^66.6.
|
|
60
|
-
"@unocss/preset-web-fonts": "66.6.
|
|
61
|
-
"@unocss/preset-wind": "^66.6.
|
|
62
|
-
"@vitejs/plugin-vue": "^6.0.
|
|
63
|
-
"ajv": "^8.
|
|
57
|
+
"@fastify/static": "^9.1.3",
|
|
58
|
+
"@unocss/core": "^66.6.8",
|
|
59
|
+
"@unocss/preset-uno": "^66.6.8",
|
|
60
|
+
"@unocss/preset-web-fonts": "66.6.8",
|
|
61
|
+
"@unocss/preset-wind": "^66.6.8",
|
|
62
|
+
"@vitejs/plugin-vue": "^6.0.6",
|
|
63
|
+
"ajv": "^8.20.0",
|
|
64
64
|
"animated-unocss": "^0.0.6",
|
|
65
65
|
"cac": "^7.0.0",
|
|
66
66
|
"chalk": "^5.6.2",
|
|
67
67
|
"cross-env": "^10.1.0",
|
|
68
|
-
"devalue": "^5.
|
|
69
|
-
"fastify": "^5.8.
|
|
68
|
+
"devalue": "^5.7.1",
|
|
69
|
+
"fastify": "^5.8.5",
|
|
70
70
|
"glob": "^13.0.6",
|
|
71
|
-
"happy-dom": "^20.
|
|
71
|
+
"happy-dom": "^20.9.0",
|
|
72
72
|
"is-port-reachable": "^4.0.0",
|
|
73
73
|
"magic-string": "^0.30.21",
|
|
74
74
|
"merge-deep": "^3.0.3",
|
|
75
75
|
"readline": "^1.3.0",
|
|
76
|
-
"rolldown": "1.0.0-rc.
|
|
76
|
+
"rolldown": "1.0.0-rc.17",
|
|
77
77
|
"rollup-plugin-visualizer": "^7.0.1",
|
|
78
|
-
"sass": "1.
|
|
78
|
+
"sass": "1.99.0",
|
|
79
79
|
"stringify-object": "^6.0.0",
|
|
80
80
|
"ts-node": "^10.9.2",
|
|
81
|
-
"unocss": "^66.6.
|
|
82
|
-
"unplugin-vue-components": "^
|
|
83
|
-
"vite": "^8.0.
|
|
81
|
+
"unocss": "^66.6.8",
|
|
82
|
+
"unplugin-vue-components": "^32.0.0",
|
|
83
|
+
"vite": "^8.0.10",
|
|
84
84
|
"vite-plugin-pwa": "^1.2.0",
|
|
85
|
-
"vitefu": "^1.1.
|
|
86
|
-
"vitest": "^4.1.
|
|
85
|
+
"vitefu": "^1.1.3",
|
|
86
|
+
"vitest": "^4.1.5",
|
|
87
87
|
"workbox-window": "^7.4.0"
|
|
88
88
|
},
|
|
89
89
|
"devDependencies": {
|
|
90
90
|
"@iconify-json/mdi": "^1.2.3",
|
|
91
|
-
"@pinia/colada": "^1.
|
|
92
|
-
"@quasar/extras": "^1.
|
|
91
|
+
"@pinia/colada": "^1.2.0",
|
|
92
|
+
"@quasar/extras": "^1.18.0",
|
|
93
93
|
"@quasar/quasar-ui-qmarkdown": "^2.0.5",
|
|
94
94
|
"@quasar/quasar-ui-qmediaplayer": "^2.0.0-beta.0",
|
|
95
95
|
"@types/connect": "^3.4.38",
|
|
96
96
|
"@types/glob": "^9.0.0",
|
|
97
97
|
"@types/merge-deep": "^3.0.3",
|
|
98
|
-
"@types/node": "^25.
|
|
98
|
+
"@types/node": "^25.6.0",
|
|
99
99
|
"@types/stringify-object": "^4.0.5",
|
|
100
100
|
"@types/ws": "^8.18.1",
|
|
101
|
-
"@unocss/preset-icons": "^66.6.
|
|
102
|
-
"@vue/runtime-core": "^3.5.
|
|
103
|
-
"beasties": "^0.4.
|
|
101
|
+
"@unocss/preset-icons": "^66.6.8",
|
|
102
|
+
"@vue/runtime-core": "^3.5.33",
|
|
103
|
+
"beasties": "^0.4.2",
|
|
104
104
|
"css": "^3.0.0",
|
|
105
105
|
"css-to-tailwind-translator": "^1.2.8",
|
|
106
106
|
"pinia": "^3.0.4",
|
|
107
|
-
"quasar": "^2.
|
|
108
|
-
"rollup": "^4.
|
|
109
|
-
"typescript": "^
|
|
110
|
-
"vue": "^3.5.
|
|
111
|
-
"vue-router": "^5.0.
|
|
107
|
+
"quasar": "^2.19.3",
|
|
108
|
+
"rollup": "^4.60.2",
|
|
109
|
+
"typescript": "^6.0.3",
|
|
110
|
+
"vue": "^3.5.33",
|
|
111
|
+
"vue-router": "^5.0.6"
|
|
112
112
|
},
|
|
113
113
|
"peerDependencies": {
|
|
114
|
-
"@fastify/static": "^9.
|
|
115
|
-
"@pinia/colada": "^1.
|
|
116
|
-
"fastify": "^5.8.
|
|
114
|
+
"@fastify/static": "^9.1.3",
|
|
115
|
+
"@pinia/colada": "^1.2.0",
|
|
116
|
+
"fastify": "^5.8.5",
|
|
117
117
|
"pinia": "^3.0.4",
|
|
118
|
-
"quasar": "^2.
|
|
119
|
-
"vue": "^3.5.
|
|
120
|
-
"vue-router": "^5.0.
|
|
118
|
+
"quasar": "^2.19.3",
|
|
119
|
+
"vue": "^3.5.33",
|
|
120
|
+
"vue-router": "^5.0.6"
|
|
121
121
|
},
|
|
122
122
|
"publishConfig": {
|
|
123
123
|
"access": "public",
|
package/src/node/bin/dev.ts
CHANGED
|
@@ -177,7 +177,11 @@ export async function createServer({
|
|
|
177
177
|
: fileURLToPath(new URL(`src/vite/${framework}/ssr/app.ts`, cliDir))
|
|
178
178
|
|
|
179
179
|
const environment = vite.environments.ssr
|
|
180
|
-
;({
|
|
180
|
+
;({
|
|
181
|
+
setup,
|
|
182
|
+
hooks: { onTemplateRendered, onAppRendered },
|
|
183
|
+
vitrifyConfig
|
|
184
|
+
} =
|
|
181
185
|
// @ts-expect-error missing types
|
|
182
186
|
await environment.runner.import(entryUrl))
|
|
183
187
|
|
|
@@ -307,7 +307,9 @@ const loadSSRAssets = async (
|
|
|
307
307
|
const manifest = JSON.parse(readFileSync(manifestPath).toString())
|
|
308
308
|
const entryServer = await import(entryServerPath)
|
|
309
309
|
const { render, getRoutes } = entryServer
|
|
310
|
-
const {
|
|
310
|
+
const {
|
|
311
|
+
hooks: { onTemplateRendered, onAppRendered }
|
|
312
|
+
} = await import(vitrifyHooksPath)
|
|
311
313
|
|
|
312
314
|
return {
|
|
313
315
|
template,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { existsSync, promises as fs, mkdirSync } from 'fs'
|
|
2
|
-
import type { OnTemplateRenderedHook } from '
|
|
2
|
+
import type { OnTemplateRenderedHook } from '../../../node/vitrify-config.js'
|
|
3
3
|
import { routesToPaths } from '../../helpers/routes.js'
|
|
4
4
|
import { renderHtml } from './fastify-ssr-plugin.js'
|
|
5
5
|
import { type RouteRecordRaw } from 'vue-router'
|
package/src/node/index.ts
CHANGED
|
@@ -34,12 +34,12 @@ import type {
|
|
|
34
34
|
import type { VitrifyContext } from './bin/run.js'
|
|
35
35
|
import type { VitrifyPlugin } from './plugins/index.js'
|
|
36
36
|
import { resolve } from './app-urls.js'
|
|
37
|
-
import type { ManualChunksOption, RollupOptions } from 'rollup'
|
|
38
37
|
import { addOrReplaceTitle, appendToBody } from './helpers/utils.js'
|
|
39
38
|
import Components from 'unplugin-vue-components/vite'
|
|
40
39
|
import { VitePWA } from 'vite-plugin-pwa'
|
|
41
40
|
import UnoCSS from 'unocss/vite'
|
|
42
41
|
import { searchForWorkspaceRoot } from 'vite'
|
|
42
|
+
import { CodeSplittingGroup, RolldownOptions } from 'rolldown'
|
|
43
43
|
|
|
44
44
|
const internalServerModules = [
|
|
45
45
|
'util',
|
|
@@ -60,8 +60,8 @@ const internalServerModules = [
|
|
|
60
60
|
const manualChunkNames = [
|
|
61
61
|
'prerender',
|
|
62
62
|
'fastify-ssr-plugin',
|
|
63
|
-
'fastify-csr-plugin'
|
|
64
|
-
'server'
|
|
63
|
+
'fastify-csr-plugin'
|
|
64
|
+
// 'server'
|
|
65
65
|
]
|
|
66
66
|
|
|
67
67
|
const moduleChunks = {
|
|
@@ -83,31 +83,6 @@ const moduleChunks = {
|
|
|
83
83
|
quasar: ['quasar'],
|
|
84
84
|
atQuasar: ['@quasar']
|
|
85
85
|
}
|
|
86
|
-
const manualChunksFn = (manualChunkList?: string[]): ManualChunksOption => {
|
|
87
|
-
return (id: string) => {
|
|
88
|
-
const matchedModule = Object.entries(moduleChunks).find(
|
|
89
|
-
([chunkName, moduleNames]) =>
|
|
90
|
-
moduleNames.some((moduleName) =>
|
|
91
|
-
new RegExp(`\/${moduleName}\/`).test(id)
|
|
92
|
-
)
|
|
93
|
-
)
|
|
94
|
-
if (id.includes('vitrify/src/')) {
|
|
95
|
-
const name = id.split('/').at(-1)?.split('.').at(0)
|
|
96
|
-
if (name && manualChunkNames.includes(name)) return name
|
|
97
|
-
} else if (
|
|
98
|
-
VIRTUAL_MODULES.some((virtualModule) => id.includes(virtualModule))
|
|
99
|
-
) {
|
|
100
|
-
return VIRTUAL_MODULES.find((name) => id.includes(name))
|
|
101
|
-
} else if (manualChunkList?.some((file) => id.includes(file))) {
|
|
102
|
-
return manualChunkList.find((file) => id.includes(file))
|
|
103
|
-
} else if (id.includes('node_modules')) {
|
|
104
|
-
if (matchedModule) {
|
|
105
|
-
return matchedModule[0]
|
|
106
|
-
}
|
|
107
|
-
return 'vendor'
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
86
|
|
|
112
87
|
export const VIRTUAL_MODULES = [
|
|
113
88
|
'virtual:vitrify-hooks',
|
|
@@ -117,6 +92,52 @@ export const VIRTUAL_MODULES = [
|
|
|
117
92
|
'vitrify.css'
|
|
118
93
|
]
|
|
119
94
|
|
|
95
|
+
/**
|
|
96
|
+
* Advanced chunking may no longer be necessary.
|
|
97
|
+
* @param ssr
|
|
98
|
+
* @returns
|
|
99
|
+
*/
|
|
100
|
+
const createCodeSplittingGroups = (
|
|
101
|
+
ssr?: VitrifySSRModes
|
|
102
|
+
): CodeSplittingGroup[] => {
|
|
103
|
+
return [
|
|
104
|
+
...VIRTUAL_MODULES.map((m) => ({
|
|
105
|
+
name: m,
|
|
106
|
+
test: new RegExp(m),
|
|
107
|
+
priority: 30
|
|
108
|
+
})),
|
|
109
|
+
{
|
|
110
|
+
test: /(?<!@)quasar/,
|
|
111
|
+
name: 'quasar'
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
test: /@quasar/,
|
|
115
|
+
name: 'at_quasar'
|
|
116
|
+
}
|
|
117
|
+
// ...manualChunkNames.map((m) => ({
|
|
118
|
+
// name: m,
|
|
119
|
+
// test: new RegExp(m),
|
|
120
|
+
// priority: 20
|
|
121
|
+
// })),
|
|
122
|
+
// ...Object.entries(moduleChunks).map(([key, value]) => ({
|
|
123
|
+
// name: key,
|
|
124
|
+
// test: new RegExp(value.join('|')),
|
|
125
|
+
// priority: 20,
|
|
126
|
+
// maxSize: ssr === 'client' || ssr === 'ssg' ? 1000000 : Infinity
|
|
127
|
+
// })),
|
|
128
|
+
// {
|
|
129
|
+
// name: 'vendor',
|
|
130
|
+
// test: /node_modules/,
|
|
131
|
+
// priority: 1
|
|
132
|
+
// },
|
|
133
|
+
// {
|
|
134
|
+
// name: 'typst',
|
|
135
|
+
// test: /\.typ/,
|
|
136
|
+
// priority: 40
|
|
137
|
+
// }
|
|
138
|
+
]
|
|
139
|
+
}
|
|
140
|
+
|
|
120
141
|
export const baseConfig = async ({
|
|
121
142
|
ssr,
|
|
122
143
|
appDir,
|
|
@@ -358,7 +379,7 @@ export const baseConfig = async ({
|
|
|
358
379
|
},
|
|
359
380
|
load(id) {
|
|
360
381
|
if (id === 'virtual:vitrify-hooks') {
|
|
361
|
-
return `
|
|
382
|
+
return `const onAppMounted = [${onAppMountedHooks
|
|
362
383
|
.map((fn) => `${String(fn)}`)
|
|
363
384
|
.join(', ')}]
|
|
364
385
|
${onAppMountedFiles
|
|
@@ -377,7 +398,7 @@ export const baseConfig = async ({
|
|
|
377
398
|
}'; onAppMounted.push(${varName});`
|
|
378
399
|
})
|
|
379
400
|
.join('\n')}
|
|
380
|
-
|
|
401
|
+
const onAppRendered = [${onAppRenderedHooks
|
|
381
402
|
.map((fn) => `${String(fn)}`)
|
|
382
403
|
.join(', ')}]
|
|
383
404
|
${onAppRenderedFiles
|
|
@@ -396,7 +417,7 @@ export const baseConfig = async ({
|
|
|
396
417
|
}'; onAppRendered.push(${varName});`
|
|
397
418
|
})
|
|
398
419
|
.join('\n')}
|
|
399
|
-
|
|
420
|
+
const onTemplateRendered = [${onTemplateRenderedHooks
|
|
400
421
|
.map((fn) => `${String(fn)}`)
|
|
401
422
|
.join(', ')}]
|
|
402
423
|
${onTemplateRenderedFiles
|
|
@@ -415,7 +436,7 @@ export const baseConfig = async ({
|
|
|
415
436
|
}'; onTemplateRendered.push(${varName});`
|
|
416
437
|
})
|
|
417
438
|
.join('\n')}
|
|
418
|
-
|
|
439
|
+
const onAppCreated = [${OnAppCreatedHooks.map(
|
|
419
440
|
(fn) => `${String(fn)}`
|
|
420
441
|
).join(', ')}]
|
|
421
442
|
${onAppCreatedFiles
|
|
@@ -434,7 +455,7 @@ export const baseConfig = async ({
|
|
|
434
455
|
}'; onAppCreated.push(${varName});`
|
|
435
456
|
})
|
|
436
457
|
.join('\n')}
|
|
437
|
-
|
|
458
|
+
const onSetup = []
|
|
438
459
|
${onSetupFiles
|
|
439
460
|
.map((url, index) => {
|
|
440
461
|
const varName = fileURLToPath(url)
|
|
@@ -450,7 +471,14 @@ export const baseConfig = async ({
|
|
|
450
471
|
new URL(url, appDir).href
|
|
451
472
|
}'; onSetup.push(${varName});`
|
|
452
473
|
})
|
|
453
|
-
.join('\n')}
|
|
474
|
+
.join('\n')}
|
|
475
|
+
export const hooks = {
|
|
476
|
+
onAppMounted,
|
|
477
|
+
onAppRendered,
|
|
478
|
+
onAppCreated,
|
|
479
|
+
onTemplateRendered,
|
|
480
|
+
onSetup
|
|
481
|
+
}`
|
|
454
482
|
} else if (id === 'virtual:static-imports') {
|
|
455
483
|
return `${Object.entries(staticImports)
|
|
456
484
|
.map(([key, value]) => {
|
|
@@ -623,7 +651,7 @@ export const baseConfig = async ({
|
|
|
623
651
|
replacement: fileURLToPath(new URL(await resolve('vitest', cliDir)))
|
|
624
652
|
})
|
|
625
653
|
|
|
626
|
-
let rollupOptions:
|
|
654
|
+
let rollupOptions: RolldownOptions = {}
|
|
627
655
|
let noExternal: RegExp[] | string[] = [
|
|
628
656
|
new RegExp(`^(?!(${[...builtinModules, ...serverModules].join('|')}))`)
|
|
629
657
|
]
|
|
@@ -644,7 +672,9 @@ export const baseConfig = async ({
|
|
|
644
672
|
entryFileNames: '[name].mjs',
|
|
645
673
|
chunkFileNames: '[name].mjs',
|
|
646
674
|
format: 'es',
|
|
647
|
-
|
|
675
|
+
codeSplitting: {
|
|
676
|
+
groups: createCodeSplittingGroups(ssr)
|
|
677
|
+
}
|
|
648
678
|
}
|
|
649
679
|
}
|
|
650
680
|
// Create a SSR bundle
|
|
@@ -661,7 +691,9 @@ export const baseConfig = async ({
|
|
|
661
691
|
entryFileNames: '[name].mjs',
|
|
662
692
|
chunkFileNames: '[name].mjs',
|
|
663
693
|
format: 'es',
|
|
664
|
-
|
|
694
|
+
codeSplitting: {
|
|
695
|
+
groups: createCodeSplittingGroups(ssr)
|
|
696
|
+
}
|
|
665
697
|
}
|
|
666
698
|
}
|
|
667
699
|
// Create a SSR bundle
|
|
@@ -677,7 +709,9 @@ export const baseConfig = async ({
|
|
|
677
709
|
entryFileNames: '[name].mjs',
|
|
678
710
|
chunkFileNames: '[name].mjs',
|
|
679
711
|
format: 'es',
|
|
680
|
-
|
|
712
|
+
codeSplitting: {
|
|
713
|
+
groups: createCodeSplittingGroups(ssr)
|
|
714
|
+
}
|
|
681
715
|
}
|
|
682
716
|
}
|
|
683
717
|
}
|
|
@@ -8,7 +8,6 @@ import type {
|
|
|
8
8
|
import type { VitrifyPlugin } from '../index.js'
|
|
9
9
|
import { findDepPkgJsonPath } from 'vitefu'
|
|
10
10
|
import {
|
|
11
|
-
type QuasarFonts,
|
|
12
11
|
type QuasarComponents,
|
|
13
12
|
type QuasarDirectives,
|
|
14
13
|
type QuasarIconSets,
|
|
@@ -16,6 +15,7 @@ import {
|
|
|
16
15
|
type GlobalQuasarIconMapFn,
|
|
17
16
|
type QuasarIconSet
|
|
18
17
|
} from 'quasar'
|
|
18
|
+
import type { QuasarFonts } from '@quasar/extras'
|
|
19
19
|
import { QuasarResolver } from 'unplugin-vue-components/resolvers'
|
|
20
20
|
|
|
21
21
|
export interface QuasarPluginOptions {
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { FastifyInstance } from 'fastify'
|
|
2
|
-
import {
|
|
2
|
+
import { hooks } from 'virtual:vitrify-hooks'
|
|
3
3
|
export { default as vitrifyConfig } from 'virtual:vitrify-config'
|
|
4
4
|
|
|
5
5
|
export const setup = async ({ fastify }: { fastify: FastifyInstance }) => {
|
|
6
|
-
if (onSetup?.length) {
|
|
7
|
-
for (const setup of onSetup) {
|
|
6
|
+
if (hooks.onSetup?.length) {
|
|
7
|
+
for (const setup of hooks.onSetup) {
|
|
8
8
|
await setup(fastify)
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
11
|
return fastify
|
|
12
12
|
}
|
|
13
|
+
|
|
14
|
+
export { hooks }
|
|
@@ -8,15 +8,17 @@ import {
|
|
|
8
8
|
onMounted as onMountedVue,
|
|
9
9
|
getCurrentInstance
|
|
10
10
|
} from 'vue'
|
|
11
|
-
import {
|
|
11
|
+
import { hooks } from 'virtual:vitrify-hooks'
|
|
12
12
|
import App from 'src/App.vue'
|
|
13
13
|
// import 'vitrify.sass'
|
|
14
14
|
const instance = getCurrentInstance()
|
|
15
15
|
const props = defineProps()
|
|
16
16
|
|
|
17
17
|
onMountedVue(async () => {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
if (hooks.onAppMounted) {
|
|
19
|
+
for (let fn of hooks.onAppMounted) {
|
|
20
|
+
await fn({ instance })
|
|
21
|
+
}
|
|
20
22
|
}
|
|
21
23
|
})
|
|
22
24
|
|
package/src/vite/vue/csr/app.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createApp } from '../../../node/frameworks/vue/server.js'
|
|
2
2
|
import { getAppDir } from '../../../node/app-urls.js'
|
|
3
3
|
// import { setup } from 'virtual:fastify-setup'
|
|
4
|
-
import {
|
|
4
|
+
import { hooks } from 'virtual:vitrify-hooks'
|
|
5
5
|
import { fastifyCsrPlugin } from './fastify-csr-plugin'
|
|
6
6
|
|
|
7
7
|
// const appDir = getPkgJsonDir(import.meta.url)
|
|
@@ -12,7 +12,7 @@ const appDir = getAppDir()
|
|
|
12
12
|
export const setupApp = async () => {
|
|
13
13
|
// const vitrifyDir = new URL('../', await resolve('vitrify', new URL(import.meta.url)))
|
|
14
14
|
return createApp({
|
|
15
|
-
onSetup,
|
|
15
|
+
onSetup: hooks.onSetup,
|
|
16
16
|
appDir,
|
|
17
17
|
baseUrl,
|
|
18
18
|
fastifyPlugin: fastifyCsrPlugin,
|
package/src/vite/vue/main.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import createRouter from 'src/router'
|
|
2
2
|
import { App, createSSRApp, createApp as createVueApp, ref } from 'vue'
|
|
3
|
-
import {
|
|
3
|
+
import { hooks } from 'virtual:vitrify-hooks'
|
|
4
4
|
import routes from 'src/router/routes'
|
|
5
5
|
import * as staticImports from 'virtual:static-imports'
|
|
6
6
|
import 'virtual:uno.css'
|
|
@@ -69,8 +69,10 @@ export async function createApp(
|
|
|
69
69
|
const router = createRouter()
|
|
70
70
|
app.use(router)
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
if (hooks.onAppCreated) {
|
|
73
|
+
for (const fn of hooks.onAppCreated) {
|
|
74
|
+
await fn({ app, router, ctx, initialState, ssrContext, staticImports })
|
|
75
|
+
}
|
|
74
76
|
}
|
|
75
77
|
|
|
76
78
|
// Workaround to fix hydration errors when serving html files directly
|
package/src/vite/vue/ssr/app.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { createApp } from '../../../node/frameworks/vue/server.js'
|
|
2
2
|
import { getAppDir } from '../../../node/app-urls.js'
|
|
3
|
-
import {
|
|
4
|
-
onSetup,
|
|
5
|
-
onAppRendered,
|
|
6
|
-
onTemplateRendered
|
|
7
|
-
} from 'virtual:vitrify-hooks'
|
|
3
|
+
import { hooks } from 'virtual:vitrify-hooks'
|
|
8
4
|
import { fastifySsrPlugin } from './fastify-ssr-plugin.js'
|
|
9
5
|
|
|
10
6
|
const getString = (str?: string) => str
|
|
@@ -13,15 +9,15 @@ const appDir = getAppDir()
|
|
|
13
9
|
|
|
14
10
|
export const setupApp = async () => {
|
|
15
11
|
return createApp({
|
|
16
|
-
onSetup,
|
|
12
|
+
onSetup: hooks.onSetup,
|
|
17
13
|
appDir,
|
|
18
14
|
baseUrl,
|
|
19
15
|
fastifyPlugin: fastifySsrPlugin,
|
|
20
|
-
onAppRendered,
|
|
21
|
-
onTemplateRendered,
|
|
16
|
+
onAppRendered: hooks.onAppRendered,
|
|
17
|
+
onTemplateRendered: hooks.onTemplateRendered,
|
|
22
18
|
mode: import.meta.env.MODE
|
|
23
19
|
})
|
|
24
20
|
}
|
|
25
21
|
|
|
26
22
|
export { default as vitrifyConfig } from 'virtual:vitrify-config'
|
|
27
|
-
export {
|
|
23
|
+
export { hooks }
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|