vitrify 0.6.12 → 0.6.13
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/frameworks/vue/fastify-ssr-plugin.js +1 -1
- package/dist/index.js +32 -22
- package/dist/plugins/quasar.js +67 -67
- package/dist/types/bin/dev.d.ts +1 -1
- package/package.json +1 -1
- package/src/node/frameworks/vue/fastify-ssr-plugin.ts +1 -1
- package/src/node/index.ts +31 -23
- package/src/node/plugins/quasar.ts +16 -12
|
@@ -131,7 +131,7 @@ const fastifySsrPlugin = async (fastify, options, done) => {
|
|
|
131
131
|
if (!ssrContext.initialState)
|
|
132
132
|
ssrContext.initialState = {};
|
|
133
133
|
ssrContext.initialState.provide = provide;
|
|
134
|
-
|
|
134
|
+
const html = template
|
|
135
135
|
.replace(`<!--preload-links-->`, preloadLinks)
|
|
136
136
|
.replace(`<!--app-html-->`, appHtml);
|
|
137
137
|
res.code(200);
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import vuePlugin from '@vitejs/plugin-vue';
|
|
2
|
+
import { resolvePackageData } from 'vite';
|
|
2
3
|
import { mergeConfig } from 'vite';
|
|
3
4
|
import { build } from 'esbuild';
|
|
4
5
|
import fs from 'fs';
|
|
@@ -8,7 +9,7 @@ import { readFileSync } from 'fs';
|
|
|
8
9
|
import builtinModules from 'builtin-modules';
|
|
9
10
|
// import { resolve } from 'import-meta-resolve'
|
|
10
11
|
import { visualizer } from 'rollup-plugin-visualizer';
|
|
11
|
-
import {
|
|
12
|
+
import { resolve } from './app-urls.js';
|
|
12
13
|
const internalServerModules = [
|
|
13
14
|
'util',
|
|
14
15
|
'vitrify',
|
|
@@ -31,21 +32,23 @@ const manualChunkNames = [
|
|
|
31
32
|
'server'
|
|
32
33
|
];
|
|
33
34
|
const moduleChunks = {
|
|
34
|
-
vue: ['vue', '
|
|
35
|
-
quasar: ['quasar']
|
|
35
|
+
vue: ['vue', 'vue-router'],
|
|
36
|
+
quasar: ['quasar', '@quasar']
|
|
36
37
|
};
|
|
37
|
-
const manualChunks = (id
|
|
38
|
-
|
|
38
|
+
const manualChunks = (id) => {
|
|
39
|
+
const matchedModule = Object.entries(moduleChunks).find(([chunkName, moduleNames]) => moduleNames.some((moduleName) => id.includes(moduleName + '/')));
|
|
40
|
+
if (id.includes('vitrify/src/vite/')) {
|
|
39
41
|
const name = id.split('/').at(-1)?.split('.').at(0);
|
|
40
|
-
|
|
42
|
+
if (name && manualChunkNames.includes(name))
|
|
43
|
+
return name;
|
|
44
|
+
}
|
|
45
|
+
else if (matchedModule) {
|
|
46
|
+
return matchedModule[0];
|
|
41
47
|
}
|
|
42
48
|
else if (VIRTUAL_MODULES.some((virtualModule) => id.includes(virtualModule))) {
|
|
43
49
|
return VIRTUAL_MODULES.find((name) => id.includes(name));
|
|
44
50
|
}
|
|
45
51
|
else if (id.includes('node_modules')) {
|
|
46
|
-
const name = Object.entries(moduleChunks).find(([chunkName, moduleNames]) => moduleNames.some((name) => id.includes(`${name}/`)));
|
|
47
|
-
if (name)
|
|
48
|
-
return name[0];
|
|
49
52
|
return 'vendor';
|
|
50
53
|
}
|
|
51
54
|
};
|
|
@@ -139,13 +142,16 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
139
142
|
console.log('No vitrify.config.(ts|js) file found, using defaults');
|
|
140
143
|
vitrifyConfig = {};
|
|
141
144
|
}
|
|
142
|
-
|
|
143
|
-
const localPackages = []
|
|
145
|
+
const localPackages = ['vue', 'vue-router', '@vue/server-renderer'];
|
|
146
|
+
// const localPackages: string[] = []
|
|
144
147
|
const cliPackages = [];
|
|
145
148
|
const packageUrls = vitrifyConfig.vitrify?.urls?.packages || {};
|
|
146
149
|
await (async () => {
|
|
147
|
-
for (const val of localPackages)
|
|
148
|
-
|
|
150
|
+
for (const val of localPackages) {
|
|
151
|
+
const pkg = resolvePackageData(val, appDir.pathname);
|
|
152
|
+
if (pkg)
|
|
153
|
+
packageUrls[val] = new URL(`file://${pkg.dir}/`);
|
|
154
|
+
}
|
|
149
155
|
})();
|
|
150
156
|
// await (async () => {
|
|
151
157
|
// for (const val of cliPackages)
|
|
@@ -375,15 +381,19 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
375
381
|
...Object.entries(packageUrls).map(([key, value]) => ({
|
|
376
382
|
find: key,
|
|
377
383
|
replacement: value.pathname
|
|
378
|
-
}))
|
|
379
|
-
{
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
},
|
|
383
|
-
{
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
}
|
|
384
|
+
}))
|
|
385
|
+
// {
|
|
386
|
+
// find: new RegExp('^vue$'),
|
|
387
|
+
// replacement: 'vue/dist/vue.runtime.esm-bundler.js'
|
|
388
|
+
// },
|
|
389
|
+
// {
|
|
390
|
+
// find: new RegExp('^vue/server-renderer$'),
|
|
391
|
+
// replacement: 'vue/server-renderer/index.mjs'
|
|
392
|
+
// },
|
|
393
|
+
// {
|
|
394
|
+
// find: new RegExp('^vue-router$'),
|
|
395
|
+
// replacement: 'vue-router/dist/vue-router.esm-bundler.js'
|
|
396
|
+
// }
|
|
387
397
|
// { find: 'vue', replacement: packageUrls['vue'].pathname },
|
|
388
398
|
// { find: 'vue-router', replacement: packageUrls['vue-router'].pathname },
|
|
389
399
|
// { find: 'vitrify', replacement: cliDir.pathname }
|
package/dist/plugins/quasar.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { resolvePackageData } from 'vite';
|
|
1
2
|
import Components from 'unplugin-vue-components/vite';
|
|
2
3
|
// import { quasarDir as defaultQuasarDir } from '../app-urls.js'
|
|
3
4
|
// import { QuasarResolver } from '../resolver.js';
|
|
4
5
|
import { QuasarResolver } from 'unplugin-vue-components/resolvers';
|
|
5
|
-
import { getPkgJsonDir, resolve } from '../app-urls.js';
|
|
6
6
|
export const injectSsrContext = (html, ssrContext) => html
|
|
7
7
|
.replace(/(<html[^>]*)(>)/i, (found, start, end) => {
|
|
8
8
|
let matches;
|
|
@@ -54,11 +54,14 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
|
|
|
54
54
|
config: async (config, env) => {
|
|
55
55
|
const { vitrify: { urls } = {}, quasar } = config;
|
|
56
56
|
const globalCss = quasar?.extras.map((extra) => `@quasar/extras/${extra}/${extra}.css`);
|
|
57
|
-
|
|
58
|
-
const localPackages = []
|
|
57
|
+
const localPackages = ['@quasar/extras', 'quasar'];
|
|
58
|
+
// const localPackages: string[] = []
|
|
59
59
|
await (async () => {
|
|
60
|
-
for (const val of localPackages)
|
|
61
|
-
|
|
60
|
+
for (const val of localPackages) {
|
|
61
|
+
const pkg = resolvePackageData(val, config.vitrify.urls.app.pathname);
|
|
62
|
+
if (pkg)
|
|
63
|
+
urls.packages[val] = new URL(`file://${pkg.dir}/`);
|
|
64
|
+
}
|
|
62
65
|
})();
|
|
63
66
|
const onMountedHooks = [
|
|
64
67
|
async (instance) => {
|
|
@@ -140,68 +143,65 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
|
|
|
140
143
|
resolve: {
|
|
141
144
|
// dedupe: ['quasar', '@quasar/extras'],
|
|
142
145
|
alias: [
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
// .pathname
|
|
203
|
-
// }
|
|
204
|
-
// { find: new RegExp('^quasar$'), replacement: 'virtual:quasar' }
|
|
146
|
+
// {
|
|
147
|
+
// find: 'quasar/wrappers',
|
|
148
|
+
// replacement: new URL('quasar-wrappers.ts', urls?.cli).pathname
|
|
149
|
+
// },
|
|
150
|
+
// {
|
|
151
|
+
// find: 'quasar/vue-plugin',
|
|
152
|
+
// replacement: new URL(
|
|
153
|
+
// 'src/vue-plugin.js',
|
|
154
|
+
// urls?.packages?.quasar
|
|
155
|
+
// ).pathname
|
|
156
|
+
// },
|
|
157
|
+
// {
|
|
158
|
+
// find: 'quasar/plugins',
|
|
159
|
+
// replacement: new URL('src/plugins.js', urls?.packages?.quasar)
|
|
160
|
+
// .pathname
|
|
161
|
+
// },
|
|
162
|
+
// {
|
|
163
|
+
// find: 'quasar/components',
|
|
164
|
+
// replacement: new URL(
|
|
165
|
+
// 'src/components.js',
|
|
166
|
+
// urls?.packages?.quasar
|
|
167
|
+
// ).pathname
|
|
168
|
+
// },
|
|
169
|
+
// {
|
|
170
|
+
// find: 'quasar/composables',
|
|
171
|
+
// replacement: new URL(
|
|
172
|
+
// 'src/composables.js',
|
|
173
|
+
// urls?.packages?.quasar
|
|
174
|
+
// ).pathname
|
|
175
|
+
// },
|
|
176
|
+
// {
|
|
177
|
+
// find: 'quasar/directives',
|
|
178
|
+
// replacement: new URL(
|
|
179
|
+
// 'src/directives.js',
|
|
180
|
+
// urls?.packages?.quasar
|
|
181
|
+
// ).pathname
|
|
182
|
+
// },
|
|
183
|
+
{
|
|
184
|
+
find: 'quasar/src',
|
|
185
|
+
replacement: new URL('./src', config.vitrify.urls.packages.quasar).pathname
|
|
186
|
+
}
|
|
187
|
+
// {
|
|
188
|
+
// find: 'quasar',
|
|
189
|
+
// replacement: new URL(
|
|
190
|
+
// 'node_modules/quasar',
|
|
191
|
+
// config.vitrify?.urls?.app
|
|
192
|
+
// )
|
|
193
|
+
// }
|
|
194
|
+
// {
|
|
195
|
+
// find: new RegExp('^quasar$'),
|
|
196
|
+
// replacement: new URL('src/index.all.js', urls?.packages?.quasar)
|
|
197
|
+
// .pathname
|
|
198
|
+
// },
|
|
199
|
+
// {
|
|
200
|
+
// find: `@quasar/extras`,
|
|
201
|
+
// replacement: new URL('.', urls?.packages?.['@quasar/extras'])
|
|
202
|
+
// .pathname
|
|
203
|
+
// }
|
|
204
|
+
// { find: new RegExp('^quasar$'), replacement: 'virtual:quasar' }
|
|
205
205
|
]
|
|
206
206
|
},
|
|
207
207
|
optimizeDeps: {
|
package/dist/types/bin/dev.d.ts
CHANGED
|
@@ -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;
|
|
46
46
|
assetsInclude: (file: string) => boolean;
|
|
47
47
|
logger: import("vite").Logger;
|
|
48
48
|
createResolver: (options?: Partial<import("vite").InternalResolveOptions> | undefined) => import("vite").ResolveFn;
|
package/package.json
CHANGED
|
@@ -183,7 +183,7 @@ const fastifySsrPlugin: FastifyPluginCallback<FastifySsrOptions> = async (
|
|
|
183
183
|
if (!ssrContext.initialState) ssrContext.initialState = {}
|
|
184
184
|
ssrContext.initialState.provide = provide
|
|
185
185
|
|
|
186
|
-
|
|
186
|
+
const html = template
|
|
187
187
|
.replace(`<!--preload-links-->`, preloadLinks)
|
|
188
188
|
.replace(`<!--app-html-->`, appHtml)
|
|
189
189
|
|
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 { resolvePackageData } from 'vite'
|
|
4
4
|
import { mergeConfig } from 'vite'
|
|
5
5
|
import { build } from 'esbuild'
|
|
6
6
|
import fs from 'fs'
|
|
@@ -50,22 +50,24 @@ const manualChunkNames = [
|
|
|
50
50
|
]
|
|
51
51
|
|
|
52
52
|
const moduleChunks = {
|
|
53
|
-
vue: ['vue', '
|
|
54
|
-
quasar: ['quasar']
|
|
53
|
+
vue: ['vue', 'vue-router'],
|
|
54
|
+
quasar: ['quasar', '@quasar']
|
|
55
55
|
}
|
|
56
|
-
const manualChunks: ManualChunksOption = (id
|
|
57
|
-
|
|
56
|
+
const manualChunks: ManualChunksOption = (id: string) => {
|
|
57
|
+
const matchedModule = Object.entries(moduleChunks).find(
|
|
58
|
+
([chunkName, moduleNames]) =>
|
|
59
|
+
moduleNames.some((moduleName) => id.includes(moduleName + '/'))
|
|
60
|
+
)
|
|
61
|
+
if (id.includes('vitrify/src/vite/')) {
|
|
58
62
|
const name = id.split('/').at(-1)?.split('.').at(0)
|
|
59
|
-
return name
|
|
63
|
+
if (name && manualChunkNames.includes(name)) return name
|
|
64
|
+
} else if (matchedModule) {
|
|
65
|
+
return matchedModule[0]
|
|
60
66
|
} else if (
|
|
61
67
|
VIRTUAL_MODULES.some((virtualModule) => id.includes(virtualModule))
|
|
62
68
|
) {
|
|
63
69
|
return VIRTUAL_MODULES.find((name) => id.includes(name))
|
|
64
70
|
} else if (id.includes('node_modules')) {
|
|
65
|
-
const name = Object.entries(moduleChunks).find(([chunkName, moduleNames]) =>
|
|
66
|
-
moduleNames.some((name) => id.includes(`${name}/`))
|
|
67
|
-
)
|
|
68
|
-
if (name) return name[0]
|
|
69
71
|
return 'vendor'
|
|
70
72
|
}
|
|
71
73
|
}
|
|
@@ -204,14 +206,16 @@ export const baseConfig = async ({
|
|
|
204
206
|
vitrifyConfig = {}
|
|
205
207
|
}
|
|
206
208
|
|
|
207
|
-
|
|
208
|
-
const localPackages: string[] = []
|
|
209
|
+
const localPackages = ['vue', 'vue-router', '@vue/server-renderer']
|
|
210
|
+
// const localPackages: string[] = []
|
|
209
211
|
const cliPackages = []
|
|
210
212
|
const packageUrls: Record<string, URL> =
|
|
211
213
|
vitrifyConfig.vitrify?.urls?.packages || {}
|
|
212
214
|
await (async () => {
|
|
213
|
-
for (const val of localPackages)
|
|
214
|
-
|
|
215
|
+
for (const val of localPackages) {
|
|
216
|
+
const pkg = resolvePackageData(val, appDir.pathname)
|
|
217
|
+
if (pkg) packageUrls![val] = new URL(`file://${pkg.dir}/`)
|
|
218
|
+
}
|
|
215
219
|
})()
|
|
216
220
|
|
|
217
221
|
// await (async () => {
|
|
@@ -458,15 +462,19 @@ export const baseConfig = async ({
|
|
|
458
462
|
...Object.entries(packageUrls).map(([key, value]) => ({
|
|
459
463
|
find: key,
|
|
460
464
|
replacement: value.pathname
|
|
461
|
-
}))
|
|
462
|
-
{
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
},
|
|
466
|
-
{
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
}
|
|
465
|
+
}))
|
|
466
|
+
// {
|
|
467
|
+
// find: new RegExp('^vue$'),
|
|
468
|
+
// replacement: 'vue/dist/vue.runtime.esm-bundler.js'
|
|
469
|
+
// },
|
|
470
|
+
// {
|
|
471
|
+
// find: new RegExp('^vue/server-renderer$'),
|
|
472
|
+
// replacement: 'vue/server-renderer/index.mjs'
|
|
473
|
+
// },
|
|
474
|
+
// {
|
|
475
|
+
// find: new RegExp('^vue-router$'),
|
|
476
|
+
// replacement: 'vue-router/dist/vue-router.esm-bundler.js'
|
|
477
|
+
// }
|
|
470
478
|
// { find: 'vue', replacement: packageUrls['vue'].pathname },
|
|
471
479
|
// { find: 'vue-router', replacement: packageUrls['vue-router'].pathname },
|
|
472
480
|
// { find: 'vitrify', replacement: cliDir.pathname }
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { readFileSync } from 'fs'
|
|
2
2
|
import type { Plugin } from 'vite'
|
|
3
|
+
import { resolvePackageData } from 'vite'
|
|
3
4
|
import Components from 'unplugin-vue-components/vite'
|
|
4
5
|
// import { prepareQuasarConf } from './quasar-conf-file.js'
|
|
5
6
|
import type {
|
|
@@ -119,13 +120,16 @@ export const QuasarPlugin: VitrifyPlugin = async ({
|
|
|
119
120
|
(extra) => `@quasar/extras/${extra}/${extra}.css`
|
|
120
121
|
)
|
|
121
122
|
|
|
122
|
-
|
|
123
|
-
const localPackages: string[] = []
|
|
123
|
+
const localPackages = ['@quasar/extras', 'quasar']
|
|
124
|
+
// const localPackages: string[] = []
|
|
124
125
|
await (async () => {
|
|
125
|
-
for (const val of localPackages)
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
for (const val of localPackages) {
|
|
127
|
+
const pkg = resolvePackageData(
|
|
128
|
+
val,
|
|
129
|
+
config.vitrify!.urls!.app!.pathname
|
|
128
130
|
)
|
|
131
|
+
if (pkg) urls!.packages![val] = new URL(`file://${pkg.dir}/`)
|
|
132
|
+
}
|
|
129
133
|
})()
|
|
130
134
|
|
|
131
135
|
const onMountedHooks: OnMountedHook[] = [
|
|
@@ -256,13 +260,13 @@ export const QuasarPlugin: VitrifyPlugin = async ({
|
|
|
256
260
|
// urls?.packages?.quasar
|
|
257
261
|
// ).pathname
|
|
258
262
|
// },
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
263
|
+
{
|
|
264
|
+
find: 'quasar/src',
|
|
265
|
+
replacement: new URL(
|
|
266
|
+
'./src',
|
|
267
|
+
config.vitrify!.urls!.packages!.quasar
|
|
268
|
+
).pathname
|
|
269
|
+
}
|
|
266
270
|
// {
|
|
267
271
|
// find: 'quasar',
|
|
268
272
|
// replacement: new URL(
|