vite 3.0.0-alpha.0 → 3.0.0-alpha.11
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/LICENSE.md +26 -4
- package/bin/vite.js +5 -5
- package/client.d.ts +16 -2
- package/dist/client/client.mjs +34 -20
- package/dist/client/client.mjs.map +1 -1
- package/dist/node/chunks/{dep-a9015192.js → dep-17430d09.js} +20 -20
- package/dist/node/chunks/{dep-fafc4143.js → dep-46501b7a.js} +38000 -36456
- package/dist/node/chunks/{dep-2d9eaf08.js → dep-4e458630.js} +27 -29
- package/dist/node/chunks/{dep-63fe0f22.js → dep-d6e255b8.js} +111 -52
- package/dist/node/chunks/{dep-2056ae8a.js → dep-e8ca8d40.js} +9 -3
- package/dist/node/chunks/{dep-dfbd0b0c.js → dep-fb927717.js} +41 -37
- package/dist/node/cli.js +46 -48
- package/dist/node/constants.js +99 -0
- package/dist/node/index.d.ts +108 -17
- package/dist/node/index.js +38 -60
- package/dist/node-cjs/publicUtils.cjs +4174 -0
- package/index.cjs +33 -0
- package/package.json +48 -29
- package/src/client/client.ts +34 -17
- package/src/client/tsconfig.json +1 -1
- package/types/importGlob.d.ts +1 -3
- package/dist/node/terser.js +0 -32876
package/index.cjs
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/* eslint-disable no-restricted-globals */
|
|
2
|
+
|
|
3
|
+
// type utils
|
|
4
|
+
module.exports.defineConfig = (config) => config
|
|
5
|
+
|
|
6
|
+
// proxy cjs utils (sync functions)
|
|
7
|
+
Object.assign(module.exports, require('./dist/node-cjs/publicUtils.cjs'))
|
|
8
|
+
|
|
9
|
+
// async functions, can be redirect from ESM build
|
|
10
|
+
const asyncFunctions = [
|
|
11
|
+
'build',
|
|
12
|
+
'createServer',
|
|
13
|
+
'preview',
|
|
14
|
+
'transformWithEsbuild',
|
|
15
|
+
'resolveConfig',
|
|
16
|
+
'optimizeDeps',
|
|
17
|
+
'formatPostcssSourceMap',
|
|
18
|
+
'loadConfigFromFile'
|
|
19
|
+
]
|
|
20
|
+
asyncFunctions.forEach((name) => {
|
|
21
|
+
module.exports[name] = (...args) =>
|
|
22
|
+
import('./dist/node/index.js').then((i) => i[name](...args))
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
// some sync functions are marked not supported due to their complexity and uncommon usage
|
|
26
|
+
const unsupportedCJS = ['resolvePackageEntry', 'resolvePackageData']
|
|
27
|
+
unsupportedCJS.forEach((name) => {
|
|
28
|
+
module.exports[name] = () => {
|
|
29
|
+
throw new Error(
|
|
30
|
+
`"${name}" is not supported in CJS build of Vite 3.\nPlease use ESM or dynamic imports \`const { ${name} } = await import('vite')\`.`
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
})
|
package/package.json
CHANGED
|
@@ -1,18 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.11",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"license": "MIT",
|
|
5
6
|
"author": "Evan You",
|
|
6
7
|
"description": "Native-ESM powered web dev build tool",
|
|
7
8
|
"bin": {
|
|
8
9
|
"vite": "bin/vite.js"
|
|
9
10
|
},
|
|
10
|
-
"main": "dist/node/index.js",
|
|
11
|
-
"
|
|
11
|
+
"main": "./dist/node/index.js",
|
|
12
|
+
"module": "./dist/node/index.js",
|
|
13
|
+
"types": "./dist/node/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/node/index.d.ts",
|
|
17
|
+
"import": "./dist/node/index.js",
|
|
18
|
+
"require": "./index.cjs"
|
|
19
|
+
},
|
|
20
|
+
"./client": {
|
|
21
|
+
"types": "./client.d.ts"
|
|
22
|
+
},
|
|
23
|
+
"./dist/client/*": "./dist/client/*"
|
|
24
|
+
},
|
|
12
25
|
"files": [
|
|
13
26
|
"bin",
|
|
14
27
|
"dist",
|
|
15
28
|
"client.d.ts",
|
|
29
|
+
"index.cjs",
|
|
16
30
|
"src/client",
|
|
17
31
|
"types"
|
|
18
32
|
],
|
|
@@ -29,42 +43,43 @@
|
|
|
29
43
|
},
|
|
30
44
|
"homepage": "https://github.com/vitejs/vite/tree/main/#readme",
|
|
31
45
|
"scripts": {
|
|
32
|
-
"dev": "rimraf dist &&
|
|
46
|
+
"dev": "rimraf dist && pnpm run build-bundle -w",
|
|
33
47
|
"build": "rimraf dist && run-s build-bundle build-types",
|
|
34
|
-
"build-bundle": "rollup
|
|
35
|
-
"build-types": "run-s build-temp-types patch-types roll-types",
|
|
48
|
+
"build-bundle": "rollup --config rollup.config.ts --configPlugin typescript",
|
|
49
|
+
"build-types": "run-s build-temp-types patch-types roll-types check-dist-types",
|
|
36
50
|
"build-temp-types": "tsc --emitDeclarationOnly --outDir temp/node -p src/node",
|
|
37
|
-
"patch-types": "
|
|
51
|
+
"patch-types": "esno scripts/patchTypes.ts",
|
|
38
52
|
"roll-types": "api-extractor run && rimraf temp",
|
|
53
|
+
"check-dist-types": "tsc --project tsconfig.check.json",
|
|
39
54
|
"lint": "eslint --ext .ts src/**",
|
|
40
55
|
"format": "prettier --write --parser typescript \"src/**/*.ts\"",
|
|
41
56
|
"prepublishOnly": "npm run build"
|
|
42
57
|
},
|
|
43
58
|
"//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!",
|
|
44
59
|
"dependencies": {
|
|
45
|
-
"esbuild": "^0.14.
|
|
46
|
-
"postcss": "^8.4.
|
|
60
|
+
"esbuild": "^0.14.43",
|
|
61
|
+
"postcss": "^8.4.14",
|
|
47
62
|
"resolve": "^1.22.0",
|
|
48
|
-
"rollup": "^2.
|
|
63
|
+
"rollup": "^2.75.6"
|
|
49
64
|
},
|
|
50
65
|
"optionalDependencies": {
|
|
51
66
|
"fsevents": "~2.3.2"
|
|
52
67
|
},
|
|
53
68
|
"devDependencies": {
|
|
54
69
|
"@ampproject/remapping": "^2.2.0",
|
|
55
|
-
"@babel/parser": "^7.
|
|
56
|
-
"@babel/types": "^7.
|
|
57
|
-
"@jridgewell/trace-mapping": "^0.3.
|
|
70
|
+
"@babel/parser": "^7.18.5",
|
|
71
|
+
"@babel/types": "^7.18.4",
|
|
72
|
+
"@jridgewell/trace-mapping": "^0.3.13",
|
|
58
73
|
"@rollup/plugin-alias": "^3.1.9",
|
|
59
74
|
"@rollup/plugin-commonjs": "^21.1.0",
|
|
60
75
|
"@rollup/plugin-dynamic-import-vars": "^1.4.3",
|
|
61
76
|
"@rollup/plugin-json": "^4.1.0",
|
|
62
|
-
"@rollup/plugin-node-resolve": "13.
|
|
63
|
-
"@rollup/plugin-typescript": "^8.3.
|
|
77
|
+
"@rollup/plugin-node-resolve": "13.3.0",
|
|
78
|
+
"@rollup/plugin-typescript": "^8.3.3",
|
|
64
79
|
"@rollup/pluginutils": "^4.2.1",
|
|
65
|
-
"@vue/compiler-dom": "^3.2.
|
|
80
|
+
"@vue/compiler-dom": "^3.2.37",
|
|
66
81
|
"acorn": "^8.7.1",
|
|
67
|
-
"cac": "6.7.
|
|
82
|
+
"cac": "^6.7.12",
|
|
68
83
|
"chokidar": "^3.5.3",
|
|
69
84
|
"connect": "^3.7.0",
|
|
70
85
|
"connect-history-api-fallback": "^1.6.0",
|
|
@@ -75,41 +90,42 @@
|
|
|
75
90
|
"dotenv": "^14.3.2",
|
|
76
91
|
"dotenv-expand": "^5.1.0",
|
|
77
92
|
"es-module-lexer": "^0.10.5",
|
|
78
|
-
"
|
|
93
|
+
"esno": "^0.16.3",
|
|
94
|
+
"estree-walker": "^3.0.1",
|
|
79
95
|
"etag": "^1.8.1",
|
|
80
96
|
"fast-glob": "^3.2.11",
|
|
81
97
|
"http-proxy": "^1.18.1",
|
|
82
98
|
"json5": "^2.2.1",
|
|
83
|
-
"launch-editor-middleware": "^2.
|
|
84
|
-
"magic-string": "^0.26.
|
|
99
|
+
"launch-editor-middleware": "^2.4.0",
|
|
100
|
+
"magic-string": "^0.26.2",
|
|
85
101
|
"micromatch": "^4.0.5",
|
|
86
|
-
"mrmime": "^1.0.
|
|
102
|
+
"mrmime": "^1.0.1",
|
|
87
103
|
"node-forge": "^1.3.1",
|
|
88
104
|
"okie": "^1.0.1",
|
|
89
105
|
"open": "^8.4.0",
|
|
90
|
-
"periscopic": "^
|
|
106
|
+
"periscopic": "^3.0.4",
|
|
91
107
|
"picocolors": "^1.0.0",
|
|
92
108
|
"postcss-import": "^14.1.0",
|
|
93
|
-
"postcss-load-config": "^
|
|
109
|
+
"postcss-load-config": "^4.0.1",
|
|
94
110
|
"postcss-modules": "^4.3.1",
|
|
95
111
|
"resolve.exports": "^1.1.0",
|
|
96
|
-
"rollup-plugin-license": "^2.
|
|
112
|
+
"rollup-plugin-license": "^2.8.1",
|
|
97
113
|
"sirv": "^2.0.2",
|
|
98
114
|
"source-map-js": "^1.0.2",
|
|
99
115
|
"source-map-support": "^0.5.21",
|
|
100
|
-
"strip-ansi": "^
|
|
116
|
+
"strip-ansi": "^7.0.1",
|
|
101
117
|
"strip-literal": "^0.3.0",
|
|
102
|
-
"
|
|
103
|
-
"tsconfck": "^2.0.0",
|
|
118
|
+
"tsconfck": "^2.0.1",
|
|
104
119
|
"tslib": "^2.4.0",
|
|
105
120
|
"types": "link:./types",
|
|
106
121
|
"ufo": "^0.8.4",
|
|
107
|
-
"ws": "^8.
|
|
122
|
+
"ws": "^8.8.0"
|
|
108
123
|
},
|
|
109
124
|
"peerDependencies": {
|
|
110
125
|
"less": "*",
|
|
111
126
|
"sass": "*",
|
|
112
|
-
"stylus": "*"
|
|
127
|
+
"stylus": "*",
|
|
128
|
+
"terser": "^5.4.0"
|
|
113
129
|
},
|
|
114
130
|
"peerDependenciesMeta": {
|
|
115
131
|
"sass": {
|
|
@@ -120,6 +136,9 @@
|
|
|
120
136
|
},
|
|
121
137
|
"less": {
|
|
122
138
|
"optional": true
|
|
139
|
+
},
|
|
140
|
+
"terser": {
|
|
141
|
+
"optional": true
|
|
123
142
|
}
|
|
124
143
|
}
|
|
125
144
|
}
|
package/src/client/client.ts
CHANGED
|
@@ -13,16 +13,35 @@ declare const __HMR_PORT__: string
|
|
|
13
13
|
declare const __HMR_TIMEOUT__: number
|
|
14
14
|
declare const __HMR_ENABLE_OVERLAY__: boolean
|
|
15
15
|
|
|
16
|
-
console.
|
|
16
|
+
console.debug('[vite] connecting...')
|
|
17
17
|
|
|
18
18
|
// use server configuration, then fallback to inference
|
|
19
19
|
const socketProtocol =
|
|
20
20
|
__HMR_PROTOCOL__ || (location.protocol === 'https:' ? 'wss' : 'ws')
|
|
21
21
|
const socketHost = `${__HMR_HOSTNAME__ || location.hostname}:${__HMR_PORT__}`
|
|
22
|
-
const socket = new WebSocket(`${socketProtocol}://${socketHost}`, 'vite-hmr')
|
|
23
22
|
const base = __BASE__ || '/'
|
|
24
23
|
const messageBuffer: string[] = []
|
|
25
24
|
|
|
25
|
+
let socket: WebSocket
|
|
26
|
+
try {
|
|
27
|
+
socket = new WebSocket(`${socketProtocol}://${socketHost}`, 'vite-hmr')
|
|
28
|
+
|
|
29
|
+
// Listen for messages
|
|
30
|
+
socket.addEventListener('message', async ({ data }) => {
|
|
31
|
+
handleMessage(JSON.parse(data))
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
// ping server
|
|
35
|
+
socket.addEventListener('close', async ({ wasClean }) => {
|
|
36
|
+
if (wasClean) return
|
|
37
|
+
console.log(`[vite] server connection lost. polling for restart...`)
|
|
38
|
+
await waitForSuccessfulPing()
|
|
39
|
+
location.reload()
|
|
40
|
+
})
|
|
41
|
+
} catch (error) {
|
|
42
|
+
console.error(`[vite] failed to connect to websocket (${error}). `)
|
|
43
|
+
}
|
|
44
|
+
|
|
26
45
|
function warnFailedFetch(err: Error, path: string | string[]) {
|
|
27
46
|
if (!err.message.match('fetch')) {
|
|
28
47
|
console.error(err)
|
|
@@ -40,17 +59,12 @@ function cleanUrl(pathname: string): string {
|
|
|
40
59
|
return url.pathname + url.search
|
|
41
60
|
}
|
|
42
61
|
|
|
43
|
-
// Listen for messages
|
|
44
|
-
socket.addEventListener('message', async ({ data }) => {
|
|
45
|
-
handleMessage(JSON.parse(data))
|
|
46
|
-
})
|
|
47
|
-
|
|
48
62
|
let isFirstUpdate = true
|
|
49
63
|
|
|
50
64
|
async function handleMessage(payload: HMRPayload) {
|
|
51
65
|
switch (payload.type) {
|
|
52
66
|
case 'connected':
|
|
53
|
-
console.
|
|
67
|
+
console.debug(`[vite] connected.`)
|
|
54
68
|
sendMessageBuffer()
|
|
55
69
|
// proxy(nginx, docker) hmr ws maybe caused timeout,
|
|
56
70
|
// so send ping package let ws keep alive.
|
|
@@ -87,7 +101,18 @@ async function handleMessage(payload: HMRPayload) {
|
|
|
87
101
|
const newPath = `${base}${searchUrl.slice(1)}${
|
|
88
102
|
searchUrl.includes('?') ? '&' : '?'
|
|
89
103
|
}t=${timestamp}`
|
|
90
|
-
|
|
104
|
+
|
|
105
|
+
// rather than swapping the href on the existing tag, we will
|
|
106
|
+
// create a new link tag. Once the new stylesheet has loaded we
|
|
107
|
+
// will remove the existing link tag. This removes a Flash Of
|
|
108
|
+
// Unstyled Content that can occur when swapping out the tag href
|
|
109
|
+
// directly, as the new stylesheet has not yet been loaded.
|
|
110
|
+
const newLinkTag = el.cloneNode() as HTMLLinkElement
|
|
111
|
+
newLinkTag.href = new URL(newPath, el.href).href
|
|
112
|
+
const removeOldEl = () => el.remove()
|
|
113
|
+
newLinkTag.addEventListener('load', removeOldEl)
|
|
114
|
+
newLinkTag.addEventListener('error', removeOldEl)
|
|
115
|
+
el.after(newLinkTag)
|
|
91
116
|
}
|
|
92
117
|
console.log(`[vite] css hot updated: ${searchUrl}`)
|
|
93
118
|
}
|
|
@@ -212,14 +237,6 @@ async function waitForSuccessfulPing(ms = 1000) {
|
|
|
212
237
|
}
|
|
213
238
|
}
|
|
214
239
|
|
|
215
|
-
// ping server
|
|
216
|
-
socket.addEventListener('close', async ({ wasClean }) => {
|
|
217
|
-
if (wasClean) return
|
|
218
|
-
console.log(`[vite] server connection lost. polling for restart...`)
|
|
219
|
-
await waitForSuccessfulPing()
|
|
220
|
-
location.reload()
|
|
221
|
-
})
|
|
222
|
-
|
|
223
240
|
// https://wicg.github.io/construct-stylesheets
|
|
224
241
|
const supportsConstructedSheet = (() => {
|
|
225
242
|
// TODO: re-enable this try block once Chrome fixes the performance of
|
package/src/client/tsconfig.json
CHANGED
package/types/importGlob.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { Worker } from 'okie'
|
|
2
|
-
|
|
3
1
|
export interface ImportGlobOptions<
|
|
4
2
|
Eager extends boolean,
|
|
5
3
|
AsType extends string
|
|
@@ -35,7 +33,7 @@ export type GeneralImportGlobOptions = ImportGlobOptions<boolean, string>
|
|
|
35
33
|
export interface KnownAsTypeMap {
|
|
36
34
|
raw: string
|
|
37
35
|
url: string
|
|
38
|
-
worker: Worker
|
|
36
|
+
worker: Worker
|
|
39
37
|
}
|
|
40
38
|
|
|
41
39
|
export interface ImportGlobFunction {
|