Skip to content

Commit b495a62

Browse files
committed
CR
1 parent 9692926 commit b495a62

File tree

2 files changed

+32
-28
lines changed

2 files changed

+32
-28
lines changed

packages/vite/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"homepage": "https://vitejs.dev",
7272
"funding": "https://github.com/vitejs/vite?sponsor=1",
7373
"scripts": {
74-
"dev": "rimraf dist && tsx scripts/dev.ts",
74+
"dev": "tsx scripts/dev.ts",
7575
"build": "rimraf dist && run-s build-bundle build-types",
7676
"build-bundle": "rollup --config rollup.config.ts --configPlugin esbuild",
7777
"build-types": "run-s build-types-temp build-types-roll build-types-check",

packages/vite/scripts/dev.ts

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import { type BuildOptions, context } from 'esbuild'
33
import packageJSON from '../package.json'
44

55
rmSync('dist', { force: true, recursive: true })
6-
mkdirSync('dist')
7-
mkdirSync('dist/node')
6+
mkdirSync('dist/node', { recursive: true })
87
writeFileSync('dist/node/index.d.ts', "export * from '../../src/node/index.ts'")
98
writeFileSync(
109
'dist/node/runtime.d.ts',
@@ -26,7 +25,7 @@ const serverOptions: BuildOptions = {
2625
const clientOptions: BuildOptions = {
2726
bundle: true,
2827
platform: 'browser',
29-
target: 'safari14',
28+
target: 'es2019',
3029
format: 'esm',
3130
sourcemap: true,
3231
}
@@ -36,37 +35,20 @@ const watch = async (options: BuildOptions) => {
3635
await ctx.watch()
3736
}
3837

39-
void watch({
40-
entryPoints: ['src/client/client.ts'],
41-
outfile: 'dist/client/client.mjs',
42-
external: ['@vite/env'],
43-
...clientOptions,
44-
})
38+
// envConfig
4539
void watch({
4640
entryPoints: ['src/client/env.ts'],
4741
outfile: 'dist/client/env.mjs',
4842
...clientOptions,
4943
})
44+
// clientConfig
5045
void watch({
51-
...serverOptions,
52-
entryPoints: ['./src/node/publicUtils.ts'],
53-
outfile: 'dist/node-cjs/publicUtils.cjs',
54-
format: 'cjs',
55-
banner: {
56-
js: `
57-
const { pathToFileURL } = require("node:url")
58-
const __url = pathToFileURL(__filename)`.trimStart(),
59-
},
60-
define: {
61-
'import.meta.url': '__url',
62-
},
63-
})
64-
void watch({
65-
...serverOptions,
66-
entryPoints: ['./src/runtime/index.ts'],
67-
outfile: 'dist/node/runtime.js',
68-
format: 'esm',
46+
entryPoints: ['src/client/client.ts'],
47+
outfile: 'dist/client/client.mjs',
48+
external: ['@vite/env'],
49+
...clientOptions,
6950
})
51+
// nodeConfig
7052
void watch({
7153
...serverOptions,
7254
entryPoints: {
@@ -106,3 +88,25 @@ void watch({
10688
},
10789
],
10890
})
91+
// runtimeConfig
92+
void watch({
93+
...serverOptions,
94+
entryPoints: ['./src/runtime/index.ts'],
95+
outfile: 'dist/node/runtime.js',
96+
format: 'esm',
97+
})
98+
// cjsConfig
99+
void watch({
100+
...serverOptions,
101+
entryPoints: ['./src/node/publicUtils.ts'],
102+
outfile: 'dist/node-cjs/publicUtils.cjs',
103+
format: 'cjs',
104+
banner: {
105+
js: `
106+
const { pathToFileURL } = require("node:url")
107+
const __url = pathToFileURL(__filename)`.trimStart(),
108+
},
109+
define: {
110+
'import.meta.url': '__url',
111+
},
112+
})

0 commit comments

Comments
 (0)