vitrify 0.6.14 → 0.6.17

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 CHANGED
@@ -16,6 +16,7 @@ cli
16
16
  const { build } = await import('./build.js');
17
17
  let appDir;
18
18
  let prerender;
19
+ let onRendered;
19
20
  if (options.appDir) {
20
21
  if (options.appDir.slice(-1) !== '/')
21
22
  options.appDir += '/';
@@ -68,14 +69,16 @@ cli
68
69
  ...args,
69
70
  outDir: new URL('ssr/server/', baseOutDir).pathname
70
71
  });
71
- ({ prerender } = await import(new URL('ssr/server/prerender.mjs', baseOutDir).pathname));
72
+ ({ prerender, onRendered } = await import(new URL('ssr/server/prerender.mjs', baseOutDir).pathname));
73
+ console.log(onRendered);
72
74
  prerender({
73
75
  outDir: new URL('static/', baseOutDir).pathname,
74
76
  templatePath: new URL('static/index.html', baseOutDir).pathname,
75
77
  manifestPath: new URL('static/ssr-manifest.json', baseOutDir)
76
78
  .pathname,
77
79
  entryServerPath: new URL('ssr/server/entry-server.mjs', baseOutDir)
78
- .pathname
80
+ .pathname,
81
+ onRendered
79
82
  });
80
83
  break;
81
84
  default:
package/dist/bin/dev.js CHANGED
@@ -76,14 +76,15 @@ ssr, framework = 'vue', host, appDir, publicDir }) {
76
76
  });
77
77
  let setup;
78
78
  let server;
79
+ let onRendered;
79
80
  console.log(`Development mode: ${ssr ? ssr : 'csr'}`);
