vitrify 0.2.4 → 0.4.0

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.
Files changed (47) hide show
  1. package/dist/app-urls.js +1 -2
  2. package/dist/bin/build.js +0 -43
  3. package/dist/bin/cli.js +29 -7
  4. package/dist/bin/dev.js +58 -67
  5. package/dist/frameworks/vue/fastify-ssr-plugin.js +67 -23
  6. package/dist/frameworks/vue/prerender.js +3 -3
  7. package/dist/frameworks/vue/server.js +9 -10
  8. package/dist/helpers/collect-css-ssr.js +57 -0
  9. package/dist/helpers/logger.js +0 -72
  10. package/dist/index.js +268 -122
  11. package/dist/plugins/quasar.js +13 -106
  12. package/dist/types/bin/build.d.ts +2 -2
  13. package/dist/types/bin/dev.d.ts +39 -3
  14. package/dist/types/frameworks/vue/fastify-ssr-plugin.d.ts +6 -3
  15. package/dist/types/frameworks/vue/prerender.d.ts +3 -3
  16. package/dist/types/frameworks/vue/server.d.ts +9 -5
  17. package/dist/types/helpers/collect-css-ssr.d.ts +10 -0
  18. package/dist/types/helpers/logger.d.ts +0 -19
  19. package/dist/types/helpers/routes.d.ts +1 -1
  20. package/dist/types/index.d.ts +1 -1
  21. package/dist/types/plugins/index.d.ts +1 -1
  22. package/dist/types/vitrify-config.d.ts +20 -16
  23. package/package.json +32 -32
  24. package/src/node/app-urls.ts +1 -2
  25. package/src/node/bin/build.ts +2 -49
  26. package/src/node/bin/cli.ts +36 -8
  27. package/src/node/bin/dev.ts +89 -75
  28. package/src/node/bin/test.ts +0 -3
  29. package/src/node/frameworks/vue/fastify-ssr-plugin.ts +80 -26
  30. package/src/node/frameworks/vue/prerender.ts +5 -5
  31. package/src/node/frameworks/vue/server.ts +22 -16
  32. package/src/node/helpers/collect-css-ssr.ts +77 -0
  33. package/src/node/helpers/logger.ts +0 -87
  34. package/src/node/index.ts +302 -137
  35. package/src/node/plugins/index.ts +1 -1
  36. package/src/node/plugins/quasar.ts +14 -111
  37. package/src/node/vitrify-config.ts +31 -16
  38. package/src/vite/fastify/entry.ts +11 -0
  39. package/src/vite/fastify/server.ts +10 -0
  40. package/src/vite/vue/index.html +1 -0
  41. package/src/vite/vue/main.ts +5 -20
  42. package/src/vite/vue/ssr/app.ts +25 -0
  43. package/src/vite/vue/ssr/entry-server.ts +13 -1
  44. package/src/vite/vue/ssr/fastify-ssr-plugin.ts +2 -118
  45. package/src/vite/vue/ssr/prerender.ts +2 -2
  46. package/src/vite/vue/ssr/server.ts +24 -15
  47. package/src/node/helpers/ssr.ts.bak +0 -52
@@ -31,38 +31,9 @@ export const injectSsrContext = (html, ssrContext) => html
31
31
  }
32
32
  return `${start} class="${classes.trim()}" ${ssrContext._meta.bodyAttrs || ''}${end}${ssrContext._meta.bodyTags || ''}`;
33
33
  });
34
- // export interface Configuration {
35
- // ssr?: 'server' | 'client' | 'ssg' | false
36
- // }
37
34
  export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
38
- // const extraPlugins: Plugin[] = []
39
- // const ctx = {
40
- // prod: process.env.MODE === 'production',
41
- // dev: process.env.MODE === 'development',
42
- // mode: {
43
- // ssr: !!ssr,
44
- // pwa: !!pwa
45
- // }
46
- // }
47
- // let bootFilePaths: Record<string, any> = {}
48
- // let components: string[] = []
49
35
  let plugins = [];
