vitrify 0.9.2 → 0.10.1

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.
@@ -1,7 +1,9 @@
1
1
  import fastify from 'fastify';
2
2
  export const createApp = ({ onSetup, appDir, baseUrl, fastifyPlugin, onRendered, vitrifyDir, mode }) => {
3
3
  const app = fastify({
4
- logger: true
4
+ logger: {
5
+ level: process.env.DEBUG ? 'debug' : process.env.PINO_LOG_LEVEL || 'info'
6
+ }
5
7
  });
6
8
  app.register(fastifyPlugin, {
7
9
  baseUrl,
package/dist/index.js CHANGED
@@ -141,6 +141,8 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
141
141
  }
142
142
  catch (e) {
143
143
  console.log('No vitrify.config.(ts|js) file found, using defaults');
144
+ if (process.env.DEBUG)
145
+ console.error(e);
144
146
  vitrifyConfig = {};
145
147
  }
146
148
  const localPackages = ['vue', 'vue-router', '@vue/server-renderer'];
@@ -338,6 +340,7 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
338
340
  }
339
341
  }
340
342
  });
343
+ // @ts-ignore
341
344
  if (debug)
342
345
  plugins.push(visualizer());
343
346
  }
@@ -49,5 +49,5 @@ export declare function createServer({ port, logLevel, ssr, framework, host, app
49
49
  worker: import("vite").ResolveWorkerOptions;
50
50
  appType: import("vite").AppType;
51
51
  experimental: import("vite").ExperimentalOptions;
52
- }>;
52
+ } & import("vite").PluginHookUtils>;
53
53
  }>;
@@ -3,7 +3,9 @@ import type { ViteDevServer } from 'vite';
3
3
  import type { OnRenderedHook } from 'src/node/vitrify-config.js';
