vite 2.9.9 → 3.0.0-alpha.2
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 +29 -1
- package/bin/vite.js +5 -5
- package/client.d.ts +4 -3
- package/dist/client/client.mjs +28 -30
- package/dist/client/client.mjs.map +1 -1
- package/dist/client/env.mjs.map +1 -1
- package/dist/node/build.d.ts +178 -0
- package/dist/node/certificate.d.ts +2 -0
- package/dist/node/chunks/{dep-ac1ae66b.js → dep-205b15fe.js} +40 -37
- package/dist/node/chunks/{dep-a9015192.js → dep-24157481.js} +20 -20
- package/dist/node/chunks/{dep-59dc6e00.js → dep-c15b7842.js} +42425 -44710
- package/dist/node/chunks/{dep-d2c728c0.js → dep-c6d28e94.js} +28 -30
- package/dist/node/chunks/{dep-739cc694.js → dep-df464a73.js} +12 -6
- package/dist/node/chunks/{dep-2056ae8a.js → dep-e8ca8d40.js} +9 -3
- package/dist/node/cli.d.ts +1 -0
- package/dist/node/cli.js +41 -42
- package/dist/node/config.d.ts +243 -0
- package/dist/node/constants.d.ts +35 -0
- package/dist/node/constants.js +82 -0
- package/dist/node/http.d.ts +88 -0
- package/dist/node/index.d.ts +234 -160
- package/dist/node/index.js +37 -61
- package/dist/node/logger.d.ts +31 -0
- package/dist/node/optimizer/esbuildDepPlugin.d.ts +4 -0
- package/dist/node/optimizer/index.d.ts +154 -0
- package/dist/node/optimizer/registerMissing.d.ts +3 -0
- package/dist/node/optimizer/scan.d.ts +8 -0
- package/dist/node/packages.d.ts +27 -0
- package/dist/node/plugin.d.ts +129 -0
- package/dist/node/plugins/asset.d.ts +68 -0
- package/dist/node/plugins/assetImportMetaUrl.d.ts +13 -0
- package/dist/node/plugins/clientInjections.d.ts +7 -0
- package/dist/node/plugins/css.d.ts +86 -0
- package/dist/node/plugins/dataUri.d.ts +5 -0
- package/dist/node/plugins/define.d.ts +3 -0
- package/dist/node/plugins/dynamicImportVars.d.ts +9 -0
- package/dist/node/plugins/ensureWatch.d.ts +5 -0
- package/dist/node/plugins/esbuild.d.ts +15 -0
- package/dist/node/plugins/html.d.ts +120 -0
- package/dist/node/plugins/importAnalysis.d.ts +47 -0
- package/dist/node/plugins/importAnalysisBuild.d.ts +16 -0
- package/dist/node/plugins/importMetaGlob.d.ts +34 -0
- package/dist/node/plugins/index.d.ts +3 -0
- package/dist/node/plugins/json.d.ts +23 -0
- package/dist/node/plugins/loadFallback.d.ts +5 -0
- package/dist/node/plugins/manifest.d.ts +14 -0
- package/dist/node/plugins/metadata.d.ts +9 -0
- package/dist/node/plugins/modulePreloadPolyfill.d.ts +4 -0
- package/dist/node/plugins/optimizedDeps.d.ts +4 -0
- package/dist/node/plugins/preAlias.d.ts +5 -0
- package/dist/node/plugins/reporter.d.ts +3 -0
- package/dist/node/plugins/resolve.d.ts +39 -0
- package/dist/node/plugins/splitVendorChunk.d.ts +12 -0
- package/dist/node/plugins/ssrRequireHook.d.ts +12 -0
- package/dist/node/plugins/terser.d.ts +3 -0
- package/dist/node/plugins/wasm.d.ts +4 -0
- package/dist/node/plugins/worker.d.ts +9 -0
- package/dist/node/plugins/workerImportMetaUrl.d.ts +3 -0
- package/dist/node/preview.d.ts +33 -0
- package/dist/node/publicUtils.d.ts +10 -0
- package/dist/node/server/hmr.d.ts +39 -0
- package/dist/node/server/index.d.ts +198 -0
- package/dist/node/server/middlewares/base.d.ts +3 -0
- package/dist/node/server/middlewares/compression.d.ts +1 -0
- package/dist/node/server/middlewares/error.d.ts +8 -0
- package/dist/node/server/middlewares/indexHtml.d.ts +4 -0
- package/dist/node/server/middlewares/proxy.d.ts +20 -0
- package/dist/node/server/middlewares/spaFallback.d.ts +2 -0
- package/dist/node/server/middlewares/static.d.ts +6 -0
- package/dist/node/server/middlewares/time.d.ts +2 -0
- package/dist/node/server/middlewares/transform.d.ts +3 -0
- package/dist/node/server/moduleGraph.d.ts +55 -0
- package/dist/node/server/openBrowser.d.ts +15 -0
- package/dist/node/server/pluginContainer.d.ts +41 -0
- package/dist/node/server/searchRoot.d.ts +8 -0
- package/dist/node/server/send.d.ts +10 -0
- package/dist/node/server/sourcemap.d.ts +11 -0
- package/dist/node/server/transformRequest.d.ts +14 -0
- package/dist/node/server/ws.d.ts +55 -0
- package/dist/node/ssr/ssrExternal.d.ts +11 -0
- package/dist/node/ssr/ssrManifestPlugin.d.ts +3 -0
- package/dist/node/ssr/ssrModuleLoader.d.ts +7 -0
- package/dist/node/ssr/ssrStacktrace.d.ts +3 -0
- package/dist/node/ssr/ssrTransform.d.ts +14 -0
- package/dist/node/utils.d.ts +145 -0
- package/dist/node-cjs/publicUtils.cjs +1788 -0
- package/dist/{node/terser.js → node-cjs/terser.cjs} +0 -0
- package/index.cjs +33 -0
- package/package.json +31 -27
- package/src/client/client.ts +27 -29
- package/src/client/tsconfig.json +1 -1
- package/types/chokidar.d.ts +4 -2
- package/types/hot.d.ts +0 -6
- package/types/importGlob.d.ts +87 -0
- package/types/importMeta.d.ts +5 -15
- package/types/shims.d.ts +6 -9
- package/types/terser.d.ts +0 -2
- package/types/ws.d.ts +2 -2
|
File without changes
|
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,23 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.2",
|
|
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
|
+
"./terser": {
|
|
24
|
+
"require": "./dist/node-cjs/terser.cjs"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
12
27
|
"files": [
|
|
13
28
|
"bin",
|
|
14
29
|
"dist",
|
|
15
30
|
"client.d.ts",
|
|
31
|
+
"index.cjs",
|
|
16
32
|
"src/client",
|
|
17
33
|
"types"
|
|
18
34
|
],
|
|
19
35
|
"engines": {
|
|
20
|
-
"node": ">=
|
|
36
|
+
"node": ">=14.6.0"
|
|
21
37
|
},
|
|
22
38
|
"repository": {
|
|
23
39
|
"type": "git",
|
|
@@ -29,13 +45,12 @@
|
|
|
29
45
|
},
|
|
30
46
|
"homepage": "https://github.com/vitejs/vite/tree/main/#readme",
|
|
31
47
|
"scripts": {
|
|
32
|
-
"dev": "rimraf dist &&
|
|
33
|
-
"build": "rimraf dist &&
|
|
34
|
-
"build-bundle": "rollup
|
|
48
|
+
"dev": "rimraf dist && pnpm run build-bundle -w",
|
|
49
|
+
"build": "rimraf dist && run-s build-bundle build-types",
|
|
50
|
+
"build-bundle": "rollup --config rollup.config.ts --configPlugin typescript",
|
|
35
51
|
"build-types": "run-s build-temp-types patch-types roll-types",
|
|
36
52
|
"build-temp-types": "tsc --emitDeclarationOnly --outDir temp/node -p src/node",
|
|
37
|
-
"
|
|
38
|
-
"patch-types": "ts-node scripts/patchTypes.ts",
|
|
53
|
+
"patch-types": "esno scripts/patchTypes.ts",
|
|
39
54
|
"roll-types": "api-extractor run && rimraf temp",
|
|
40
55
|
"lint": "eslint --ext .ts src/**",
|
|
41
56
|
"format": "prettier --write --parser typescript \"src/**/*.ts\"",
|
|
@@ -43,10 +58,10 @@
|
|
|
43
58
|
},
|
|
44
59
|
"//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!",
|
|
45
60
|
"dependencies": {
|
|
46
|
-
"esbuild": "^0.14.
|
|
61
|
+
"esbuild": "^0.14.38",
|
|
47
62
|
"postcss": "^8.4.13",
|
|
48
63
|
"resolve": "^1.22.0",
|
|
49
|
-
"rollup": "^2.
|
|
64
|
+
"rollup": "^2.72.1"
|
|
50
65
|
},
|
|
51
66
|
"optionalDependencies": {
|
|
52
67
|
"fsevents": "~2.3.2"
|
|
@@ -55,7 +70,7 @@
|
|
|
55
70
|
"@ampproject/remapping": "^2.2.0",
|
|
56
71
|
"@babel/parser": "^7.17.10",
|
|
57
72
|
"@babel/types": "^7.17.10",
|
|
58
|
-
"@jridgewell/trace-mapping": "^0.3.
|
|
73
|
+
"@jridgewell/trace-mapping": "^0.3.10",
|
|
59
74
|
"@rollup/plugin-alias": "^3.1.9",
|
|
60
75
|
"@rollup/plugin-commonjs": "^21.1.0",
|
|
61
76
|
"@rollup/plugin-dynamic-import-vars": "^1.4.3",
|
|
@@ -63,19 +78,6 @@
|
|
|
63
78
|
"@rollup/plugin-node-resolve": "13.2.1",
|
|
64
79
|
"@rollup/plugin-typescript": "^8.3.2",
|
|
65
80
|
"@rollup/pluginutils": "^4.2.1",
|
|
66
|
-
"@types/convert-source-map": "^1.5.2",
|
|
67
|
-
"@types/cross-spawn": "^6.0.2",
|
|
68
|
-
"@types/debug": "^4.1.7",
|
|
69
|
-
"@types/estree": "^0.0.51",
|
|
70
|
-
"@types/etag": "^1.8.1",
|
|
71
|
-
"@types/less": "^3.0.3",
|
|
72
|
-
"@types/micromatch": "^4.0.2",
|
|
73
|
-
"@types/mime": "^2.0.3",
|
|
74
|
-
"@types/node": "^17.0.25",
|
|
75
|
-
"@types/resolve": "^1.20.2",
|
|
76
|
-
"@types/sass": "~1.43.1",
|
|
77
|
-
"@types/stylus": "^0.48.37",
|
|
78
|
-
"@types/ws": "^8.5.3",
|
|
79
81
|
"@vue/compiler-dom": "^3.2.33",
|
|
80
82
|
"acorn": "^8.7.1",
|
|
81
83
|
"cac": "6.7.9",
|
|
@@ -89,6 +91,7 @@
|
|
|
89
91
|
"dotenv": "^14.3.2",
|
|
90
92
|
"dotenv-expand": "^5.1.0",
|
|
91
93
|
"es-module-lexer": "^0.10.5",
|
|
94
|
+
"esno": "^0.16.3",
|
|
92
95
|
"estree-walker": "^2.0.2",
|
|
93
96
|
"etag": "^1.8.1",
|
|
94
97
|
"fast-glob": "^3.2.11",
|
|
@@ -112,11 +115,12 @@
|
|
|
112
115
|
"source-map-js": "^1.0.2",
|
|
113
116
|
"source-map-support": "^0.5.21",
|
|
114
117
|
"strip-ansi": "^6.0.1",
|
|
115
|
-
"strip-literal": "^0.
|
|
118
|
+
"strip-literal": "^0.3.0",
|
|
116
119
|
"terser": "^5.13.1",
|
|
117
|
-
"tsconfck": "^
|
|
120
|
+
"tsconfck": "^2.0.0",
|
|
118
121
|
"tslib": "^2.4.0",
|
|
119
122
|
"types": "link:./types",
|
|
123
|
+
"ufo": "^0.8.4",
|
|
120
124
|
"ws": "^8.6.0"
|
|
121
125
|
},
|
|
122
126
|
"peerDependencies": {
|
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.
|
|
@@ -106,6 +120,7 @@ async function handleMessage(payload: HMRPayload) {
|
|
|
106
120
|
const payloadPath = base + payload.path.slice(1)
|
|
107
121
|
if (
|
|
108
122
|
pagePath === payloadPath ||
|
|
123
|
+
payload.path === '/index.html' ||
|
|
109
124
|
(pagePath.endsWith('/') && pagePath + 'index.html' === payloadPath)
|
|
110
125
|
) {
|
|
111
126
|
location.reload()
|
|
@@ -200,12 +215,10 @@ async function waitForSuccessfulPing(ms = 1000) {
|
|
|
200
215
|
// eslint-disable-next-line no-constant-condition
|
|
201
216
|
while (true) {
|
|
202
217
|
try {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
// failure - non-2xx status code
|
|
208
|
-
else throw new Error()
|
|
218
|
+
// A fetch on a websocket URL will return a successful promise with status 400,
|
|
219
|
+
// but will reject a networking error.
|
|
220
|
+
await fetch(`${location.protocol}//${socketHost}`)
|
|
221
|
+
break
|
|
209
222
|
} catch (e) {
|
|
210
223
|
// wait ms before attempting to ping again
|
|
211
224
|
await new Promise((resolve) => setTimeout(resolve, ms))
|
|
@@ -213,14 +226,6 @@ async function waitForSuccessfulPing(ms = 1000) {
|
|
|
213
226
|
}
|
|
214
227
|
}
|
|
215
228
|
|
|
216
|
-
// ping server
|
|
217
|
-
socket.addEventListener('close', async ({ wasClean }) => {
|
|
218
|
-
if (wasClean) return
|
|
219
|
-
console.log(`[vite] server connection lost. polling for restart...`)
|
|
220
|
-
await waitForSuccessfulPing()
|
|
221
|
-
location.reload()
|
|
222
|
-
})
|
|
223
|
-
|
|
224
229
|
// https://wicg.github.io/construct-stylesheets
|
|
225
230
|
const supportsConstructedSheet = (() => {
|
|
226
231
|
// TODO: re-enable this try block once Chrome fixes the performance of
|
|
@@ -432,13 +437,6 @@ export function createHotContext(ownerPath: string): ViteHotContext {
|
|
|
432
437
|
}
|
|
433
438
|
},
|
|
434
439
|
|
|
435
|
-
acceptDeps() {
|
|
436
|
-
throw new Error(
|
|
437
|
-
`hot.acceptDeps() is deprecated. ` +
|
|
438
|
-
`Use hot.accept() with the same signature instead.`
|
|
439
|
-
)
|
|
440
|
-
},
|
|
441
|
-
|
|
442
440
|
dispose(cb) {
|
|
443
441
|
disposeMap.set(ownerPath, cb)
|
|
444
442
|
},
|
package/src/client/tsconfig.json
CHANGED
package/types/chokidar.d.ts
CHANGED
|
@@ -140,8 +140,10 @@ export interface WatchOptions {
|
|
|
140
140
|
cwd?: string
|
|
141
141
|
|
|
142
142
|
/**
|
|
143
|
-
*
|
|
144
|
-
*
|
|
143
|
+
* If set to true then the strings passed to .watch() and .add() are treated as literal path
|
|
144
|
+
* names, even if they look like globs.
|
|
145
|
+
*
|
|
146
|
+
* @default false
|
|
145
147
|
*/
|
|
146
148
|
disableGlobbing?: boolean
|
|
147
149
|
|
package/types/hot.d.ts
CHANGED
|
@@ -7,12 +7,6 @@ export interface ViteHotContext {
|
|
|
7
7
|
accept(cb: (mod: any) => void): void
|
|
8
8
|
accept(dep: string, cb: (mod: any) => void): void
|
|
9
9
|
accept(deps: readonly string[], cb: (mods: any[]) => void): void
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @deprecated
|
|
13
|
-
*/
|
|
14
|
-
acceptDeps(): never
|
|
15
|
-
|
|
16
10
|
dispose(cb: (data: any) => void): void
|
|
17
11
|
decline(): void
|
|
18
12
|
invalidate(): void
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
export interface ImportGlobOptions<
|
|
2
|
+
Eager extends boolean,
|
|
3
|
+
AsType extends string
|
|
4
|
+
> {
|
|
5
|
+
/**
|
|
6
|
+
* Import type for the import url.
|
|
7
|
+
*/
|
|
8
|
+
as?: AsType
|
|
9
|
+
/**
|
|
10
|
+
* Import as static or dynamic
|
|
11
|
+
*
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
eager?: Eager
|
|
15
|
+
/**
|
|
16
|
+
* Import only the specific named export. Set to `default` to import the default export.
|
|
17
|
+
*/
|
|
18
|
+
import?: string
|
|
19
|
+
/**
|
|
20
|
+
* Custom queries
|
|
21
|
+
*/
|
|
22
|
+
query?: string | Record<string, string | number | boolean>
|
|
23
|
+
/**
|
|
24
|
+
* Search files also inside `node_modules/` and hidden directories (e.g. `.git/`). This might have impact on performance.
|
|
25
|
+
*
|
|
26
|
+
* @default false
|
|
27
|
+
*/
|
|
28
|
+
exhaustive?: boolean
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type GeneralImportGlobOptions = ImportGlobOptions<boolean, string>
|
|
32
|
+
|
|
33
|
+
export interface KnownAsTypeMap {
|
|
34
|
+
raw: string
|
|
35
|
+
url: string
|
|
36
|
+
worker: Worker
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface ImportGlobFunction {
|
|
40
|
+
/**
|
|
41
|
+
* 1. No generic provided, infer the type from `eager` and `as`
|
|
42
|
+
*/
|
|
43
|
+
<
|
|
44
|
+
Eager extends boolean,
|
|
45
|
+
As extends string,
|
|
46
|
+
T = As extends keyof KnownAsTypeMap ? KnownAsTypeMap[As] : unknown
|
|
47
|
+
>(
|
|
48
|
+
glob: string | string[],
|
|
49
|
+
options?: ImportGlobOptions<Eager, As>
|
|
50
|
+
): (Eager extends true ? true : false) extends true
|
|
51
|
+
? Record<string, T>
|
|
52
|
+
: Record<string, () => Promise<T>>
|
|
53
|
+
/**
|
|
54
|
+
* 2. Module generic provided, infer the type from `eager: false`
|
|
55
|
+
*/
|
|
56
|
+
<M>(
|
|
57
|
+
glob: string | string[],
|
|
58
|
+
options?: ImportGlobOptions<false, string>
|
|
59
|
+
): Record<string, () => Promise<M>>
|
|
60
|
+
/**
|
|
61
|
+
* 3. Module generic provided, infer the type from `eager: true`
|
|
62
|
+
*/
|
|
63
|
+
<M>(
|
|
64
|
+
glob: string | string[],
|
|
65
|
+
options: ImportGlobOptions<true, string>
|
|
66
|
+
): Record<string, M>
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface ImportGlobEagerFunction {
|
|
70
|
+
/**
|
|
71
|
+
* 1. No generic provided, infer the type from `as`
|
|
72
|
+
*/
|
|
73
|
+
<
|
|
74
|
+
As extends string,
|
|
75
|
+
T = As extends keyof KnownAsTypeMap ? KnownAsTypeMap[As] : unknown
|
|
76
|
+
>(
|
|
77
|
+
glob: string | string[],
|
|
78
|
+
options?: Omit<ImportGlobOptions<boolean, As>, 'eager'>
|
|
79
|
+
): Record<string, T>
|
|
80
|
+
/**
|
|
81
|
+
* 2. Module generic provided
|
|
82
|
+
*/
|
|
83
|
+
<M>(
|
|
84
|
+
glob: string | string[],
|
|
85
|
+
options?: Omit<ImportGlobOptions<boolean, string>, 'eager'>
|
|
86
|
+
): Record<string, M>
|
|
87
|
+
}
|
package/types/importMeta.d.ts
CHANGED
|
@@ -9,12 +9,6 @@
|
|
|
9
9
|
// in vite/client.d.ts and in production src/node/importGlob.ts doesn't exist.
|
|
10
10
|
interface GlobOptions {
|
|
11
11
|
as?: string
|
|
12
|
-
/**
|
|
13
|
-
* @deprecated
|
|
14
|
-
*/
|
|
15
|
-
assert?: {
|
|
16
|
-
type: string
|
|
17
|
-
}
|
|
18
12
|
}
|
|
19
13
|
|
|
20
14
|
interface ImportMeta {
|
|
@@ -24,15 +18,11 @@ interface ImportMeta {
|
|
|
24
18
|
|
|
25
19
|
readonly env: ImportMetaEnv
|
|
26
20
|
|
|
27
|
-
glob
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
globEager<Module = { [key: string]: any }>(
|
|
33
|
-
pattern: string,
|
|
34
|
-
options?: GlobOptions
|
|
35
|
-
): Record<string, Module>
|
|
21
|
+
glob: import('./importGlob').ImportGlobFunction
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated Use `import.meta.glob('*', { eager: true })` instead
|
|
24
|
+
*/
|
|
25
|
+
globEager: import('./importGlob').ImportGlobEagerFunction
|
|
36
26
|
}
|
|
37
27
|
|
|
38
28
|
interface ImportMetaEnv {
|
package/types/shims.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ declare module 'launch-editor-middleware' {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
declare module 'postcss-load-config' {
|
|
31
|
-
import type {
|
|
31
|
+
import type { Plugin, ProcessOptions } from 'postcss'
|
|
32
32
|
function load(
|
|
33
33
|
inline: any,
|
|
34
34
|
root: string
|
|
@@ -59,6 +59,7 @@ declare module 'postcss-modules' {
|
|
|
59
59
|
|
|
60
60
|
declare module '@rollup/plugin-dynamic-import-vars' {
|
|
61
61
|
import type { Plugin } from 'rollup'
|
|
62
|
+
import type { BaseNode } from 'estree'
|
|
62
63
|
|
|
63
64
|
interface Options {
|
|
64
65
|
include?: string | RegExp | (string | RegExp)[]
|
|
@@ -68,6 +69,10 @@ declare module '@rollup/plugin-dynamic-import-vars' {
|
|
|
68
69
|
|
|
69
70
|
const p: (o?: Options) => Plugin
|
|
70
71
|
export default p
|
|
72
|
+
export function dynamicImportToGlob(
|
|
73
|
+
ast: BaseNode,
|
|
74
|
+
source: string
|
|
75
|
+
): null | string
|
|
71
76
|
}
|
|
72
77
|
|
|
73
78
|
declare module 'rollup-plugin-web-worker-loader' {
|
|
@@ -85,14 +90,6 @@ declare module 'rollup-plugin-web-worker-loader' {
|
|
|
85
90
|
export default p
|
|
86
91
|
}
|
|
87
92
|
|
|
88
|
-
declare module 'micromatch' {
|
|
89
|
-
export function isMatch(
|
|
90
|
-
path: string,
|
|
91
|
-
pattern: string,
|
|
92
|
-
options?: { matchBase?: boolean }
|
|
93
|
-
): boolean
|
|
94
|
-
}
|
|
95
|
-
|
|
96
93
|
// LESS' types somewhat references this which doesn't make sense in Node,
|
|
97
94
|
// so we have to shim it
|
|
98
95
|
declare interface HTMLLinkElement {}
|
package/types/terser.d.ts
CHANGED
|
@@ -185,8 +185,6 @@ export namespace Terser {
|
|
|
185
185
|
module?: boolean
|
|
186
186
|
nameCache?: object
|
|
187
187
|
format?: FormatOptions
|
|
188
|
-
/** @deprecated use format instead */
|
|
189
|
-
output?: FormatOptions
|
|
190
188
|
parse?: ParseOptions
|
|
191
189
|
safari10?: boolean
|
|
192
190
|
sourceMap?: boolean | SourceMapOptions
|
package/types/ws.d.ts
CHANGED
|
@@ -20,9 +20,9 @@ import type {
|
|
|
20
20
|
Agent,
|
|
21
21
|
ClientRequest,
|
|
22
22
|
ClientRequestArgs,
|
|
23
|
+
Server as HTTPServer,
|
|
23
24
|
IncomingMessage,
|
|
24
|
-
OutgoingHttpHeaders
|
|
25
|
-
Server as HTTPServer
|
|
25
|
+
OutgoingHttpHeaders
|
|
26
26
|
} from 'http'
|
|
27
27
|
import type { Server as HTTPSServer } from 'https'
|
|
28
28
|
import type { Duplex, DuplexOptions } from 'stream'
|