80
81
  if (ssr) {
81
82
  const entryUrl = ssr === 'fastify'
82
83
  ? new URL('src/vite/fastify/entry.ts', cliDir).pathname
83
- : new URL(`src/vite/${framework}/ssr/entry-server.ts`, cliDir).pathname;
84
- ({ setup } = await vite.ssrLoadModule(entryUrl));
84
+ : new URL(`src/vite/${framework}/ssr/app.ts`, cliDir).pathname;
85
+ ({ setup, onRendered } = await vite.ssrLoadModule(entryUrl));
85
86
  const app = fastify({
86
- logger: true,
87
+ logger: false,
87
88
  https: vite.config.server.https
88
89
  });
89
90
  if (process.env)
@@ -96,7 +97,8 @@ ssr, framework = 'vue', host, appDir, publicDir }) {
96
97
  if (ssr === 'ssr') {
97
98
  await app.register(fastifySsrPlugin, {
98
99
  appDir,
99
- mode: 'development'
100
+ mode: 'development',
101
+ onRendered
100
102
  });
101
103
  }
102
104
  await app.listen({
@@ -56,7 +56,6 @@ const fastifySsrPlugin = async (fastify, options, done) => {
56
56
  // configFile: false,
57
57
  // ...config
58
58
  // })
59
- console.log('Dev mode');
60
59
  if (!('use' in fastify)) {
61
60
  const middie = (await import('@fastify/middie')).default;
62
61
  await fastify.register(middie);
@@ -65,9 +64,11 @@ const fastifySsrPlugin = async (fastify, options, done) => {
65
64
  fastify.get(`${options.baseUrl}*`, async (req, res) => {
66
65
  try {
67
66
  const url = req.raw.url?.replace(options.baseUrl, '/');
67
+ const provide = options.provide ? await options.provide(req, res) : {};
68
68
  const ssrContext = {
69
69
  req,
70
- res
70
+ res,
71
+ provide
71
72
  };
72
73
  let template = readFileSync(new URL('index.html', frameworkDir)).toString();
73
74
  template = await vite.transformIndexHtml(url, template);
@@ -90,11 +91,16 @@ const fastifySsrPlugin = async (fastify, options, done) => {
90
91
  mods: matchedModules
91
92
  });
92
93
  const [appHtml, preloadLinks] = await render(url, manifest, ssrContext);
93
- const html = template
94
+ let html = template
94
95
  .replace(`<!--preload-links-->`, preloadLinks)
95
96
  .replace(`<!--app-html-->`, appHtml)
96
97
  .replace('<!--product-name-->', options.productName || 'Product name')
97
98
  .replace('<!--dev-ssr-css-->', css);
99
+ if (options.onRendered?.length) {
100
+ for (const ssrFunction of options.onRendered) {
101
+ html = ssrFunction(html, ssrContext);
102
+ }
103
+ }
98
104
  res.code(200);
99
105
  res.type('text/html');
100
106
  res.send(html);
@@ -131,9 +137,14 @@ const fastifySsrPlugin = async (fastify, options, done) => {
131
137
  if (!ssrContext.initialState)
132
138
  ssrContext.initialState = {};
133
139
  ssrContext.initialState.provide = provide;
134
- const html = template
140
+ let html = template
135
141
  .replace(`<!--preload-links-->`, preloadLinks)
136
142
  .replace(`<!--app-html-->`, appHtml);
143
+ if (options.onRendered?.length) {
144
+ for (const ssrFunction of options.onRendered) {
145
+ html = ssrFunction(html, ssrContext);
146
+ }
147
+ }
137
148
  res.code(200);
138
149
  res.type('text/html');
139
150
  res.send(html);
@@ -1,6 +1,6 @@
1
1
  import { promises as fs } from 'fs';
2
2
  import { routesToPaths } from '../../helpers/routes.js';
3
- export const prerender = async ({ outDir, templatePath, manifestPath, entryServerPath }) => {
3
+ export const prerender = async ({ outDir, templatePath, manifestPath, entryServerPath, onRendered }) => {
4
4
  const promises = [];
5
5
  const template = (await fs.readFile(templatePath)).toString();
6
6
  const manifest = await fs.readFile(manifestPath);
@@ -25,6 +25,11 @@ export const prerender = async ({ outDir, templatePath, manifestPath, entryServe
25
25
  let html = template
26
26
  .replace(`<!--preload-links-->`, preloadLinks)
27
27
  .replace(`<!--app-html-->`, appHtml);
28
+ if (onRendered?.length) {
29
+ for (const ssrFunction of onRendered) {
30
+ html = ssrFunction(html, ssrContext);
31
+ }
32
+ }
28
33
  html = await critters.process(html);
29
34
  promises.push(fs.writeFile(outDir + filename, html, 'utf-8'));
30
35
  }
@@ -1,5 +1,5 @@
1
1
  import fastify from 'fastify';
2
- export const createApp = ({ onSetup, appDir, baseUrl, fastifyPlugin, vitrifyDir, mode }) => {
2
+ export const createApp = ({ onSetup, appDir, baseUrl, fastifyPlugin, onRendered, vitrifyDir, mode }) => {
3
3
  const app = fastify({
4
4
  logger: true
5
5
  });
@@ -7,6 +7,7 @@ export const createApp = ({ onSetup, appDir, baseUrl, fastifyPlugin, vitrifyDir,
7
7
  baseUrl,
8
8
  appDir,
9
9
  vitrifyDir,
10
+ onRendered,
10
11
  mode
11
12
  });
12
13
  // if (onSetup?.length) {
package/dist/index.js CHANGED
@@ -32,23 +32,23 @@ const manualChunkNames = [
32
32
  'server'
33
33
  ];
34
34
  const moduleChunks = {
35
- vue: ['vue', 'vue-router'],
35
+ vue: ['vue', '@vue', 'vue-router'],
36
36
  quasar: ['quasar', '@quasar']
37
37
  };
38
38
  const manualChunks = (id) => {
39
39
  const matchedModule = Object.entries(moduleChunks).find(([chunkName, moduleNames]) => moduleNames.some((moduleName) => id.includes(moduleName + '/')));
40
- if (id.includes('vitrify/src/vite/')) {
40
+ if (id.includes('vitrify/src/')) {
41
41
  const name = id.split('/').at(-1)?.split('.').at(0);
42
42
  if (name && manualChunkNames.includes(name))
43
43
  return name;
44
44
  }
45
- else if (matchedModule) {
46
- return matchedModule[0];
47
- }
48
45
  else if (VIRTUAL_MODULES.some((virtualModule) => id.includes(virtualModule))) {
49
46
  return VIRTUAL_MODULES.find((name) => id.includes(name));
50
47
  }
51
48
  else if (id.includes('node_modules')) {
49
+ if (matchedModule) {
50
+ return matchedModule[0];
51
+ }
52
52
  return 'vendor';
53
53
  }
54
54
  };
@@ -378,22 +378,22 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
378
378
  { find: 'cwd', replacement: cwd.pathname },
379
379
  { find: 'boot', replacement: new URL('boot/', srcDir).pathname },
380
380
  { find: 'assets', replacement: new URL('assets/', srcDir).pathname },
381
- ...Object.entries(packageUrls).map(([key, value]) => ({
382
- find: key,
383
- replacement: value.pathname
384
- }))
385
- // {
386
- // find: new RegExp('^vue$'),
387
- // replacement: 'vue/dist/vue.runtime.esm-bundler.js'
388
- // },
381
+ // ...Object.entries(packageUrls).map(([key, value]) => ({
382
+ // find: key,
383
+ // replacement: value.pathname
384
+ // }))
385
+ {
386
+ find: new RegExp('^vue$'),
387
+ replacement: new URL('./dist/vue.runtime.esm-bundler.js', packageUrls['vue']).pathname
388
+ },
389
389
  // {
390
390
  // find: new RegExp('^vue/server-renderer$'),
391
391
  // replacement: 'vue/server-renderer/index.mjs'
392
392
  // },
393
- // {
394
- // find: new RegExp('^vue-router$'),
395
- // replacement: 'vue-router/dist/vue-router.esm-bundler.js'
396
- // }
393
+ {
394
+ find: new RegExp('^vue-router$'),
395
+ replacement: new URL('./dist/vue-router.esm-bundler.js', packageUrls['vue-router']).pathname
396
+ }
397
397
  // { find: 'vue', replacement: packageUrls['vue'].pathname },
398
398
  // { find: 'vue-router', replacement: packageUrls['vue-router'].pathname },
399
399
  // { find: 'vitrify', replacement: cliDir.pathname }
@@ -195,7 +195,7 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
195
195
  // find: new RegExp('^quasar$'),
196
196
  // replacement: new URL('src/index.all.js', urls?.packages?.quasar)
197
197
  // .pathname
198
- // },
198
+ // }
199
199
  // {
200
200
  // find: `@quasar/extras`,
201
201
  // replacement: new URL('.', urls?.packages?.['@quasar/extras'])
@@ -217,10 +217,10 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
217
217
  // __QUASAR_SSR_CLIENT__: `!import.meta.env.SSR`,
218
218
  // // __QUASAR_SSR_PWA__: ssr === 'client' && pwa
219
219
  // __QUASAR_SSR_PWA__: pwa ? `!import.meta.env.SSR` : false
220
+ },
221
+ ssr: {
222
+ noExternal: ['quasar']
220
223
  }
221
- // ssr: {
222
- // noExternal: ['quasar']
223
- // }
224
224
  };
225
225
  }
226
226
  },
@@ -42,7 +42,7 @@ export declare function createServer({ port, logLevel, ssr, framework, host, app
42
42
  server: import("vite").ResolvedServerOptions;
43
43
  build: Required<import("vite").BuildOptions>;
44
44
  preview: import("vite").ResolvedPreviewOptions;
45
- ssr: import("vite").ResolvedSSROptions;
45
+ ssr: import("vite").ResolvedSSROptions | undefined;
46
46
  assetsInclude: (file: string) => boolean;
47
47
  logger: import("vite").Logger;
48
48
  createResolver: (options?: Partial<import("vite").InternalResolveOptions> | undefined) => import("vite").ResolveFn;
@@ -1,10 +1,12 @@
1
1
  import type { FastifyPluginCallback, FastifyRequest, FastifyReply } from 'fastify';
2
2
  import type { ViteDevServer } from 'vite';
3
+ import type { OnRenderedHook } from 'src/node/vitrify-config.js';
3
4
  export interface FastifySsrOptions {
4
5
  baseUrl?: string;
5
6
  provide?: (req: FastifyRequest, res: FastifyReply) => Promise<Record<string, unknown>>;
6
7
  vitrifyDir?: URL;
7
8
  vite?: ViteDevServer;
9
+ onRendered?: OnRenderedHook[];
8
10
  appDir?: URL;
9
11
  publicDir?: URL;
10
12
  productName?: string;
@@ -1,6 +1,8 @@
1
- export declare const prerender: ({ outDir, templatePath, manifestPath, entryServerPath }: {
1
+ import type { OnRenderedHook } from 'src/node/vitrify-config.js';
2
+ export declare const prerender: ({ outDir, templatePath, manifestPath, entryServerPath, onRendered }: {
2
3
  outDir: string;
3
4
  templatePath: string;
4
5
  manifestPath: string;
5
6
  entryServerPath: string;
7
+ onRendered: OnRenderedHook[];
6
8
  }) => Promise<void[]>;
@@ -1,13 +1,14 @@
1
1
  /// <reference types="node" />
2
2
  import type { FastifyInstance } from 'fastify';
3
- import type { OnSetupFile } from '../../vitrify-config.js';
3
+ import type { OnRenderedHook, OnSetupFile } from '../../vitrify-config.js';
4
4
  import type { FastifyCsrPlugin } from './fastify-csr-plugin.js';
5
5
  import type { FastifySsrPlugin } from './fastify-ssr-plugin.js';
6
- export declare const createApp: ({ onSetup, appDir, baseUrl, fastifyPlugin, vitrifyDir, mode }: {
6
+ export declare const createApp: ({ onSetup, appDir, baseUrl, fastifyPlugin, onRendered, vitrifyDir, mode }: {
7
7
  onSetup: OnSetupFile[];
8
8
  appDir: URL;
9
9
  baseUrl?: string | undefined;
10
10
  fastifyPlugin: FastifySsrPlugin | FastifyCsrPlugin;
11
+ onRendered: OnRenderedHook[];
11
12
  vitrifyDir?: URL | undefined;
12
13
  mode: string;
13
14
  }) => FastifyInstance<import("http").Server, import("http").IncomingMessage, import("http").ServerResponse, pino.Logger, import("fastify").FastifyTypeProviderDefault> & PromiseLike<FastifyInstance<import("http").Server, import("http").IncomingMessage, import("http").ServerResponse, pino.Logger, import("fastify").FastifyTypeProviderDefault>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitrify",
3
- "version": "0.6.14",
3
+ "version": "0.6.17",
4
4
  "license": "MIT",
5
5
  "author": "Stefan van Herwijnen",
6
6
  "description": "Pre-configured Vite CLI for your framework",
@@ -76,7 +76,7 @@
76
76
  "sass": "1.53.0",
77
77
  "ts-node": "^10.8.2",
78
78
  "unplugin-vue-components": "^0.21.0",
79
- "vite": "^3.0.0-beta.0",
79
+ "vite": "3.0.0-beta.6",
80
80
  "vitest": "^0.17.0"
81
81
  },
82
82
  "devDependencies": {
@@ -25,6 +25,7 @@ cli
25
25
  const { build } = await import('./build.js')
26
26
  let appDir: URL
27
27
  let prerender
28
+ let onRendered
28
29
  if (options.appDir) {
29
30
  if (options.appDir.slice(-1) !== '/') options.appDir += '/'
30
31
  appDir = new URL(`file://${options.appDir}`)
@@ -84,16 +85,18 @@ cli
84
85
  ...args,
85
86
  outDir: new URL('ssr/server/', baseOutDir).pathname
86
87
  })
87
- ;({ prerender } = await import(
88
+ ;({ prerender, onRendered } = await import(
88
89
  new URL('ssr/server/prerender.mjs', baseOutDir).pathname
89
90
  ))
91
+ console.log(onRendered)
90
92
  prerender({
91
93
  outDir: new URL('static/', baseOutDir).pathname,
92
94
  templatePath: new URL('static/index.html', baseOutDir).pathname,
93
95
  manifestPath: new URL('static/ssr-manifest.json', baseOutDir)
94
96
  .pathname,
95
97
  entryServerPath: new URL('ssr/server/entry-server.mjs', baseOutDir)
96
- .pathname
98
+ .pathname,
99
+ onRendered
97
100
  })
98
101
  break
99
102
  default:
@@ -7,6 +7,7 @@ import type { FastifyInstance } from 'fastify/types/instance'
7
7
  import fastify from 'fastify'
8
8
  import { fastifySsrPlugin } from '../frameworks/vue/fastify-ssr-plugin.js'
9
9
  import type { ServerOptions } from 'https'
10
+ import type { OnRenderedHook } from '../vitrify-config.js'
10
11
 
11
12
  export async function createVitrifyDevServer({
12
13
  port = 3000,
@@ -128,18 +129,18 @@ export async function createServer({
128
129
 
129
130
  let setup
130
131
  let server: Server
132
+ let onRendered: OnRenderedHook[]
131
133
 
132
134
  console.log(`Development mode: ${ssr ? ssr : 'csr'}`)
133
135
  if (ssr) {
134
136
  const entryUrl =
135
137
  ssr === 'fastify'
136
138
  ? new URL('src/vite/fastify/entry.ts', cliDir).pathname
137
- : new URL(`src/vite/${framework}/ssr/entry-server.ts`, cliDir).pathname
138
-
139
- ;({ setup } = await vite.ssrLoadModule(entryUrl))
139
+ : new URL(`src/vite/${framework}/ssr/app.ts`, cliDir).pathname
140
140
 
141
+ ;({ setup, onRendered } = await vite.ssrLoadModule(entryUrl))
141
142
  const app = fastify({
142
- logger: true,
143
+ logger: false,
143
144
  https: vite.config.server.https as ServerOptions
144
145
  })
145
146
  if (process.env) process.env.MODE = 'development'
@@ -151,7 +152,8 @@ export async function createServer({
151
152
  if (ssr === 'ssr') {
152
153
  await app.register(fastifySsrPlugin, {
153
154
  appDir,
154
- mode: 'development'
155
+ mode: 'development',
156
+ onRendered
155
157
  })
156
158
  }
157
159
  await app.listen({
@@ -7,6 +7,7 @@ import fastifyStatic from '@fastify/static'
7
7
  import { readFileSync } from 'fs'
8
8
  import { componentsModules, collectCss } from '../../helpers/collect-css-ssr.js'
9
9
  import type { ViteDevServer } from 'vite'
10
+ import type { OnRenderedHook } from 'src/node/vitrify-config.js'
10
11
 
11
12
  export interface FastifySsrOptions {
12
13
  baseUrl?: string
@@ -17,6 +18,7 @@ export interface FastifySsrOptions {
17
18
  vitrifyDir?: URL
18
19
  vite?: ViteDevServer
19
20
  // frameworkDir?: URL
21
+ onRendered?: OnRenderedHook[]
20
22
  appDir?: URL
21
23
  publicDir?: URL
22
24
  productName?: string
@@ -88,7 +90,6 @@ const fastifySsrPlugin: FastifyPluginCallback<FastifySsrOptions> = async (
88
90
  // ...config
89
91
  // })
90
92
 
91
- console.log('Dev mode')
92
93
  if (!('use' in fastify)) {
93
94
  const middie = (await import('@fastify/middie')).default
94
95
  await fastify.register(middie)
@@ -98,9 +99,12 @@ const fastifySsrPlugin: FastifyPluginCallback<FastifySsrOptions> = async (
98
99
  fastify.get(`${options.baseUrl}*`, async (req, res) => {
99
100
  try {
100
101
  const url = req.raw.url?.replace(options.baseUrl!, '/')
102
+ const provide = options.provide ? await options.provide(req, res) : {}
103
+
101
104
  const ssrContext = {
102
105
  req,
103
- res
106
+ res,
107
+ provide
104
108
  }
105
109
 
106
110
  let template = readFileSync(
@@ -129,12 +133,18 @@ const fastifySsrPlugin: FastifyPluginCallback<FastifySsrOptions> = async (
129
133
  })
130
134
 
131
135
  const [appHtml, preloadLinks] = await render(url, manifest, ssrContext)
132
- const html = template
136
+ let html = template
133
137
  .replace(`<!--preload-links-->`, preloadLinks)
134
138
  .replace(`<!--app-html-->`, appHtml)
135
139
  .replace('<!--product-name-->', options.productName || 'Product name')
136
140
  .replace('<!--dev-ssr-css-->', css)
137
141
 
142
+ if (options.onRendered?.length) {
143
+ for (const ssrFunction of options.onRendered) {
144
+ html = ssrFunction(html, ssrContext)
145
+ }
146
+ }
147
+
138
148
  res.code(200)
139
149
  res.type('text/html')
140
150
  res.send(html)
@@ -183,10 +193,16 @@ const fastifySsrPlugin: FastifyPluginCallback<FastifySsrOptions> = async (
183
193
  if (!ssrContext.initialState) ssrContext.initialState = {}
184
194
  ssrContext.initialState.provide = provide
185
195
 
186
- const html = template
196
+ let html = template
187
197
  .replace(`<!--preload-links-->`, preloadLinks)
188
198
  .replace(`<!--app-html-->`, appHtml)
189
199
 
200
+ if (options.onRendered?.length) {
201
+ for (const ssrFunction of options.onRendered) {
202
+ html = ssrFunction(html, ssrContext)
203
+ }
204
+ }
205
+
190
206
  res.code(200)
191
207
  res.type('text/html')
192
208
  res.send(html)
@@ -1,16 +1,19 @@
1
1
  import { promises as fs } from 'fs'
2
+ import type { OnRenderedHook } from 'src/node/vitrify-config.js'
2
3
  import { routesToPaths } from '../../helpers/routes.js'
3
4
 
4
5
  export const prerender = async ({
5
6
  outDir,
6
7
  templatePath,
7
8
  manifestPath,
8
- entryServerPath
9
+ entryServerPath,
10
+ onRendered
9
11
  }: {
10
12
  outDir: string
11
13
  templatePath: string
12
14
  manifestPath: string
13
15
  entryServerPath: string
16
+ onRendered: OnRenderedHook[]
14
17
  }) => {
15
18
  const promises = []
16
19
  const template = (await fs.readFile(templatePath)).toString()
@@ -41,6 +44,12 @@ export const prerender = async ({
41
44
  .replace(`<!--preload-links-->`, preloadLinks)
42
45
  .replace(`<!--app-html-->`, appHtml)
43
46
 
47
+ if (onRendered?.length) {
48
+ for (const ssrFunction of onRendered) {
49
+ html = ssrFunction(html, ssrContext)
50
+ }
51
+ }
52
+
44
53
  html = await critters.process(html)
45
54
 
46
55
  promises.push(fs.writeFile(outDir + filename, html, 'utf-8'))
@@ -2,7 +2,7 @@ import type { FastifyInstance } from 'fastify'
2
2
  import fastify from 'fastify'
3
3
  import type { ViteDevServer } from 'vite'
4
4
  import { getCliDir, getCliViteDir } from '../../app-urls.js'
5
- import type { OnSetupFile } from '../../vitrify-config.js'
5
+ import type { OnRenderedHook, OnSetupFile } from '../../vitrify-config.js'
6
6
  import type { FastifyCsrPlugin } from './fastify-csr-plugin.js'
7
7
  import type { FastifySsrPlugin } from './fastify-ssr-plugin.js'
8
8
 
@@ -11,6 +11,7 @@ export const createApp = ({
11
11
  appDir,
12
12
  baseUrl,
13
13
  fastifyPlugin,
14
+ onRendered,
14
15
  vitrifyDir,
15
16
  mode
16
17
  }: {
@@ -18,6 +19,7 @@ export const createApp = ({
18
19
  appDir: URL
19
20
  baseUrl?: string
20
21
  fastifyPlugin: FastifySsrPlugin | FastifyCsrPlugin
22
+ onRendered: OnRenderedHook[]
21
23
  vitrifyDir?: URL
22
24
  mode: string
23
25
  }) => {
@@ -29,6 +31,7 @@ export const createApp = ({
29
31
  baseUrl,
30
32
  appDir,
31
33
  vitrifyDir,
34
+ onRendered,
32
35
  mode
33
36
  })
34
37
 
package/src/node/index.ts CHANGED
@@ -50,7 +50,7 @@ const manualChunkNames = [
50
50
  ]
51
51
 
52
52
  const moduleChunks = {
53
- vue: ['vue', 'vue-router'],
53
+ vue: ['vue', '@vue', 'vue-router'],
54
54
  quasar: ['quasar', '@quasar']
55
55
  }
56
56
  const manualChunks: ManualChunksOption = (id: string) => {
@@ -58,16 +58,17 @@ const manualChunks: ManualChunksOption = (id: string) => {
58
58
  ([chunkName, moduleNames]) =>
59
59
  moduleNames.some((moduleName) => id.includes(moduleName + '/'))
60
60
  )
61
- if (id.includes('vitrify/src/vite/')) {
61
+ if (id.includes('vitrify/src/')) {
62
62
  const name = id.split('/').at(-1)?.split('.').at(0)
63
63
  if (name && manualChunkNames.includes(name)) return name
64
- } else if (matchedModule) {
65
- return matchedModule[0]
66
64
  } else if (
67
65
  VIRTUAL_MODULES.some((virtualModule) => id.includes(virtualModule))
68
66
  ) {
69
67
  return VIRTUAL_MODULES.find((name) => id.includes(name))
70
68
  } else if (id.includes('node_modules')) {
69
+ if (matchedModule) {
70
+ return matchedModule[0]
71
+ }
71
72
  return 'vendor'
72
73
  }
73
74
  }
@@ -459,22 +460,28 @@ export const baseConfig = async ({
459
460
  { find: 'cwd', replacement: cwd.pathname },
460
461
  { find: 'boot', replacement: new URL('boot/', srcDir).pathname },
461
462
  { find: 'assets', replacement: new URL('assets/', srcDir).pathname },
462
- ...Object.entries(packageUrls).map(([key, value]) => ({
463
- find: key,
464
- replacement: value.pathname
465
- }))
466
- // {
467
- // find: new RegExp('^vue$'),
468
- // replacement: 'vue/dist/vue.runtime.esm-bundler.js'
469
- // },
463
+ // ...Object.entries(packageUrls).map(([key, value]) => ({
464
+ // find: key,
465
+ // replacement: value.pathname
466
+ // }))
467
+ {
468
+ find: new RegExp('^vue$'),
469
+ replacement: new URL(
470
+ './dist/vue.runtime.esm-bundler.js',
471
+ packageUrls['vue']
472
+ ).pathname
473
+ },
470
474
  // {
471
475
  // find: new RegExp('^vue/server-renderer$'),
472
476
  // replacement: 'vue/server-renderer/index.mjs'
473
477
  // },
474
- // {
475
- // find: new RegExp('^vue-router$'),
476
- // replacement: 'vue-router/dist/vue-router.esm-bundler.js'
477
- // }
478
+ {
479
+ find: new RegExp('^vue-router$'),
480
+ replacement: new URL(
481
+ './dist/vue-router.esm-bundler.js',
482
+ packageUrls['vue-router']
483
+ ).pathname
484
+ }
478
485
  // { find: 'vue', replacement: packageUrls['vue'].pathname },
479
486
  // { find: 'vue-router', replacement: packageUrls['vue-router'].pathname },
480
487
  // { find: 'vitrify', replacement: cliDir.pathname }
@@ -278,7 +278,7 @@ export const QuasarPlugin: VitrifyPlugin = async ({
278
278
  // find: new RegExp('^quasar$'),
279
279
  // replacement: new URL('src/index.all.js', urls?.packages?.quasar)
280
280
  // .pathname
281
- // },
281
+ // }
282
282
  // {
283
283
  // find: `@quasar/extras`,
284
284
  // replacement: new URL('.', urls?.packages?.['@quasar/extras'])
@@ -300,10 +300,10 @@ export const QuasarPlugin: VitrifyPlugin = async ({
300
300
  // __QUASAR_SSR_CLIENT__: `!import.meta.env.SSR`,
301
301
  // // __QUASAR_SSR_PWA__: ssr === 'client' && pwa
302
302
  // __QUASAR_SSR_PWA__: pwa ? `!import.meta.env.SSR` : false
303
+ },
304
+ ssr: {
305
+ noExternal: ['quasar']
303
306
  }
304
- // ssr: {
305
- // noExternal: ['quasar']
306
- // }
307
307
  }
308
308
  }
309
309
  },
@@ -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 { onSetup } from 'virtual:vitrify-hooks'
4
+ import { onSetup, onRendered } from 'virtual:vitrify-hooks'
5
5
  import { fastifySsrPlugin } from './fastify-ssr-plugin.js'
6
6
  import type { ViteDevServer } from 'vite'
7
7
 
@@ -17,7 +17,10 @@ export const setupApp = async () => {
17
17
  appDir,
18
18
  baseUrl,
19
19
  fastifyPlugin: fastifySsrPlugin,
20
+ onRendered,
20
21
  // vitrifyDir,
21
22
  mode: import.meta.env.MODE
22
23
  })
23
24
  }
25
+
26
+ export { onRendered }
@@ -1,7 +1,7 @@
1
1
  import { createApp } from '../main.js'
2
2
  // import { renderToString } from 'vue/server-renderer'
3
3
 
4
- import { onRendered } from 'virtual:vitrify-hooks'
4
+ // import { onRendered } from 'virtual:vitrify-hooks'
5
5
 
6
6
  const initializeApp = async (url, ssrContext) => {
7
7
  const onRenderedList = []
@@ -49,12 +49,6 @@ export async function render(url, manifest, ssrContext, renderToString) {
49
49
 
50
50
  const preloadLinks = renderPreloadLinks(ctx.modules, manifest)
51
51
 
52
- if (onRendered?.length) {
53
- for (const ssrFunction of onRendered) {
54
- html = ssrFunction(html, ssrContext)
55
- }
56
- }
57
-
58
52
  return [html, preloadLinks]
59
53
  }
60
54
 
@@ -1,3 +1,4 @@
1
1
  import { prerender } from '../../../node/frameworks/vue/prerender.js'
2
+ import { onRendered } from 'virtual:vitrify-hooks'
2
3
 
3
- export { prerender }
4
+ export { prerender, onRendered }