vitrify 0.5.1 → 0.5.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/build.js CHANGED
@@ -8,7 +8,8 @@ export async function build(opts) {
8
8
  ssr: opts?.ssr,
9
9
  appDir: opts.appDir,
10
10
  publicDir: opts.publicDir,
11
- base: opts.base
11
+ base: opts.base,
12
+ debug: opts.debug
12
13
  });
13
14
  config.build = {
14
15
  ...config.build,
package/dist/bin/cli.js CHANGED
@@ -11,6 +11,7 @@ cli
11
11
  .option('--appDir [appDir]', 'App directory')
12
12
  .option('--publicDir [publicDir]', 'Public directory')
13
13
  .option('--productName [productName]', 'Product name')
14
+ .option('--debug', 'Debug build')
14
15
  .action(async (options) => {
15
16
  const { build } = await import('./build.js');
16
17
  let appDir;
@@ -27,7 +28,8 @@ cli
27
28
  const args = {
28
29
  base: options.base,
29
30
  appDir,
30
- publicDir: parsePath(options.publicDir, appDir)
31
+ publicDir: parsePath(options.publicDir, appDir),
32
+ debug: options.debug
31
33
  };
32
34
  switch (options.mode) {
33
35
  case 'csr':
@@ -1,4 +1,4 @@
1
- import fastifyStatic from '@fastify/static';
1
+ import { fastifyStatic } from '@fastify/static';
2
2
  const fastifyCsrPlugin = async (fastify, options, done) => {
3
3
  options.vitrifyDir =
4
4
  options.vitrifyDir || (await import('vitrify')).vitrifyDir;
@@ -1,4 +1,4 @@
1
- import fastifyStatic from '@fastify/static';
1
+ import { fastifyStatic } from '@fastify/static';
2
2
  import { readFileSync } from 'fs';
3
3
  import { componentsModules, collectCss } from '../../helpers/collect-css-ssr.js';
4
4
  const fastifySsrPlugin = async (fastify, options, done) => {
package/dist/index.js CHANGED
@@ -7,38 +7,16 @@ import { pathToFileURL } from 'url';
7
7
  import { readFileSync } from 'fs';
8
8
  import builtinModules from 'builtin-modules';
9
9
  import { resolve } from 'import-meta-resolve';
10
+ import { visualizer } from 'rollup-plugin-visualizer';
10
11
  import { getPkgJsonDir } from './app-urls.js';
11
12
  const internalServerModules = [
12
- // 'fs',
13
- // 'path',
14
- // 'url',
15
- // 'module',
16
- // 'crypto',
17
- // 'node:fs',
18
13
  'util',
19
- 'node:url',
20
- 'node:util',
21
- 'node:fs',
22
- 'node:process',
23
14
  'vitrify',
24
15
  'vitrify/dev',
25
- // 'import-meta-resolve',
26
16
  'vite',
27
17
  'fastify',
28
- '@fastify',
18
+ '@fastify/static',
29
19
  'node'
30
- // 'middie',
31
- // 'knex',
32
- // 'bcrypt',
33
- // 'objection',
34
- // '@fastify/formbody',
35
- // '@fastify/static',
36
- // '@fastify/cors',
37
- // '@fastify/cookie',
38
- // 'mercurius',
39
- // 'jose',
40
- // 'oidc-provider',
41
- // 'node-fetch'
42
20
  ];
43
21
  const configPluginMap = {
44
22
  quasar: () => import('./plugins/quasar.js').then((module) => module.QuasarPlugin)
@@ -55,6 +33,9 @@ const manualChunks = (id) => {
55
33
  if (name && manualChunkNames.includes(name))
56
34
  return name;
57
35
  }
36
+ else if (VIRTUAL_MODULES.some((virtualModule) => id.includes(virtualModule))) {
37
+ return VIRTUAL_MODULES.find((name) => id.includes(name));
38
+ }
58
39
  else if (id.includes('node_modules')) {
59
40
  return 'vendor';
60
41
  }
@@ -112,7 +93,7 @@ async function bundleConfigFile(fileName, isESM = false) {
112
93
  dependencies: result.metafile ? Object.keys(result.metafile.inputs) : []
113
94
  };
114
95
  }
115
- export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command = 'build', mode = 'production', framework = 'vue', pwa = false }) => {
96
+ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command = 'build', mode = 'production', framework = 'vue', pwa = false, debug = false }) => {
116
97
  const { getAppDir, getCliDir, getCliViteDir, getSrcDir, getCwd } = await import('./app-urls.js');
117
98
  if (!appDir) {
118
99
  appDir = getAppDir();
@@ -357,6 +338,8 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
357
338
  }
358
339
  }
359
340
  });
341
+ if (debug)
342
+ plugins.push(visualizer());
360
343
  }
