vitrify 0.25.8 → 0.26.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.
package/dist/bin/cli.js CHANGED
@@ -3,8 +3,8 @@ import cac from 'cac';
3
3
  import { fileURLToPath } from 'url';
4
4
  import { getAppDir, parsePath } from '../app-urls.js';
5
5
  import { printHttpServerUrls, exitLogs } from '../helpers/logger.js';
6
- import { build as esbuild } from 'esbuild';
7
- import { readdir } from 'fs/promises';
6
+ import { minify } from 'rolldown/utils';
7
+ import { readdir, readFile, writeFile } from 'fs/promises';
8
8
  import { loadSSRAssets } from '../frameworks/vue/fastify-ssr-plugin.js';
9
9
  const cli = cac('vitrify');
10
10
  cli
@@ -172,21 +172,25 @@ cli.command('run <file>').action(async (file, options) => {
172
172
  await run(fileURLToPath(filePath));
173
173
  });
174
174
  cli.command('minify <dir>').action(async (dir, options) => {
175
- const files = await readdir(fileURLToPath(new URL(dir, `file://${process.cwd()}/`)));
175
+ const baseUrl = new URL(dir, `file://${process.cwd()}/`);
176
+ const files = await readdir(fileURLToPath(baseUrl));
176
177
  let counter = 0;
177
178
  for (const file of files) {
178
179
  if (file.endsWith('.mjs')) {
179
- await esbuild({
180
- absWorkingDir: fileURLToPath(new URL(dir, `file://${process.cwd()}/`)),
181
- entryPoints: [file],
182
- minify: true,
183
- minifyIdentifiers: true,
184
- minifySyntax: true,
185
- minifyWhitespace: true,
186
- outfile: file,
187
- allowOverwrite: true
180
+ const path = fileURLToPath(new URL(`${dir}/${file}`, `file://${process.cwd()}/`));
181
+ const content = await readFile(path, {
182
+ encoding: 'utf-8'
188
183
  });
189
- counter++;
184
+ const output = await minify(path, content, {
185
+ compress: true,
186
+ module: true,
187
+ mangle: true,
188
+ codegen: true
189
+ });
190
+ if (!output.errors.length) {
191
+ await writeFile(path, output.code);
192
+ counter++;
193
+ }
190
194
  }
191
195
  }
192
196
  console.log(`Minified ${counter} files`);
package/dist/index.js CHANGED
@@ -1,10 +1,8 @@
1
1
  import vuePlugin from '@vitejs/plugin-vue';
2
2
  import { findDepPkgJsonPath } from 'vitefu';
3
3
  import { mergeConfig } from 'vite';
4
- import { build } from 'esbuild';
4
+ import { transform } from 'rolldown/utils';
5
5
  import fs from 'fs';
6
- import path from 'path';
7
- import { pathToFileURL } from 'url';
8
6
  import { readFileSync } from 'fs';
9
7
  import { builtinModules } from 'node:module';
10
8
  import { visualizer } from 'rollup-plugin-visualizer';
@@ -84,54 +82,6 @@ export const VIRTUAL_MODULES = [
84
82
  'vitrify.sass',
85
83
  'vitrify.css'
86
84
  ];
87
- async function bundleConfigFile(fileName, isESM = false) {
88
- const result = await build({
89
- absWorkingDir: process.cwd(),
90
- entryPoints: [fileName],
91
- outfile: 'out.js',
92
- write: false,
93
- platform: 'node',
94
- bundle: true,
95
- format: 'esm',
96
- sourcemap: 'inline',
97
- metafile: true,
98
- plugins: [
99
- {
100
- name: 'externalize-deps',
101
- setup(build) {
102
- build.onResolve({ filter: /.*/ }, (args) => {
103
- const id = args.path;
104
- if (id[0] !== '.' && !path.isAbsolute(id)) {
105
- return {
106
- external: true
107
- };
108
- }
109
- });
110
- }
111
- },
112
- {
113
- name: 'replace-import-meta',
114
- setup(build) {
115
- build.onLoad({ filter: /\.[jt]s$/ }, async (args) => {
116
- const contents = await fs.promises.readFile(args.path, 'utf8');
117
- return {
118
- loader: args.path.endsWith('.ts') ? 'ts' : 'js',
119
- contents: contents
120
- .replace(/\bimport\.meta\.url\b/g, JSON.stringify(pathToFileURL(args.path).href))
121
- .replace(/\b__dirname\b/g, JSON.stringify(path.dirname(args.path)))
122
- .replace(/\b__filename\b/g, JSON.stringify(args.path))
123
- };
124
- });
125
- }
126
- }
127
- ]
128
- });
129
- const { text } = result.outputFiles[0];
130
- return {
131
- code: text,
132
- dependencies: result.metafile ? Object.keys(result.metafile.inputs) : []
133
- };
134
- }
135
85
  export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command = 'build', mode = 'production', framework = 'vue', debug = false, productName }) => {
136
86
  const { getAppDir, getCliDir, getCliViteDir, getSrcDir, getCwd } = await import('./app-urls.js');
137
87
  if (!appDir) {
@@ -150,8 +100,11 @@ export const baseConfig = async ({ ssr, appDir, publicDir, base = '/', command =
150
100
  try {
151
101
  if (fs.existsSync(fileURLToPath(new URL('vitrify.config.ts', appDir)))) {
152
102
  const configPath = fileURLToPath(new URL('vitrify.config.ts', appDir));
153
- const bundledConfig = await bundleConfigFile(fileURLToPath(new URL('vitrify.config.ts', appDir)));
154
- fs.writeFileSync(configPath + '.js', bundledConfig.code);
103
+ const content = readFileSync(configPath, {
104
+ encoding: 'utf-8'
105
+ });
106
+ const output = await transform(configPath, content);
107
+ fs.writeFileSync(configPath + '.js', output.code);
155
108
  rawVitrifyConfig = (await import('file://' + configPath + '.js')).default;
156
109
  fs.unlinkSync(configPath + '.js');
157
110
  }
@@ -7,4 +7,4 @@ export declare function build(opts: {
7
7
  publicDir?: URL;
8
8
  debug?: boolean;
9
9
  productName?: string;
10
- }): Promise<import("rollup").RollupOutput | import("rollup").RollupOutput[] | import("rollup").RollupWatcher>;
10
+ }): Promise<import("rolldown").RolldownOutput | import("rolldown").RolldownOutput[] | import("rolldown").RolldownWatcher>;
@@ -26,7 +26,7 @@ export declare function createServer({ port, logLevel, ssr, framework, host, app
26
26
  publicDir?: URL;
27
27
  vite?: ViteDevServer;
28
28
  }): Promise<{
29
- app: FastifyInstance<import("fastify").RawServerDefault, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, import("fastify").FastifyBaseLogger, import("fastify").FastifyTypeProviderDefault> | undefined;
29
+ app: FastifyInstance<import("fastify").RawServerDefault, import("node:http").IncomingMessage, import("node:http").ServerResponse<import("node:http").IncomingMessage>, import("fastify").FastifyBaseLogger, import("fastify").FastifyTypeProviderDefault> | undefined;
30
30
  server: Server;
31
31
  config: ResolvedConfig;
32
32
  vite: ViteDevServer;
@@ -10,6 +10,6 @@ export declare const createApp: ({ onSetup, appDir, baseUrl, fastifyPlugin, onAp
10
10
  onTemplateRendered?: OnTemplateRenderedHook[];
11
11
  vitrifyDir?: URL;
12
12
  mode: string;
13
- }) => import("fastify").FastifyInstance<import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, import("fastify").FastifyBaseLogger, import("fastify").FastifyTypeProviderDefault> & PromiseLike<import("fastify").FastifyInstance<import("http").Server<typeof import("http").IncomingMessage, typeof import("http").ServerResponse>, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, import("fastify").FastifyBaseLogger, import("fastify").FastifyTypeProviderDefault>> & {
13
+ }) => import("fastify").FastifyInstance<import("node:http").Server<typeof import("node:http").IncomingMessage, typeof import("node:http").ServerResponse>, import("node:http").IncomingMessage, import("node:http").ServerResponse<import("node:http").IncomingMessage>, import("fastify").FastifyBaseLogger, import("fastify").FastifyTypeProviderDefault> & PromiseLike<import("fastify").FastifyInstance<import("node:http").Server<typeof import("node:http").IncomingMessage, typeof import("node:http").ServerResponse>, import("node:http").IncomingMessage, import("node:http").ServerResponse<import("node:http").IncomingMessage>, import("fastify").FastifyBaseLogger, import("fastify").FastifyTypeProviderDefault>> & {
14
14
  __linterBrands: "SafePromiseLike";
15
15
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitrify",
3
- "version": "0.25.8",
3
+ "version": "0.26.0",
4
4
  "license": "MIT",
5
5
  "author": "Stefan van Herwijnen",
6
6
  "description": "Vite as your Full Stack development tool",
@@ -52,72 +52,72 @@
52
52
  },
53
53
  "homepage": "https://github.com/simsustech/vitrify/tree/main/#readme",
54
54
  "dependencies": {
55
- "@fastify/middie": "^9.0.3",
56
- "@fastify/one-line-logger": "^2.0.2",
57
- "@fastify/static": "^8.3.0",
58
- "@unocss/core": "^66.5.9",
59
- "@unocss/preset-uno": "^66.5.9",
60
- "@unocss/preset-web-fonts": "66.5.9",
61
- "@unocss/preset-wind": "^66.5.9",
62
- "@vitejs/plugin-vue": "^6.0.2",
63
- "ajv": "^8.17.1",
55
+ "@fastify/middie": "^9.3.1",
56
+ "@fastify/one-line-logger": "^2.1.0",
57
+ "@fastify/static": "^9.0.0",
58
+ "@unocss/core": "^66.6.7",
59
+ "@unocss/preset-uno": "^66.6.7",
60
+ "@unocss/preset-web-fonts": "66.6.7",
61
+ "@unocss/preset-wind": "^66.6.7",
62
+ "@vitejs/plugin-vue": "^6.0.5",
63
+ "ajv": "^8.18.0",
64
64
  "animated-unocss": "^0.0.6",
65
- "cac": "^6.7.14",
65
+ "cac": "^7.0.0",
66
66
  "chalk": "^5.6.2",
67
67
  "cross-env": "^10.1.0",
68
- "devalue": "^5.5.0",
69
- "esbuild": "^0.27.0",
70
- "fastify": "^5.6.2",
71
- "glob": "^13.0.0",
72
- "happy-dom": "^20.0.11",
68
+ "devalue": "^5.6.4",
69
+ "fastify": "^5.8.2",
70
+ "glob": "^13.0.6",
71
+ "happy-dom": "^20.8.4",
73
72
  "is-port-reachable": "^4.0.0",
74
73
  "magic-string": "^0.30.21",
75
74
  "merge-deep": "^3.0.3",
76
75
  "readline": "^1.3.0",
77
- "rollup-plugin-visualizer": "^6.0.5",
78
- "sass": "1.94.2",
76
+ "rolldown": "1.0.0-rc.9",
77
+ "rollup-plugin-visualizer": "^7.0.1",
78
+ "sass": "1.98.0",
79
79
  "stringify-object": "^6.0.0",
80
80
  "ts-node": "^10.9.2",
81
- "unocss": "^66.5.9",
82
- "unplugin-vue-components": "^30.0.0",
83
- "vite": "^7.2.4",
81
+ "unocss": "^66.6.7",
82
+ "unplugin-vue-components": "^31.0.0",
83
+ "vite": "^8.0.0",
84
84
  "vite-plugin-pwa": "^1.2.0",
85
- "vitefu": "^1.1.1",
86
- "vitest": "^4.0.14",
85
+ "vitefu": "^1.1.2",
86
+ "vitest": "^4.1.0",
87
87
  "workbox-window": "^7.4.0"
88
88
  },
89
89
  "devDependencies": {
90
90
  "@iconify-json/mdi": "^1.2.3",
91
- "@pinia/colada": "^0.17.9",
91
+ "@pinia/colada": "^1.0.0",
92
92
  "@quasar/extras": "^1.17.0",
93
93
  "@quasar/quasar-ui-qmarkdown": "^2.0.5",
94
94
  "@quasar/quasar-ui-qmediaplayer": "^2.0.0-beta.0",
95
95
  "@types/connect": "^3.4.38",
96
96
  "@types/glob": "^9.0.0",
97
97
  "@types/merge-deep": "^3.0.3",
98
- "@types/node": "^24.10.1",
98
+ "@types/node": "^25.5.0",
99
99
  "@types/stringify-object": "^4.0.5",
100
100
  "@types/ws": "^8.18.1",
101
- "@unocss/preset-icons": "^66.5.9",
102
- "@vue/runtime-core": "^3.5.25",
103
- "beasties": "^0.3.5",
101
+ "@unocss/preset-icons": "^66.6.7",
102
+ "@vue/runtime-core": "^3.5.30",
103
+ "beasties": "^0.4.1",
104
104
  "css": "^3.0.0",
105
105
  "css-to-tailwind-translator": "^1.2.8",
106
106
  "pinia": "^3.0.4",
107
- "quasar": "^2.18.6",
108
- "rollup": "^4.53.3",
107
+ "quasar": "^2.18.7",
108
+ "rollup": "^4.59.0",
109
109
  "typescript": "^5.9.3",
110
- "vue": "^3.5.25",
111
- "vue-router": "^4.6.3"
110
+ "vue": "^3.5.30",
111
+ "vue-router": "^5.0.3"
112
112
  },
113
113
  "peerDependencies": {
114
- "@fastify/static": "^8.3.0",
115
- "@pinia/colada": "^0.17.9",
116
- "fastify": "^5.6.2",
114
+ "@fastify/static": "^9.0.0",
115
+ "@pinia/colada": "^1.0.0",
116
+ "fastify": "^5.8.2",
117
117
  "pinia": "^3.0.4",
118
- "quasar": "^2.18.6",
119
- "vue": "^3.5.25",
120
- "vue-router": "^4.6.3"
118
+ "quasar": "^2.18.7",
119
+ "vue": "^3.5.30",
120
+ "vue-router": "^5.0.3"
121
121
  },
122
122
  "publishConfig": {
123
123
  "access": "public",
@@ -3,11 +3,11 @@ import cac from 'cac'
3
3
  import { fileURLToPath } from 'url'
4
4
  import { getAppDir, parsePath } from '../app-urls.js'
5
5
  import { printHttpServerUrls, exitLogs } from '../helpers/logger.js'
6
- import { build as esbuild } from 'esbuild'
6
+ import { minify } from 'rolldown/utils'
7
7
  import type { ResolvedConfig, ViteDevServer } from 'vite'
8
8
  import type { Server } from 'net'
9
9
  import type { FastifyInstance } from 'fastify'
10
- import { readdir } from 'fs/promises'
10
+ import { readdir, readFile, writeFile } from 'fs/promises'
11
11
  import { loadSSRAssets } from '../frameworks/vue/fastify-ssr-plugin.js'
12
12
 
13
13
  const cli = cac('vitrify')
@@ -199,23 +199,27 @@ cli.command('run <file>').action(async (file, options) => {
199
199
  })
200
200
 
201
201
  cli.command('minify <dir>').action(async (dir, options) => {
202
- const files = await readdir(
203
- fileURLToPath(new URL(dir, `file://${process.cwd()}/`))
204
- )
202
+ const baseUrl = new URL(dir, `file://${process.cwd()}/`)
203
+ const files = await readdir(fileURLToPath(baseUrl))
205
204
  let counter = 0
206
205
  for (const file of files) {
207
206
  if (file.endsWith('.mjs')) {
208
- await esbuild({
209
- absWorkingDir: fileURLToPath(new URL(dir, `file://${process.cwd()}/`)),
210
- entryPoints: [file],
211
- minify: true,
212
- minifyIdentifiers: true,
213
- minifySyntax: true,
214
- minifyWhitespace: true,
215
- outfile: file,
216
- allowOverwrite: true
207
+ const path = fileURLToPath(
208
+ new URL(`${dir}/${file}`, `file://${process.cwd()}/`)
209
+ )
210
+ const content = await readFile(path, {
211
+ encoding: 'utf-8'
212
+ })
213
+ const output = await minify(path, content, {
214
+ compress: true,
215
+ module: true,
216
+ mangle: true,
217
+ codegen: true
217
218
  })
218
- counter++
219
+ if (!output.errors.length) {
220
+ await writeFile(path, output.code)
221
+ counter++
222
+ }
219
223
  }
220
224
  }
221
225
  console.log(`Minified ${counter} files`)
package/src/node/index.ts CHANGED
@@ -7,10 +7,8 @@ import type {
7
7
  } from 'vite'
8
8
  import { findDepPkgJsonPath } from 'vitefu'
9
9
  import { mergeConfig } from 'vite'
10
- import { build } from 'esbuild'
10
+ import { transform } from 'rolldown/utils'
11
11
  import fs from 'fs'
12
- import path from 'path'
13
- import { pathToFileURL } from 'url'
14
12
  import { readFileSync } from 'fs'
15
13
  import { builtinModules } from 'node:module'
16
14
  import { visualizer } from 'rollup-plugin-visualizer'
@@ -119,64 +117,6 @@ export const VIRTUAL_MODULES = [
119
117
  'vitrify.css'
120
118
  ]
121
119
 
122
- async function bundleConfigFile(
123
- fileName: string,
124
- isESM = false
125
- ): Promise<{ code: string; dependencies: string[] }> {
126
- const result = await build({
127
- absWorkingDir: process.cwd(),
128
- entryPoints: [fileName],
129
- outfile: 'out.js',
130
- write: false,
131
- platform: 'node',
132
- bundle: true,
133
- format: 'esm',
134
- sourcemap: 'inline',
135
- metafile: true,
136
- plugins: [
137
- {
138
- name: 'externalize-deps',
139
- setup(build) {
140
- build.onResolve({ filter: /.*/ }, (args) => {
141
- const id = args.path
142
- if (id[0] !== '.' && !path.isAbsolute(id)) {
143
- return {
144
- external: true
145
- }
146
- }
147
- })
148
- }
149
- },
150
- {
151
- name: 'replace-import-meta',
152
- setup(build) {
153
- build.onLoad({ filter: /\.[jt]s$/ }, async (args) => {
154
- const contents = await fs.promises.readFile(args.path, 'utf8')
155
- return {
156
- loader: args.path.endsWith('.ts') ? 'ts' : 'js',
157
- contents: contents
158
- .replace(
159
- /\bimport\.meta\.url\b/g,
160
- JSON.stringify(pathToFileURL(args.path).href)
161
- )
162
- .replace(
163
- /\b__dirname\b/g,
164
- JSON.stringify(path.dirname(args.path))
165
- )
166
- .replace(/\b__filename\b/g, JSON.stringify(args.path))
167
- }
168
- })
169
- }
170
- }
171
- ]
172
- })
173
- const { text } = result.outputFiles[0]
174
- return {
175
- code: text,
176
- dependencies: result.metafile ? Object.keys(result.metafile.inputs) : []
177
- }
178
- }
179
-
180
120
  export const baseConfig = async ({
181
121
  ssr,
182
122
  appDir,
@@ -218,10 +158,12 @@ export const baseConfig = async ({
218
158
  try {
219
159
  if (fs.existsSync(fileURLToPath(new URL('vitrify.config.ts', appDir)))) {
220
160
  const configPath = fileURLToPath(new URL('vitrify.config.ts', appDir))
221
- const bundledConfig = await bundleConfigFile(
222
- fileURLToPath(new URL('vitrify.config.ts', appDir))
223
- )
224
- fs.writeFileSync(configPath + '.js', bundledConfig.code)
161
+
162
+ const content = readFileSync(configPath, {
163
+ encoding: 'utf-8'
164
+ })
165
+ const output = await transform(configPath, content)
166
+ fs.writeFileSync(configPath + '.js', output.code)
225
167
 
226
168
  rawVitrifyConfig = (await import('file://' + configPath + '.js')).default
227
169
  fs.unlinkSync(configPath + '.js')