vitrify 0.5.3 → 0.5.6
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/app-urls.js +7 -0
- package/dist/index.js +7 -5
- package/dist/plugins/quasar.js +2 -3
- package/dist/types/app-urls.d.ts +1 -0
- package/package.json +1 -4
- package/src/node/app-urls.ts +8 -0
- package/src/node/index.ts +7 -7
- package/src/node/plugins/quasar.ts +3 -3
- package/src/vite/vue/csr/app.ts +3 -4
- package/src/vite/vue/ssr/app.ts +3 -4
- package/src/vite/vue/ssr/entry-server.ts +1 -1
package/dist/app-urls.js
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
// import { resolve } from 'import-meta-resolve'
|
|
2
2
|
import { existsSync } from 'fs';
|
|
3
|
+
export const resolve = (packageName, base) => {
|
|
4
|
+
const packageUrl = new URL(`./node_modules/${packageName}/`, base);
|
|
5
|
+
if (existsSync(packageUrl.pathname)) {
|
|
6
|
+
return new URL('./', packageUrl);
|
|
7
|
+
}
|
|
8
|
+
throw new Error(`Package ${packageName} not found in ${base.pathname}.`);
|
|
9
|
+
};
|
|
3
10
|
export const getPkgJsonDir = (dir) => {
|
|
4
11
|
const pkgJsonPath = new URL('package.json', dir);
|
|
5
12
|
if (existsSync(pkgJsonPath.pathname)) {
|
package/dist/index.js
CHANGED
|
@@ -6,9 +6,9 @@ import path from 'path';
|
|
|
6
6
|
import { pathToFileURL } from 'url';
|
|
7
7
|
import { readFileSync } from 'fs';
|
|
8
8
|
import builtinModules from 'builtin-modules';
|
|
9
|
-
import { resolve } from 'import-meta-resolve'
|
|
9
|
+
// import { resolve } from 'import-meta-resolve'
|
|
10
10
|
import { visualizer } from 'rollup-plugin-visualizer';
|
|
11
|
-
import { getPkgJsonDir } from './app-urls.js';
|
|
11
|
+
import { getPkgJsonDir, resolve } from './app-urls.js';
|
|
12
12
|
const internalServerModules = [
|
|
13
13
|
'util',
|
|
14
14
|
'vitrify',
|
|
@@ -16,6 +16,8 @@ const internalServerModules = [
|
|
|
16
16
|
'vite',
|
|
17
17
|
'fastify',
|
|
18
18
|
'@fastify/static',
|
|
19
|
+
'@fastify/middie',
|
|
20
|
+
'@fastify',
|
|
19
21
|
'node'
|
|
20
22
|
];
|
|
21
23
|
const configPluginMap = {
|
|
@@ -130,12 +132,12 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
130
132
|
console.log('No vitrify.config.(ts|js) file found, using defaults');
|
|
131
133
|
vitrifyConfig = {};
|
|
132
134
|
}
|
|
133
|
-
const localPackages = ['vue', 'vue-router'];
|
|
135
|
+
const localPackages = ['vue', 'vue-router', '@vue/server-renderer'];
|
|
134
136
|
const cliPackages = [];
|
|
135
137
|
const packageUrls = vitrifyConfig.vitrify?.urls?.packages || {};
|
|
136
138
|
await (async () => {
|
|
137
139
|
for (const val of localPackages)
|
|
138
|
-
packageUrls[val] = getPkgJsonDir(new URL(await resolve(val, appDir
|
|
140
|
+
packageUrls[val] = getPkgJsonDir(new URL(await resolve(val, appDir)));
|
|
139
141
|
})();
|
|
140
142
|
// await (async () => {
|
|
141
143
|
// for (const val of cliPackages)
|
|
@@ -375,7 +377,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
|
|
|
375
377
|
if (command === 'test')
|
|
376
378
|
alias.push({
|
|
377
379
|
find: 'vitest',
|
|
378
|
-
replacement: new URL(await resolve('vitest', cliDir
|
|
380
|
+
replacement: new URL(await resolve('vitest', cliDir)).pathname
|
|
379
381
|
});
|
|
380
382
|
let rollupOptions = {};
|
|
381
383
|
let noExternal = [
|
package/dist/plugins/quasar.js
CHANGED
|
@@ -3,8 +3,7 @@ import Components from 'unplugin-vue-components/vite';
|
|
|
3
3
|
// import { quasarDir as defaultQuasarDir } from '../app-urls.js'
|
|
4
4
|
// import { QuasarResolver } from '../resolver.js';
|
|
5
5
|
import { QuasarResolver } from 'unplugin-vue-components/resolvers';
|
|
6
|
-
import { getPkgJsonDir } from '../app-urls.js';
|
|
7
|
-
import { resolve } from 'import-meta-resolve';
|
|
6
|
+
import { getPkgJsonDir, resolve } from '../app-urls.js';
|
|
8
7
|
export const injectSsrContext = (html, ssrContext) => html
|
|
9
8
|
.replace(/(<html[^>]*)(>)/i, (found, start, end) => {
|
|
10
9
|
let matches;
|
|
@@ -59,7 +58,7 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
|
|
|
59
58
|
const localPackages = ['@quasar/extras', 'quasar'];
|
|
60
59
|
await (async () => {
|
|
61
60
|
for (const val of localPackages)
|
|
62
|
-
urls.packages[val] = getPkgJsonDir(new URL(await resolve(val, urls.app
|
|
61
|
+
urls.packages[val] = getPkgJsonDir(new URL(await resolve(val, urls.app)));
|
|
63
62
|
})();
|
|
64
63
|
const onMountedHooks = [
|
|
65
64
|
async (instance) => {
|
package/dist/types/app-urls.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitrify",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Stefan van Herwijnen",
|
|
6
6
|
"description": "Pre-configured Vite CLI for your framework",
|
|
@@ -64,7 +64,6 @@
|
|
|
64
64
|
"fastify": "^4.0.0",
|
|
65
65
|
"glob": "^8.0.3",
|
|
66
66
|
"happy-dom": "^5.2.0",
|
|
67
|
-
"local-pkg": "^0.4.1",
|
|
68
67
|
"magic-string": "^0.26.2",
|
|
69
68
|
"merge-deep": "^3.0.3",
|
|
70
69
|
"readline": "^1.3.0",
|
|
@@ -82,7 +81,6 @@
|
|
|
82
81
|
"@types/node": "^17.0.41",
|
|
83
82
|
"@types/ws": "^8.5.3",
|
|
84
83
|
"@vue/runtime-core": "^3.2.37",
|
|
85
|
-
"import-meta-resolve": "^2.0.3",
|
|
86
84
|
"quasar": "^2.7.1",
|
|
87
85
|
"rollup": "^2.75.6",
|
|
88
86
|
"typescript": "^4.7.3",
|
|
@@ -93,7 +91,6 @@
|
|
|
93
91
|
"peerDependencies": {
|
|
94
92
|
"@fastify/static": "^6.4.0",
|
|
95
93
|
"fastify": "^4.0.0",
|
|
96
|
-
"import-meta-resolve": "^2.0.3",
|
|
97
94
|
"quasar": "^2.7.1",
|
|
98
95
|
"vue": "^3.2.37",
|
|
99
96
|
"vue-router": "^4.0.15"
|
package/src/node/app-urls.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
// import { resolve } from 'import-meta-resolve'
|
|
2
2
|
import { existsSync } from 'fs'
|
|
3
3
|
|
|
4
|
+
export const resolve = (packageName: string, base: URL) => {
|
|
5
|
+
const packageUrl = new URL(`./node_modules/${packageName}/`, base)
|
|
6
|
+
if (existsSync(packageUrl.pathname)) {
|
|
7
|
+
return new URL('./', packageUrl)
|
|
8
|
+
}
|
|
9
|
+
throw new Error(`Package ${packageName} not found in ${base.pathname}.`)
|
|
10
|
+
}
|
|
11
|
+
|
|
4
12
|
export const getPkgJsonDir = (dir: URL): URL => {
|
|
5
13
|
const pkgJsonPath = new URL('package.json', dir)
|
|
6
14
|
if (existsSync(pkgJsonPath.pathname)) {
|
package/src/node/index.ts
CHANGED
|
@@ -8,7 +8,7 @@ import path from 'path'
|
|
|
8
8
|
import { pathToFileURL } from 'url'
|
|
9
9
|
import { readFileSync } from 'fs'
|
|
10
10
|
import builtinModules from 'builtin-modules'
|
|
11
|
-
import { resolve } from 'import-meta-resolve'
|
|
11
|
+
// import { resolve } from 'import-meta-resolve'
|
|
12
12
|
import { visualizer } from 'rollup-plugin-visualizer'
|
|
13
13
|
import type {
|
|
14
14
|
StaticImports,
|
|
@@ -21,7 +21,7 @@ import type {
|
|
|
21
21
|
} from './vitrify-config.js'
|
|
22
22
|
import type { VitrifyContext } from './bin/run.js'
|
|
23
23
|
import type { VitrifyPlugin } from './plugins/index.js'
|
|
24
|
-
import { getPkgJsonDir } from './app-urls.js'
|
|
24
|
+
import { getPkgJsonDir, resolve } from './app-urls.js'
|
|
25
25
|
import type { ManualChunksOption, RollupOptions } from 'rollup'
|
|
26
26
|
|
|
27
27
|
const internalServerModules = [
|
|
@@ -31,6 +31,8 @@ const internalServerModules = [
|
|
|
31
31
|
'vite',
|
|
32
32
|
'fastify',
|
|
33
33
|
'@fastify/static',
|
|
34
|
+
'@fastify/middie',
|
|
35
|
+
'@fastify',
|
|
34
36
|
'node'
|
|
35
37
|
]
|
|
36
38
|
|
|
@@ -192,15 +194,13 @@ export const baseConfig = async ({
|
|
|
192
194
|
vitrifyConfig = {}
|
|
193
195
|
}
|
|
194
196
|
|
|
195
|
-
const localPackages = ['vue', 'vue-router']
|
|
197
|
+
const localPackages = ['vue', 'vue-router', '@vue/server-renderer']
|
|
196
198
|
const cliPackages = []
|
|
197
199
|
const packageUrls: Record<string, URL> =
|
|
198
200
|
vitrifyConfig.vitrify?.urls?.packages || {}
|
|
199
201
|
await (async () => {
|
|
200
202
|
for (const val of localPackages)
|
|
201
|
-
packageUrls[val] = getPkgJsonDir(
|
|
202
|
-
new URL(await resolve(val, appDir!.href))
|
|
203
|
-
)
|
|
203
|
+
packageUrls[val] = getPkgJsonDir(new URL(await resolve(val, appDir)))
|
|
204
204
|
})()
|
|
205
205
|
|
|
206
206
|
// await (async () => {
|
|
@@ -458,7 +458,7 @@ export const baseConfig = async ({
|
|
|
458
458
|
if (command === 'test')
|
|
459
459
|
alias.push({
|
|
460
460
|
find: 'vitest',
|
|
461
|
-
replacement: new URL(await resolve('vitest', cliDir
|
|
461
|
+
replacement: new URL(await resolve('vitest', cliDir)).pathname
|
|
462
462
|
})
|
|
463
463
|
|
|
464
464
|
let rollupOptions: RollupOptions = {}
|
|
@@ -12,9 +12,9 @@ import type {
|
|
|
12
12
|
// import { QuasarResolver } from '../resolver.js';
|
|
13
13
|
import { QuasarResolver } from 'unplugin-vue-components/resolvers'
|
|
14
14
|
import type { VitrifyPlugin } from './index.js'
|
|
15
|
-
import { getPkgJsonDir } from '../app-urls.js'
|
|
15
|
+
import { getPkgJsonDir, resolve } from '../app-urls.js'
|
|
16
16
|
|
|
17
|
-
import { resolve } from 'import-meta-resolve'
|
|
17
|
+
// import { resolve } from 'import-meta-resolve'
|
|
18
18
|
|
|
19
19
|
export interface QuasarConf {
|
|
20
20
|
ctx: Record<string, any>
|
|
@@ -123,7 +123,7 @@ export const QuasarPlugin: VitrifyPlugin = async ({
|
|
|
123
123
|
await (async () => {
|
|
124
124
|
for (const val of localPackages)
|
|
125
125
|
urls!.packages![val] = getPkgJsonDir(
|
|
126
|
-
new URL(await resolve(val, urls!.app
|
|
126
|
+
new URL(await resolve(val, urls!.app!))
|
|
127
127
|
)
|
|
128
128
|
})()
|
|
129
129
|
|
package/src/vite/vue/csr/app.ts
CHANGED
|
@@ -4,22 +4,21 @@ import { getAppDir } from '../../../node/app-urls.js'
|
|
|
4
4
|
import { onRendered, onSetup } from 'virtual:vitrify-hooks'
|
|
5
5
|
import { fastifyCsrPlugin } from './fastify-csr-plugin.js'
|
|
6
6
|
import type { ViteDevServer } from 'vite'
|
|
7
|
-
|
|
8
|
-
const { resolve } = imr
|
|
7
|
+
|
|
9
8
|
// const appDir = getPkgJsonDir(import.meta.url)
|
|
10
9
|
const getString = (str?: string) => str
|
|
11
10
|
let baseUrl = getString(__BASE_URL__)
|
|
12
11
|
const appDir = getAppDir()
|
|
13
12
|
|
|
14
13
|
export const setupApp = async () => {
|
|
15
|
-
const vitrifyDir = new URL('../', await resolve('vitrify', import.meta.url))
|
|
14
|
+
// const vitrifyDir = new URL('../', await resolve('vitrify', new URL(import.meta.url)))
|
|
16
15
|
return createApp({
|
|
17
16
|
onSetup,
|
|
18
17
|
appDir,
|
|
19
18
|
baseUrl,
|
|
20
19
|
onRendered,
|
|
21
20
|
fastifyPlugin: fastifyCsrPlugin,
|
|
22
|
-
vitrifyDir,
|
|
21
|
+
// vitrifyDir,
|
|
23
22
|
mode: import.meta.env.MODE
|
|
24
23
|
})
|
|
25
24
|
}
|
package/src/vite/vue/ssr/app.ts
CHANGED
|
@@ -4,22 +4,21 @@ import { getAppDir } from '../../../node/app-urls.js'
|
|
|
4
4
|
import { onRendered, onSetup } from 'virtual:vitrify-hooks'
|
|
5
5
|
import { fastifySsrPlugin } from './fastify-ssr-plugin.js'
|
|
6
6
|
import type { ViteDevServer } from 'vite'
|
|
7
|
-
|
|
8
|
-
const { resolve } = imr
|
|
7
|
+
|
|
9
8
|
// const appDir = getPkgJsonDir(import.meta.url)
|
|
10
9
|
const getString = (str?: string) => str
|
|
11
10
|
let baseUrl = getString(__BASE_URL__)
|
|
12
11
|
const appDir = getAppDir()
|
|
13
12
|
|
|
14
13
|
export const setupApp = async () => {
|
|
15
|
-
const vitrifyDir = new URL('../', await resolve('vitrify', import.meta.url))
|
|
14
|
+
// const vitrifyDir = new URL('../', await resolve('vitrify', new URL(import.meta.url)))
|
|
16
15
|
return createApp({
|
|
17
16
|
onSetup,
|
|
18
17
|
appDir,
|
|
19
18
|
baseUrl,
|
|
20
19
|
onRendered,
|
|
21
20
|
fastifyPlugin: fastifySsrPlugin,
|
|
22
|
-
vitrifyDir,
|
|
21
|
+
// vitrifyDir,
|
|
23
22
|
mode: import.meta.env.MODE
|
|
24
23
|
})
|
|
25
24
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createApp } from '../main.js'
|
|
2
|
-
import { renderToString } from 'vue/server-renderer'
|
|
2
|
+
import { renderToString } from '@vue/server-renderer'
|
|
3
3
|
import type { FastifyInstance } from 'fastify'
|
|
4
4
|
// import * as ApolloSSR from '@vue/apollo-ssr'
|
|
5
5
|
// import { ApolloClients } from '@vue/apollo-composable'
|