361
344
  const alias = [
362
345
  { find: 'src', replacement: srcDir.pathname },
@@ -386,6 +369,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
386
369
  const external = [...builtinModules, ...serverModules];
387
370
  if (ssr === 'server') {
388
371
  rollupOptions = {
372
+ ...rollupOptions,
389
373
  input: [
390
374
  new URL('ssr/entry-server.ts', frameworkDir).pathname,
391
375
  new URL('ssr/prerender.ts', frameworkDir).pathname,
@@ -416,6 +400,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
416
400
  }
417
401
  else if (ssr === 'fastify') {
418
402
  rollupOptions = {
403
+ ...rollupOptions,
419
404
  input: [new URL('server.ts', fastifyDir).pathname],
420
405
  external,
421
406
  output: {
@@ -441,10 +426,11 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
441
426
  }
442
427
  else {
443
428
  rollupOptions = {
444
- input: [
445
- new URL('index.html', frameworkDir).pathname
446
- // new URL('csr/server.ts', frameworkDir).pathname
447
- ],
429
+ ...rollupOptions,
430
+ // input: [
431
+ // new URL('index.html', frameworkDir).pathname
432
+ // // new URL('csr/server.ts', frameworkDir).pathname
433
+ // ],
448
434
  external,
449
435
  output: {
450
436
  minifyInternalExports: false,
@@ -154,10 +154,6 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
154
154
  replacement: new URL('src/index.all.js', urls?.packages?.quasar)
155
155
  .pathname
156
156
  },
157
- // {
158
- // find: 'quasar',
159
- // replacement: new URL('src/index.all.js', urls?.packages?.quasar).pathname
160
- // },
161
157
  {
162
158
  find: `@quasar/extras`,
163
159
  replacement: new URL('.', urls?.packages?.['@quasar/extras'])
@@ -188,7 +184,7 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
188
184
  config: async (config, env) => ({
189
185
  resolve: {
190
186
  alias: [
191
- // { find: new RegExp('^quasar$'), replacement: 'virtual:quasar' }
187
+ { find: new RegExp('^quasar$'), replacement: 'virtual:quasar' }
192
188
  ]
193
189
  }
194
190
  }),
@@ -5,4 +5,5 @@ export declare function build(opts: {
5
5
  outDir: string;
6
6
  appDir?: URL;
7
7
  publicDir?: URL;
8
+ debug?: boolean;
8
9
  }): Promise<import("rollup").RollupOutput | import("rollup").RollupOutput[] | import("rollup").RollupWatcher>;
@@ -3,7 +3,7 @@ import type { BootFunction, VitrifyConfig } from './vitrify-config.js';
3
3
  import type { VitrifyContext } from './bin/run.js';
4
4
  import type { VitrifyPlugin } from './plugins/index.js';
5
5
  export declare const VIRTUAL_MODULES: string[];
6
- export declare const baseConfig: ({ ssr, appDir, publicDir, base, command, mode, framework, pwa }: {
6
+ export declare const baseConfig: ({ ssr, appDir, publicDir, base, command, mode, framework, pwa, debug }: {
7
7
  ssr?: "server" | "client" | "ssg" | "fastify" | undefined;
8
8
  appDir?: URL | undefined;
9
9
  publicDir?: URL | undefined;
@@ -12,6 +12,7 @@ export declare const baseConfig: ({ ssr, appDir, publicDir, base, command, mode,
12
12
  mode?: "production" | "development" | undefined;
13
13
  framework?: "vue" | undefined;
14
14
  pwa?: boolean | undefined;
15
+ debug?: boolean | undefined;
15
16
  }) => Promise<InlineConfig>;
16
17
  export declare const vitrifyDir: URL;
17
18
  export type { VitrifyConfig, VitrifyPlugin, VitrifyContext, BootFunction };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitrify",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "license": "MIT",
5
5
  "author": "Stefan van Herwijnen",
6
6
  "description": "Pre-configured Vite CLI for your framework",
@@ -68,6 +68,7 @@
68
68
  "magic-string": "^0.26.2",
69
69
  "merge-deep": "^3.0.3",
70
70
  "readline": "^1.3.0",
71
+ "rollup-plugin-visualizer": "^5.6.0",
71
72
  "sass": "1.52.3",
72
73
  "ts-node": "^10.8.1",
73
74
  "unplugin-vue-components": "^0.19.6",
@@ -93,10 +94,10 @@
93
94
  "@fastify/static": "^6.4.0",
94
95
  "fastify": "^4.0.0",
95
96
  "fastify-plugin": "^3.0.1",
97
+ "import-meta-resolve": "^2.0.3",
96
98
  "quasar": "^2.7.1",
97
99
  "vue": "^3.2.37",
98
- "vue-router": "^4.0.15",
99
- "import-meta-resolve": "^2.0.3"
100
+ "vue-router": "^4.0.15"
100
101
  },
101
102
  "publishConfig": {
102
103
  "access": "public",
@@ -8,6 +8,7 @@ export async function build(opts: {
8
8
  outDir: string
9
9
  appDir?: URL
10
10
  publicDir?: URL
11
+ debug?: boolean
11
12
  }) {
12
13
  const config = await baseConfig({
13
14
  command: 'build',
@@ -15,7 +16,8 @@ export async function build(opts: {
15
16
  ssr: opts?.ssr,
16
17
  appDir: opts.appDir,
17
18
  publicDir: opts.publicDir,
18
- base: opts.base
19
+ base: opts.base,
20
+ debug: opts.debug
19
21
  })
20
22
 
21
23
  config.build = {
@@ -20,6 +20,7 @@ cli
20
20
  .option('--appDir [appDir]', 'App directory')
21
21
  .option('--publicDir [publicDir]', 'Public directory')
22
22
  .option('--productName [productName]', 'Product name')
23
+ .option('--debug', 'Debug build')
23
24
  .action(async (options) => {
24
25
  const { build } = await import('./build.js')
25
26
  let appDir: URL
@@ -38,10 +39,12 @@ cli
38
39
  base: string
39
40
  appDir?: URL
40
41
  publicDir?: URL
42
+ debug?: boolean
41
43
  } = {
42
44
  base: options.base,
43
45
  appDir,
44
- publicDir: parsePath(options.publicDir, appDir)
46
+ publicDir: parsePath(options.publicDir, appDir),
47
+ debug: options.debug
45
48
  }
46
49
 
47
50
  switch (options.mode) {
@@ -3,7 +3,7 @@ import type {
3
3
  FastifyRequest,
4
4
  FastifyReply
5
5
  } from 'fastify'
6
- import fastifyStatic from '@fastify/static'
6
+ import { fastifyStatic } from '@fastify/static'
7
7
  import type { OnRenderedHook } from '../../vitrify-config.js'
8
8
  import type { ViteDevServer } from 'vite'
9
9
 
@@ -3,7 +3,7 @@ import type {
3
3
  FastifyRequest,
4
4
  FastifyReply
5
5
  } from 'fastify'
6
- import fastifyStatic from '@fastify/static'
6
+ import { fastifyStatic } from '@fastify/static'
7
7
  import { readFileSync } from 'fs'
8
8
  import type { OnRenderedHook } from '../../vitrify-config.js'
9
9
  import { componentsModules, collectCss } from '../../helpers/collect-css-ssr.js'
package/src/node/index.ts CHANGED
@@ -9,6 +9,7 @@ import { pathToFileURL } from 'url'
9
9
  import { readFileSync } from 'fs'
10
10
  import builtinModules from 'builtin-modules'
11
11
  import { resolve } from 'import-meta-resolve'
12
+ import { visualizer } from 'rollup-plugin-visualizer'
12
13
  import type {
13
14
  StaticImports,
14
15
  BootFunction,
@@ -21,39 +22,16 @@ import type {
21
22
  import type { VitrifyContext } from './bin/run.js'
22
23
  import type { VitrifyPlugin } from './plugins/index.js'
23
24
  import { getPkgJsonDir } from './app-urls.js'
24
- import type { RollupOptions } from 'rollup'
25
+ import type { ManualChunksOption, RollupOptions } from 'rollup'
25
26
 
26
27
  const internalServerModules = [
27
- // 'fs',
28
- // 'path',
29
- // 'url',
30
- // 'module',
31
- // 'crypto',
32
- // 'node:fs',
33
28
  'util',
34
- 'node:url',
35
- 'node:util',
36
- 'node:fs',
37
- 'node:process',
38
29
  'vitrify',
39
30
  'vitrify/dev',
40
- // 'import-meta-resolve',
41
31
  'vite',
42
32
  'fastify',
43
- '@fastify',
33
+ '@fastify/static',
44
34
  'node'
45
- // 'middie',
46
- // 'knex',
47
- // 'bcrypt',
48
- // 'objection',
49
- // '@fastify/formbody',
50
- // '@fastify/static',
51
- // '@fastify/cors',
52
- // '@fastify/cookie',
53
- // 'mercurius',
54
- // 'jose',
55
- // 'oidc-provider',
56
- // 'node-fetch'
57
35
  ]
58
36
 
59
37
  const configPluginMap: Record<string, () => Promise<VitrifyPlugin>> = {
@@ -67,10 +45,14 @@ const manualChunkNames = [
67
45
  'fastify-csr-plugin',
68
46
  'server'
69
47
  ]
70
- const manualChunks = (id: string) => {
48
+ const manualChunks: ManualChunksOption = (id: string) => {
71
49
  if (id.includes('vitrify/src/vite/')) {
72
50
  const name = id.split('/').at(-1)?.split('.').at(0)
73
51
  if (name && manualChunkNames.includes(name)) return name
52
+ } else if (
53
+ VIRTUAL_MODULES.some((virtualModule) => id.includes(virtualModule))
54
+ ) {
55
+ return VIRTUAL_MODULES.find((name) => id.includes(name))
74
56
  } else if (id.includes('node_modules')) {
75
57
  return 'vendor'
76
58
  }
@@ -148,7 +130,8 @@ export const baseConfig = async ({
148
130
  command = 'build',
149
131
  mode = 'production',
150
132
  framework = 'vue',
151
- pwa = false
133
+ pwa = false,
134
+ debug = false
152
135
  }: {
153
136
  ssr?: 'client' | 'server' | 'ssg' | 'fastify'
154
137
  appDir?: URL
@@ -158,6 +141,7 @@ export const baseConfig = async ({
158
141
  mode?: 'production' | 'development'
159
142
  framework?: 'vue'
160
143
  pwa?: boolean
144
+ debug?: boolean
161
145
  }): Promise<InlineConfig> => {
162
146
  const { getAppDir, getCliDir, getCliViteDir, getSrcDir, getCwd } =
163
147
  await import('./app-urls.js')
@@ -438,6 +422,8 @@ export const baseConfig = async ({
438
422
  }
439
423
  }
440
424
  })
425
+
426
+ if (debug) plugins.push(visualizer())
441
427
  }
442
428
 
443
429
  const alias: Alias[] = [
@@ -471,6 +457,7 @@ export const baseConfig = async ({
471
457
 
472
458
  if (ssr === 'server') {
473
459
  rollupOptions = {
460
+ ...rollupOptions,
474
461
  input: [
475
462
  new URL('ssr/entry-server.ts', frameworkDir).pathname,
476
463
  new URL('ssr/prerender.ts', frameworkDir).pathname,
@@ -500,6 +487,7 @@ export const baseConfig = async ({
500
487
  ]
501
488
  } else if (ssr === 'fastify') {
502
489
  rollupOptions = {
490
+ ...rollupOptions,
503
491
  input: [new URL('server.ts', fastifyDir).pathname],
504
492
  external,
505
493
  output: {
@@ -524,10 +512,11 @@ export const baseConfig = async ({
524
512
  ]
525
513
  } else {
526
514
  rollupOptions = {
527
- input: [
528
- new URL('index.html', frameworkDir).pathname
529
- // new URL('csr/server.ts', frameworkDir).pathname
530
- ],
515
+ ...rollupOptions,
516
+ // input: [
517
+ // new URL('index.html', frameworkDir).pathname
518
+ // // new URL('csr/server.ts', frameworkDir).pathname
519
+ // ],
531
520
  external,
532
521
  output: {
533
522
  minifyInternalExports: false,
@@ -13,6 +13,7 @@ import type {
13
13
  import { QuasarResolver } from 'unplugin-vue-components/resolvers'
14
14
  import type { VitrifyPlugin } from './index.js'
15
15
  import { getPkgJsonDir } from '../app-urls.js'
16
+
16
17
  import { resolve } from 'import-meta-resolve'
17
18
 
18
19
  export interface QuasarConf {
@@ -248,10 +249,6 @@ export const QuasarPlugin: VitrifyPlugin = async ({
248
249
  replacement: new URL('src/index.all.js', urls?.packages?.quasar)
249
250
  .pathname
250
251
  },
251
- // {
252
- // find: 'quasar',
253
- // replacement: new URL('src/index.all.js', urls?.packages?.quasar).pathname
254
- // },
255
252
  {
256
253
  find: `@quasar/extras`,
257
254
  replacement: new URL('.', urls?.packages?.['@quasar/extras'])
@@ -282,7 +279,7 @@ export const QuasarPlugin: VitrifyPlugin = async ({
282
279
  config: async (config, env) => ({
283
280
  resolve: {
284
281
  alias: [
285
- // { find: new RegExp('^quasar$'), replacement: 'virtual:quasar' }
282
+ { find: new RegExp('^quasar$'), replacement: 'virtual:quasar' }
286
283
  ]
287
284
  }
288
285
  }),
@@ -1,4 +1,3 @@
1
- import type { FastifyInstance } from 'fastify'
2
1
  import type { Alias, UserConfig } from 'vite'
3
2
  import type { QuasarConf } from './plugins/quasar.js'
4
3
  import type { ComponentInternalInstance } from '@vue/runtime-core'