50
- // let css: string[] = []
51
- let extras = [];
52
36
  return [
53
- // {
54
- // name: 'legacy-support',
55
- // enforce: 'pre',
56
- // transform (code, id) {
57
- // /**
58
- // * ESM does not resolve an import to .default when there are multiple exports. The following is required to make the VuePlugin import of QCalendar work.
59
- // */
60
- // if (code.includes('app.use(VuePlugin)')) {
61
- // code = code.replace(/app\.use\(VuePlugin\)/g, `app.use(VuePlugin.install ? VuePlugin : VuePlugin.default)`)
62
- // }
63
- // return code
64
- // }
65
- // },
66
37
  Components({
67
38
  resolvers: [QuasarResolver()]
68
39
  }),
@@ -84,15 +55,13 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
84
55
  $q.onSSRHydrated !== void 0 && $q.onSSRHydrated();
85
56
  }
86
57
  ];
87
- const bootFunctions = [
58
+ const onBootHooks = [
88
59
  async ({ app, ssrContext, staticImports }) => {
89
- // @ts-ignore
90
- // const quasarVuePlugin = (await import('quasar/vue-plugin')).default
91
60
  // @ts-ignore
92
61
  const quasarPlugins = await import('virtual:quasar-plugins');
93
62
  // @ts-ignore
94
63
  const directives = await import('quasar/src/directives.js');
95
- app.use(staticImports.Quasar, {
64
+ app.use(staticImports?.Quasar, {
96
65
  plugins: quasarPlugins,
97
66
  directives
98
67
  }, ssrContext);
@@ -101,14 +70,14 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
101
70
  return {
102
71
  vitrify: {
103
72
  urls,
104
- bootFunctions,
105
- ssrFunctions: [injectSsrContext],
106
73
  globalCss,
107
74
  staticImports: {
108
75
  quasar: ['Quasar']
109
76
  },
110
77
  hooks: {
111
- onMounted: onMountedHooks
78
+ onBoot: onBootHooks,
79
+ onMounted: onMountedHooks,
80
+ onRendered: [injectSsrContext]
112
81
  },
113
82
  sass: {
114
83
  additionalData: [`@import 'quasar/src/css/index.sass'`]
@@ -120,50 +89,10 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
120
89
  {
121
90
  name: 'vite-plugin-quasar',
122
91
  enforce: 'post',
123
- // transformIndexHtml: {
124
- // enforce: 'post',
125
- // transform: (html) => {
126
- // return html.replace(
127
- // '<!--product-name-->',
128
- // productName
129
- // )
130
- // }
131
- // },
132
92
  config: async (config, env) => {
133
- // let appDir: URL
134
- // let cliDir: URL
135
- // let cwd: URL
136
- // let quasarDir: URL
137
- // let quasarConf: QuasarConf | undefined
138
93
  const { quasar: quasarConf, vitrify: { urls } = {} } = config;
139
94
  const quasarPkgJsonPath = new URL('package.json', urls?.packages?.quasar).pathname;
140
95
  const { version } = JSON.parse(readFileSync(quasarPkgJsonPath, { encoding: 'utf-8' }));
141
- // if (quasarConf?.boot) {
142
- // bootFilePaths = (quasarConf.boot as (Record<string, any> | string)[])
143
- // .filter(entry => {
144
- // if (typeof entry === 'object') return (entry.server && (ssr === 'server'))
145
- // else if (entry !== '') return true
146
- // })
147
- // .map(entry => {
148
- // if (typeof entry === 'string') return entry
149
- // else if (typeof entry === 'object') return entry.path
150
- // })
151
- // .reduce((acc, entry) => {
152
- // if (entry[0] === '~') {
153
- // const split = entry.substring(1).split('/')
154
- // const name = split[0].replace(/[|&;$%@"<>()+,]/g, "");
155
- // acc[name] = {
156
- // path: new URL(`node_modules/${entry.substring(1)}`, urls?.app).pathname
157
- // }
158
- // } else {
159
- // const name = entry.split('.')[0]
160
- // acc[name] = {
161
- // path: `src/boot/${entry}`
162
- // }
163
- // }
164
- // return acc
165
- // }, {})
166
- // }
167
96
  /**
168
97
  * All components should have been auto-imported
169
98
  */
@@ -175,13 +104,6 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
175
104
  ];
176
105
  plugins = quasarConf?.framework.plugins;
177
106
  }
178
- // css = (quasarConf?.css || []).map((v => {
179
- // if (v[0] === '~') {
180
- // return v.slice(1)
181
- // }
182
- // return v
183
- // })).map((v) => `@import '${v}'`)
184
- extras = quasarConf?.extras || [];
185
107
  return {
186
108
  resolve: {
187
109
  alias: [
@@ -214,22 +136,20 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
214
136
  find: 'quasar/src',
215
137
  replacement: new URL('src/', urls?.packages?.quasar).pathname
216
138
  },
217
- // ...extras.map(extra => ({
218
- // find: `@quasar/extras/${extra}/${extra}.css`,
219
- // replacement: new URL(`${extra}/${extra}.css`, urls?.packages?.['@quasar/extras']).pathname
220
- // })
221
- // ),
222
139
  {
223
- find: 'quasar',
224
- replacement: new URL('src/', urls?.packages?.quasar).pathname
140
+ find: new RegExp('^quasar$'),
141
+ replacement: new URL('src/index.all.js', urls?.packages?.quasar)
142
+ .pathname
225
143
  },
144
+ // {
145
+ // find: 'quasar',
146
+ // replacement: new URL('src/index.all.js', urls?.packages?.quasar).pathname
147
+ // },
226
148
  {
227
149
  find: `@quasar/extras`,
228
150
  replacement: new URL('.', urls?.packages?.['@quasar/extras'])
229
151
  .pathname
230
152
  }
231
- // { find: new RegExp('^quasar$'), replacement: new URL('src/index.all.js', urls?.packages?.quasar).pathname },
232
- // { find: new RegExp('^quasar$'), replacement: 'virtual:quasar' },
233
153
  ]
234
154
  },
235
155
  define: {
@@ -240,19 +160,6 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
240
160
  __QUASAR_SSR_CLIENT__: ssr === 'client',
241
161
  __QUASAR_SSR_PWA__: ssr === 'client' && pwa
242
162
  },
243
- // css: {
244
- // preprocessorOptions: {
245
- // sass: {
246
- // additionalData: `@import 'quasar/src/css/index.sass'`
247
- // // [
248
- // // // ...extras.map(extra => `@import "@quasar/extras/${extra}/${extra}.css"`),
249
- // // // ...extras.map(extra => `@import ${new URL(`${extra}/${extra}.css`, urls?.packages?.['@quasar/extras']).pathname}`) || [],
250
- // // // config.css?.preprocessorOptions?.sass?.additionalData,
251
- // // `@import 'quasar/src/css/index.sass'`
252
- // // ].join('\n')
253
- // }
254
- // }
255
- // },
256
163
  ssr: {
257
164
  noExternal: ['quasar']
258
165
  }
@@ -265,7 +172,7 @@ export const QuasarPlugin = async ({ ssr = false, pwa = false }) => {
265
172
  config: async (config, env) => ({
266
173
  resolve: {
267
174
  alias: [
268
- { find: new RegExp('^quasar$'), replacement: 'virtual:quasar' }
175
+ // { find: new RegExp('^quasar$'), replacement: 'virtual:quasar' }
269
176
  ]
270
177
  }
271
178
  }),
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/node --experimental-specifier-resolution=node
2
2
  export declare function build(opts: {
3
- ssr?: 'client' | 'server' | 'ssg';
3
+ ssr?: 'client' | 'server' | 'ssg' | 'fastify';
4
4
  base?: string;
5
- outDir?: string;
5
+ outDir: string;
6
6
  appDir?: URL;
7
7
  publicDir?: URL;
8
8
  }): Promise<import("rollup").RollupOutput | import("rollup").RollupOutput[] | import("rollup").RollupWatcher>;
@@ -1,15 +1,51 @@
1
1
  /// <reference types="node" />
2
- import type { ViteDevServer, LogLevel } from 'vite';
2
+ import type { LogLevel, InlineConfig } from 'vite';
3
+ import { ViteDevServer } from 'vite';
3
4
  import type { Server } from 'net';
5
+ export declare function createVitrifyDevServer({ port, logLevel, mode, framework, host, appDir, publicDir }: {
6
+ port?: number;
7
+ logLevel?: LogLevel;
8
+ mode?: 'csr' | 'ssr' | 'fastify';
9
+ framework?: 'vue';
10
+ host?: string;
11
+ appDir?: URL;
12
+ publicDir?: URL;
13
+ }): Promise<ViteDevServer>;
4
14
  export declare function createServer({ port, logLevel, mode, framework, host, appDir, publicDir }: {
5
15
  port?: number;
6
16
  logLevel?: LogLevel;
7
- mode?: 'csr' | 'ssr';
17
+ mode?: 'csr' | 'ssr' | 'fastify';
8
18
  framework?: 'vue';
9
19
  host?: string;
10
20
  appDir?: URL;
11
21
  publicDir?: URL;
12
22
  }): Promise<{
13
23
  server: Server;
14
- vite: ViteDevServer;
24
+ config: Readonly<Omit<import("vite").UserConfig, "plugins" | "assetsInclude" | "optimizeDeps" | "worker"> & {
25
+ configFile: string | undefined;
26
+ configFileDependencies: string[];
27
+ inlineConfig: InlineConfig;
28
+ root: string;
29
+ base: string;
30
+ publicDir: string;
31
+ cacheDir: string;
32
+ command: "build" | "serve";
33
+ mode: string;
34
+ isWorker: boolean;
35
+ isProduction: boolean;
36
+ env: Record<string, any>;
37
+ resolve: import("vite").ResolveOptions & {
38
+ alias: import("vite").Alias[];
39
+ };
40
+ plugins: readonly import("vite").Plugin[];
41
+ server: import("vite").ResolvedServerOptions;
42
+ build: Required<import("vite").BuildOptions>;
43
+ preview: import("vite").ResolvedPreviewOptions;
44
+ assetsInclude: (file: string) => boolean;
45
+ logger: import("vite").Logger;
46
+ createResolver: (options?: Partial<import("vite").InternalResolveOptions> | undefined) => import("vite").ResolveFn;
47
+ optimizeDeps: import("vite").DepOptimizationOptions;
48
+ worker: import("vite").ResolveWorkerOptions;
49
+ spa: boolean;
50
+ }>;
15
51
  }>;
@@ -1,14 +1,17 @@
1
1
  import type { FastifyPluginCallback, FastifyRequest, FastifyReply } from 'fastify';
2
+ import type { OnRenderedHook } from '../../vitrify-config.js';
2
3
  import type { ViteDevServer } from 'vite';
3
- import type { SsrFunction } from '../../vitrify-config.js';
4
4
  export interface FastifySsrOptions {
5
5
  baseUrl?: string;
6
6
  provide?: (req: FastifyRequest, res: FastifyReply) => Promise<Record<string, unknown>>;
7
+ vitrifyDir?: URL;
7
8
  vite?: ViteDevServer;
8
- cliDir?: URL;
9
9
  appDir?: URL;
10
+ publicDir?: URL;
10
11
  productName?: string;
11
- ssrFunctions?: SsrFunction[];
12
+ onRendered?: OnRenderedHook[];
13
+ mode?: string;
12
14
  }
13
15
  declare const fastifySsrPlugin: FastifyPluginCallback<FastifySsrOptions>;
14
16
  export { fastifySsrPlugin };
17
+ export declare type FastifySsrPlugin = typeof fastifySsrPlugin;
@@ -1,8 +1,8 @@
1
- import type { SsrFunction } from '../../vitrify-config.js';
2
- export declare const prerender: ({ outDir, templatePath, manifestPath, entryServerPath, ssrFunctions }: {
1
+ import type { OnRenderedHook } from '../../vitrify-config.js';
2
+ export declare const prerender: ({ outDir, templatePath, manifestPath, entryServerPath, onRenderedHooks }: {
3
3
  outDir: string;
4
4
  templatePath: string;
5
5
  manifestPath: string;
6
6
  entryServerPath: string;
7
- ssrFunctions: SsrFunction[];
7
+ onRenderedHooks: OnRenderedHook[];
8
8
  }) => Promise<void[]>;
@@ -1,9 +1,13 @@
1
1
  /// <reference types="node" />
2
2
  import type { FastifyInstance } from 'fastify';
3
- import type { SsrFunction } from '../../vitrify-config.js';
4
- export declare const createApp: ({ setup, appDir, baseUrl, ssrFunctions }: {
5
- setup: (fastify: FastifyInstance) => any;
3
+ import type { OnRenderedHook, OnSetupFile } from '../../vitrify-config.js';
4
+ import type { FastifySsrPlugin } from './fastify-ssr-plugin.js';
5
+ export declare const createApp: ({ onSetup, appDir, baseUrl, onRendered, fastifySsrPlugin, vitrifyDir, mode }: {
6
+ onSetup: OnSetupFile[];
6
7
  appDir: URL;
7
8
  baseUrl?: string | undefined;
8
- ssrFunctions?: SsrFunction[] | undefined;
9
- }) => FastifyInstance<import("http").Server, import("http").IncomingMessage, import("http").ServerResponse, import("fastify").FastifyLoggerInstance> & PromiseLike<FastifyInstance<import("http").Server, import("http").IncomingMessage, import("http").ServerResponse, import("fastify").FastifyLoggerInstance>>;
9
+ onRendered?: OnRenderedHook[] | undefined;
10
+ fastifySsrPlugin: FastifySsrPlugin;
11
+ vitrifyDir?: URL | undefined;
12
+ mode: string;
13
+ }) => 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>>;
@@ -0,0 +1,10 @@
1
+ import type { ViteDevServer, ModuleNode } from 'vite';
2
+ /**
3
+ * Collect SSR CSS for Vite
4
+ */
5
+ export declare const componentsModules: (components: string[], vite: ViteDevServer) => Set<ModuleNode>;
6
+ export declare const collectCss: (mods: Set<ModuleNode>, styles?: Map<string, string>, checkedComponents?: Set<unknown>) => string;
7
+ /**
8
+ * Client listener to detect updated modules through HMR, and remove the initial styled attached to the head
9
+ */
10
+ export declare const removeCssHotReloaded: () => void;
@@ -1,23 +1,4 @@
1
1
  /// <reference types="node" />
2
2
  import type { Server } from 'net';
3
3
  import type { ResolvedConfig } from 'vite';
4
- export declare const clearConsole: () => void;
5
- export declare const log: (msg?: string | undefined) => void;
6
- export declare const warn: (msg?: string | undefined, pill?: string | undefined) => void;
7
- export declare const fatal: (msg?: string | undefined, pill?: string | undefined) => never;
8
- /**
9
- * Extended approach - Compilation status & pills
10
- */
11
- export declare const successPill: (msg?: string | undefined) => string;
12
- export declare const infoPill: (msg?: string | undefined) => string;
13
- export declare const errorPill: (msg?: string | undefined) => string;
14
- export declare const warningPill: (msg?: string | undefined) => string;
15
- export declare const success: (msg?: string | undefined, title?: string) => void;
16
- export declare const getSuccess: (msg?: string | undefined, title?: string | undefined) => string;
17
- export declare const info: (msg?: string | undefined, title?: string) => void;
18
- export declare const getInfo: (msg?: string | undefined, title?: string | undefined) => string;
19
- export declare const error: (msg?: string | undefined, title?: string) => void;
20
- export declare const getError: (msg?: string | undefined, title?: string) => string;
21
- export declare const warning: (msg?: string | undefined, title?: string) => void;
22
- export declare const getWarning: (msg?: string | undefined, title?: string) => string;
23
4
  export declare function printHttpServerUrls(server: Server, config: ResolvedConfig): void;
@@ -1,2 +1,2 @@
1
1
  import type { RouteRecordRaw } from 'vue-router';
2
- export declare const routesToPaths: (routes?: RouteRecordRaw[] | undefined) => string[];
2
+ export declare const routesToPaths: (routes?: RouteRecordRaw[]) => string[];
@@ -4,7 +4,7 @@ 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
6
  export declare const baseConfig: ({ ssr, appDir, publicDir, command, mode, framework, pwa }: {
7
- ssr?: "server" | "client" | "ssg" | undefined;
7
+ ssr?: "server" | "client" | "ssg" | "fastify" | undefined;
8
8
  appDir?: URL | undefined;
9
9
  publicDir?: URL | undefined;
10
10
  command?: "build" | "dev" | "test" | undefined;
@@ -1,6 +1,6 @@
1
1
  import type { Plugin } from 'vite';
2
2
  export declare type VitrifyPlugin = ({ ssr, mode, command }: {
3
- ssr?: 'server' | 'client' | 'ssg' | false;
3
+ ssr?: 'server' | 'client' | 'ssg' | 'fastify' | false;
4
4
  pwa?: boolean;
5
5
  mode?: 'production' | 'development';
6
6
  command?: 'build' | 'dev' | 'test';
@@ -1,4 +1,3 @@
1
- import type { FastifyInstance } from 'fastify';
2
1
  import type { UserConfig } from 'vite';
3
2
  import type { QuasarConf } from './plugins/quasar.js';
4
3
  import type { ComponentInternalInstance } from '@vue/runtime-core';
@@ -7,32 +6,43 @@ export declare type BootFunction = ({ app, ssrContext, staticImports }: {
7
6
  ssrContext: Record<string, unknown>;
8
7
  staticImports: Record<string, any>;
9
8
  }) => Promise<void> | void;
9
+ export declare type OnBootHook = ({ app, ssrContext, staticImports }: {
10
+ app: any;
11
+ ssrContext: Record<string, unknown>;
12
+ staticImports?: Record<string, any>;
13
+ }) => Promise<void> | void;
10
14
  export declare type OnMountedHook = (instance: ComponentInternalInstance) => Promise<void> | void;
11
15
  export declare type StaticImports = Record<string, string[]>;
12
16
  export declare type SsrFunction = (html: string, ssrContext: Record<string, any>) => string;
17
+ export declare type OnRenderedHook = (html: string, ssrContext: Record<string, any>) => string;
18
+ export declare type OnSetupFile = URL;
13
19
  export interface VitrifyConfig extends UserConfig {
14
20
  vitrify?: {
15
21
  /**
16
22
  * Global CSS imports
17
23
  */
18
24
  globalCss?: string[];
19
- /**
20
- * Functions which run after initializing the app
21
- */
22
- bootFunctions?: BootFunction[];
23
- /**
24
- * Functions which run on the server after rendering the app
25
- */
26
- ssrFunctions?: SsrFunction[];
27
25
  /**
28
26
  * Static imports in the app: packageName: [imports]
29
27
  */
30
28
  staticImports?: StaticImports;
31
29
  hooks?: {
30
+ /**
31
+ * setup() is called directly after instantiating fastify. Use it to register your own plugins, routes etc.
32
+ */
33
+ onSetup?: OnSetupFile[];
32
34
  /**
33
35
  * Functions which run in the onMounted hook of the app
34
36
  */
35
- onMounted: OnMountedHook[];
37
+ onMounted?: OnMountedHook[];
38
+ /**
39
+ * Functions which run after initializing the app
40
+ */
41
+ onBoot?: OnBootHook[];
42
+ /**
43
+ * Functions which run after rendering the app (SSR)
44
+ */
45
+ onRendered?: OnRenderedHook[];
36
46
  };
37
47
  /**
38
48
  * Global SASS variables
@@ -41,12 +51,6 @@ export interface VitrifyConfig extends UserConfig {
41
51
  variables?: Record<string, string>;
42
52
  additionalData?: string[];
43
53
  };
44
- fastify?: {
45
- /**
46
- * setup() is called directly after instantiating fastify. Use it to register your own plugins, routes etc.
47
- */
48
- setup: (fastify: FastifyInstance) => any;
49
- };
50
54
  /**
51
55
  * Product name of the application. Will be used for the HTML title tag
52
56
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitrify",
3
- "version": "0.2.4",
3
+ "version": "0.4.0",
4
4
  "license": "MIT",
5
5
  "author": "Stefan van Herwijnen",
6
6
  "description": "Pre-configured Vite CLI for your framework",
@@ -49,53 +49,53 @@
49
49
  "homepage": "https://github.com/simsustech/vitrify/tree/main/#readme",
50
50
  "scripts": {
51
51
  "build": "tsc",
52
- "test": "echo \"Error: no test specified\" && exit 0"
52
+ "test": "vitest test/"
53
53
  },
54
54
  "dependencies": {
55
- "@quasar/extras": "^1.13.5",
56
- "@vitejs/plugin-vue": "^2.3.1",
57
- "@vue/compiler-sfc": "^3.2.33",
58
- "@vue/server-renderer": "^3.2.33",
59
- "builtin-modules": "^3.2.0",
55
+ "@fastify/middie": "^8.0.0",
56
+ "@fastify/static": "^6.4.0",
57
+ "@quasar/extras": "^1.14.0",
58
+ "@vitejs/plugin-vue": "^3.0.0-alpha.1",
59
+ "builtin-modules": "^3.3.0",
60
60
  "cac": "^6.7.12",
61
61
  "chalk": "^5.0.1",
62
62
  "cross-env": "^7.0.3",
63
- "fastify": "^3.28.0",
64
- "fastify-static": "^4.6.1",
65
- "glob": "^8.0.1",
66
- "happy-dom": "^2.55.0",
67
- "import-meta-resolve": "^1.1.1",
63
+ "esbuild": "^0.14.43",
64
+ "fastify": "^4.0.0",
65
+ "glob": "^8.0.3",
66
+ "happy-dom": "^5.2.0",
68
67
  "local-pkg": "^0.4.1",
69
- "magic-string": "^0.26.1",
68
+ "magic-string": "^0.26.2",
70
69
  "merge-deep": "^3.0.3",
71
- "middie": "^6.0.0",
72
70
  "readline": "^1.3.0",
73
- "sass": "1.50.0",
74
- "unplugin-vue-components": "^0.19.3",
75
- "vite": "^2.9.5",
76
- "vitest": "^0.9.3"
71
+ "sass": "1.52.3",
72
+ "ts-node": "^10.8.1",
73
+ "unplugin-vue-components": "^0.19.6",
74
+ "vite": "^3.0.0-alpha.9",
75
+ "vitest": "^0.14.1"
77
76
  },
78
77
  "devDependencies": {
78
+ "@types/connect": "^3.4.35",
79
79
  "@types/glob": "^7.2.0",
80
80
  "@types/merge-deep": "^3.0.0",
81
- "@types/node": "^17.0.24",
81
+ "@types/node": "^17.0.41",
82
82
  "@types/ws": "^8.5.3",
83
- "@vue/runtime-core": "^3.2.33",
84
- "quasar": "^2.6.6",
85
- "rollup": "^2.70.1",
86
- "typescript": "^4.6.3",
87
- "vite": "^2.9.5",
88
- "vue": "^3.2.33",
89
- "vue-router": "^4.0.14"
83
+ "@vue/runtime-core": "^3.2.37",
84
+ "import-meta-resolve": "^2.0.2",
85
+ "quasar": "^2.7.1",
86
+ "rollup": "^2.75.6",
87
+ "typescript": "^4.7.3",
88
+ "vite": "^3.0.0-alpha.9",
89
+ "vue": "^3.2.37",
90
+ "vue-router": "^4.0.15"
90
91
  },
91
92
  "peerDependencies": {
92
- "fastify": "^3.28.0",
93
+ "@fastify/static": "^6.4.0",
94
+ "fastify": "^4.0.0",
93
95
  "fastify-plugin": "^3.0.1",
94
- "fastify-sensible": "^3.1.2",
95
- "fastify-static": "^4.6.1",
96
- "quasar": "^2.6.6",
97
- "vue": "^3.2.33",
98
- "vue-router": "^4.0.14"
96
+ "quasar": "^2.7.1",
97
+ "vue": "^3.2.37",
98
+ "vue-router": "^4.0.15"
99
99
  },
100
100
  "publishConfig": {
101
101
  "access": "public",
@@ -14,11 +14,10 @@ export const getCliDir = () => getPkgJsonDir(new URL('./', import.meta.url))
14
14
  export const getCliViteDir = (cliDir: URL) => new URL('src/vite/', cliDir)
15
15
  export const getSrcDir = (appDir: URL) => new URL('src/', appDir)
16
16
  export const getCwd = () => new URL(`file://${process.cwd()}/`)
17
- // export const quasarDir = getPkgJsonDir(new URL('./', await resolve('quasar', appDir.href)))
18
17
 
19
18
  export const parsePath = (path: string, basePath: URL) => {
20
19
  if (path) {
21
- if (path.slice(-1) !== '/') path += '/'
20
+ if (!path.includes('.') && path.slice(-1) !== '/') path += '/'
22
21
  if (path.startsWith('.')) {
23
22
  return new URL(path, basePath)
24
23
  } else if (path) {
@@ -1,58 +1,11 @@
1
1
  #!/usr/bin/node --experimental-specifier-resolution=node
2
2
  import { baseConfig } from '../index.js'
3
- // import { promises as fs } from 'fs'
4
- // import { routesToPaths } from '../helpers/routes.js'
5
3
  import { build as viteBuild } from 'vite'
6
- // import { SsrFunction } from '../vitrify-config.js'
7
-
8
- // export const prerender = async ({
9
- // outDir,
10
- // templatePath,
11
- // manifestPath,
12
- // entryServerPath,
13
- // injectSsrContext
14
- // }: {
15
- // outDir: string
16
- // templatePath: string
17
- // manifestPath: string
18
- // entryServerPath: string
19
- // injectSsrContext: SsrFunction
20
- // }) => {
21
- // let template
22
- // let manifest
23
- // const promises = []
24
- // template = (await fs.readFile(templatePath)).toString()
25
- // manifest = await fs.readFile(manifestPath)
26
- // let { render, getRoutes } = await import(entryServerPath)
27
- // const routes = await getRoutes()
28
- // const paths = routesToPaths(routes).filter(
29
- // (i) => !i.includes(':') && !i.includes('*')
30
- // )
31
- // for (let url of paths) {
32
- // const filename =
33
- // (url.endsWith('/') ? 'index' : url.replace(/^\//g, '')) + '.html'
34
- // console.log(`Generating ${filename}`)
35
- // const ssrContext = {
36
- // req: { headers: {}, url },
37
- // res: {}
38
- // }
39
- // const [appHtml, preloadLinks] = await render(url, manifest, ssrContext)
40
-
41
- // let html = template
42
- // .replace(`<!--preload-links-->`, preloadLinks)
43
- // .replace(`<!--app-html-->`, appHtml)
44
-
45
- // html = injectSsrContext(html, ssrContext)
46
-
47
- // promises.push(fs.writeFile(outDir + filename, html, 'utf-8'))
48
- // }
49
- // return Promise.all(promises)
50
- // }
51
4
 
52
5
  export async function build(opts: {
53
- ssr?: 'client' | 'server' | 'ssg'
6
+ ssr?: 'client' | 'server' | 'ssg' | 'fastify'
54
7
  base?: string
55
- outDir?: string
8
+ outDir: string
56
9
  appDir?: URL
57
10
  publicDir?: URL
58
11
  }) {