4
4
  export interface FastifySsrOptions {
5
5
  baseUrl?: string;
6
- provide?: (req: FastifyRequest, res: FastifyReply) => Promise<Record<string, unknown>>;
6
+ provide?: (req: FastifyRequest, res: FastifyReply) => Promise<Record<string, unknown | {
7
+ value: unknown;
8
+ }>>;
7
9
  vitrifyDir?: URL;
8
10
  vite?: ViteDevServer;
9
11
  onRendered?: OnRenderedHook[];
@@ -11,4 +11,4 @@ export declare const createApp: ({ onSetup, appDir, baseUrl, fastifyPlugin, onRe
11
11
  onRendered: OnRenderedHook[];
12
12
  vitrifyDir?: URL | undefined;
13
13
  mode: string;
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>>;
14
+ }) => FastifyInstance<import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, any, import("fastify").FastifyTypeProviderDefault> & PromiseLike<FastifyInstance<import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, any, import("fastify").FastifyTypeProviderDefault>>;
package/package.json CHANGED
@@ -1,42 +1,34 @@
1
1
  {
2
2
  "name": "vitrify",
3
- "version": "0.9.2",
3
+ "version": "0.10.1",
4
4
  "license": "MIT",
5
5
  "author": "Stefan van Herwijnen",
6
6
  "description": "Vite as your Full Stack development tool",
7
7
  "type": "module",
8
+ "types": "./dist/index.d.ts",
8
9
  "bin": {
9
10
  "vitrify": "./dist/bin/cli.js"
10
11
  },
11
12
  "exports": {
12
- ".": "./dist/index.js",
13
- "./*": "./dist/*.js",
14
- "./build": "./dist/bin/build.js",
15
- "./dev": "./dist/bin/dev.js",
16
- "./prerender": "./dist/prerender.js",
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.js"
16
+ },
17
+ "./build": {
18
+ "types": "./dist/types/bin/build.d.ts",
19
+ "import": "./dist/bin/build.js"
20
+ },
21
+ "./dev": {
22
+ "types": "./dist/types/bin/dev.d.ts",
23
+ "import": "./dist/bin/dev.js"
24
+ },
25
+ "./prerender": {
26
+ "types": "./dist/types/bin/prerender.d.ts",
27
+ "import": "./dist/bin/prerender.js"
28
+ },
17
29
  "./helpers/*": "./dist/helpers/*.js",
18
- "./vite/*": "./src/vite/*"
19
- },
20
- "typesVersions": {
21
- "*": {
22
- "*": [
23
- "./dist/types/index.d.ts"
24
- ],
25
- "helpers/*": [
26
- "./dist/types/helpers/*.d.ts"
27
- ],
28
- "build": [
29
- "./dist/types/bin/build.d.ts"
30
- ],
31
- "dev": [
32
- "./dist/types/bin/dev.d.ts"
33
- ],
34
- "prerender": [
35
- "./dist/types/prerender.d.ts"
36
- ],
37
- "help": [
38
- "./dist/types/bin/help.d.ts"
39
- ]
30
+ "./client": {
31
+ "types": "./client.d.ts"
40
32
  }
41
33
  },
42
34
  "engines": {
@@ -58,48 +50,48 @@
58
50
  "dependencies": {
59
51
  "@fastify/middie": "^8.0.0",
60
52
  "@fastify/static": "^6.5.0",
61
- "@quasar/extras": "^1.15.1",
62
- "@vitejs/plugin-vue": "^3.0.1",
63
- "@vitrify/plugin-env": "^0.1.0",
53
+ "@quasar/extras": "^1.15.2",
54
+ "@vitejs/plugin-vue": "^3.1.0",
55
+ "@vitrify/plugin-env": "^0.1.1",
64
56
  "builtin-modules": "^3.3.0",
65
- "cac": "^6.7.12",
57
+ "cac": "^6.7.14",
66
58
  "chalk": "^5.0.1",
67
59
  "critters": "^0.0.16",
68
60
  "cross-env": "^7.0.3",
69
- "esbuild": "^0.14.53",
70
- "fastify": "^4.3.0",
61
+ "esbuild": "^0.15.7",
62
+ "fastify": "^4.5.3",
71
63
  "glob": "^8.0.3",
72
64
  "happy-dom": "^6.0.4",
73
65
  "is-port-reachable": "^4.0.0",
74
- "magic-string": "^0.26.2",
66
+ "magic-string": "^0.26.3",
75
67
  "merge-deep": "^3.0.3",
76
68
  "readline": "^1.3.0",
77
- "rollup-plugin-visualizer": "^5.7.1",
78
- "sass": "1.54.2",
69
+ "rollup-plugin-visualizer": "^5.8.1",
70
+ "sass": "1.54.8",
79
71
  "ts-node": "^10.9.1",
80
- "unplugin-vue-components": "^0.22.0",
81
- "vite": "^3.0.4",
82
- "vitest": "^0.20.3"
72
+ "unplugin-vue-components": "^0.22.4",
73
+ "vite": "^3.1.0",
74
+ "vitest": "^0.23.1"
83
75
  },
84
76
  "devDependencies": {
85
77
  "@types/connect": "^3.4.35",
86
- "@types/glob": "^7.2.0",
78
+ "@types/glob": "^8.0.0",
87
79
  "@types/merge-deep": "^3.0.0",
88
- "@types/node": "^18.6.3",
80
+ "@types/node": "^18.7.15",
89
81
  "@types/ws": "^8.5.3",
90
- "@vue/runtime-core": "^3.2.37",
82
+ "@vue/runtime-core": "^3.2.38",
91
83
  "quasar": "^2.7.7",
92
- "rollup": "^2.77.2",
93
- "typescript": "^4.7.4",
94
- "vue": "^3.2.37",
95
- "vue-router": "^4.1.3"
84
+ "rollup": "^2.79.0",
85
+ "typescript": "^4.8.2",
86
+ "vue": "^3.2.38",
87
+ "vue-router": "^4.1.5"
96
88
  },
97
89
  "peerDependencies": {
98
90
  "@fastify/static": "^6.5.0",
99
- "fastify": "^4.3.0",
91
+ "fastify": "^4.5.3",
100
92
  "quasar": "^2.7.7",
101
- "vue": "^3.2.37",
102
- "vue-router": "^4.1.3"
93
+ "vue": "^3.2.38",
94
+ "vue-router": "^4.1.5"
103
95
  },
104
96
  "publishConfig": {
105
97
  "access": "public",
@@ -8,6 +8,7 @@ export async function test(opts: { appDir: URL }) {
8
8
  })
9
9
 
10
10
  await startVitest(
11
+ 'test',
11
12
  [],
12
13
  {
13
14
  root: opts.appDir.pathname,
@@ -13,7 +13,7 @@ export interface FastifySsrOptions {
13
13
  provide?: (
14
14
  req: FastifyRequest,
15
15
  res: FastifyReply
16
- ) => Promise<Record<string, unknown>>
16
+ ) => Promise<Record<string, unknown | { value: unknown }>>
17
17
  vitrifyDir?: URL
18
18
  vite?: ViteDevServer
19
19
  // frameworkDir?: URL
@@ -24,7 +24,9 @@ export const createApp = ({
24
24
  mode: string
25
25
  }) => {
26
26
  const app = fastify({
27
- logger: true
27
+ logger: {
28
+ level: process.env.DEBUG ? 'debug' : process.env.PINO_LOG_LEVEL || 'info'
29
+ }
28
30
  })
29
31
 
30
32
  app.register(fastifyPlugin, {
package/src/node/index.ts CHANGED
@@ -205,6 +205,7 @@ export const baseConfig = async ({
205
205
  vitrifyConfig = await vitrifyConfig({ mode, command })
206
206
  } catch (e) {
207
207
  console.log('No vitrify.config.(ts|js) file found, using defaults')
208
+ if (process.env.DEBUG) console.error(e)
208
209
  vitrifyConfig = {}
209
210
  }
210
211
 
@@ -409,6 +410,7 @@ export const baseConfig = async ({
409
410
  }
410
411
  })
411
412
 
413
+ // @ts-ignore
412
414
  if (debug) plugins.push(visualizer())
413
415
  }
414
416
 
@@ -2,7 +2,7 @@ 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
4
  import { onSetup } from 'virtual:vitrify-hooks'
5
- import { fastifyCsrPlugin } from './fastify-csr-plugin.js'
5
+ import { fastifyCsrPlugin } from './fastify-csr-plugin'
6
6
  import type { ViteDevServer } from 'vite'
7
7
 
8
8
  // const appDir = getPkgJsonDir(import.meta.url)
@@ -1,3 +1,3 @@
1
- import { fastifyCsrPlugin } from '../../../node/frameworks/vue/fastify-csr-plugin.js'
1
+ import { fastifyCsrPlugin } from '../../../node/frameworks/vue/fastify-csr-plugin'
2
2
 
3
3
  export { fastifyCsrPlugin }
@@ -1,4 +1,4 @@
1
- import { setupApp } from './app.js'
1
+ import { setupApp } from './app'
2
2
 
3
3
  const app = await setupApp()
4
4
 
@@ -1,17 +1,18 @@
1
- // import 'vitrify.css'
2
- import 'vitrify.sass'
3
- import App from 'src/App.vue'
4
1
  import createRouter from 'src/router'
5
2
  import {
6
3
  createSSRApp,
7
4
  createApp as createVueApp,
8
5
  h,
9
6
  onMounted as onMountedVue,
10
- getCurrentInstance
7
+ getCurrentInstance,
8
+ ref
11
9
  } from 'vue'
12
10
  import { onBoot, onMounted } from 'virtual:vitrify-hooks'
13
11
  import routes from 'src/router/routes'
14
12
  import * as staticImports from 'virtual:static-imports'
13
+ import 'vitrify.sass'
14
+ import 'vitrify.css'
15
+ import App from 'src/App.vue'
15
16
 
16
17
  interface ssrContext {
17
18
  ssr: boolean
@@ -19,6 +20,10 @@ interface ssrContext {
19
20
  [key: string]: unknown
20
21
  }
21
22
 
23
+ function capitalizeFirstLetter(string) {
24
+ return string.charAt(0).toUpperCase() + string.slice(1)
25
+ }
26
+
22
27
  export async function createApp(
23
28
  ssr?: 'client' | 'server',
24
29
  ssrContext?: ssrContext
@@ -56,7 +61,7 @@ export async function createApp(
56
61
  })
57
62
 
58
63
  let initialState: Record<string, any>
59
- let provide: Record<string, unknown> = {}
64
+ let provide: Record<string, any> = {}
60
65
  if (import.meta.env.SSR) {
61
66
  if (ssrContext?.provide) {
62
67
  provide = ssrContext?.provide
@@ -70,7 +75,16 @@ export async function createApp(
70
75
  }
71
76
  }
72
77
  for (let key in provide) {
73
- app.provide(key, provide[key])
78
+ if (provide[key].value) {
79
+ const refValue = ref(provide[key].value)
80
+ app.provide(key, refValue)
81
+ app.provide(
82
+ `update${capitalizeFirstLetter(key)}`,
83
+ (val: any) => (refValue.value = val)
84
+ )
85
+ } else {
86
+ app.provide(key, provide[key])
87
+ }
74
88
  }
75
89
 
76
90
  for (let fn of onBoot) {
@@ -1,4 +1,4 @@
1
- import { createApp } from '../main.js'
1
+ import { createApp } from '../main'
2
2
 
3
3
  // const { app, router } = createApp()
4
4
  createApp('client').then(({ app, router }) => {
@@ -1,4 +1,4 @@
1
- import { createApp } from '../main.js'
1
+ import { createApp } from '../main'
2
2
  // import { renderToString } from 'vue/server-renderer'
3
3
 
4
4
  // import { onRendered } from 'virtual:vitrify-hooks'
@@ -1,4 +1,4 @@
1
- import { setupApp } from './app.js'
1
+ import { setupApp } from './app'
2
2
 
3
3
  const app = await setupApp()
4
4