vite 2.7.1 → 2.7.5

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.

Potentially problematic release.


This version of vite might be problematic. Click here for more details.

Files changed (91) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/LICENSE.md +41 -11
  3. package/dist/client/client.mjs +1 -1
  4. package/dist/client/client.mjs.map +1 -1
  5. package/dist/node/build.d.ts +200 -0
  6. package/dist/node/chunks/{dep-76c973d0.js → dep-05f535a1.js} +2 -2
  7. package/dist/node/chunks/dep-05f535a1.js.map +1 -0
  8. package/dist/node/chunks/{dep-58399509.js → dep-2d8e2cb1.js} +1 -1
  9. package/dist/node/chunks/dep-2d8e2cb1.js.map +1 -0
  10. package/dist/node/chunks/{dep-8ff556de.js → dep-4b67bc15.js} +79 -61
  11. package/dist/node/chunks/dep-4b67bc15.js.map +1 -0
  12. package/dist/node/chunks/{dep-51488e9f.js → dep-bab9c4d6.js} +2 -2
  13. package/dist/node/chunks/{dep-51488e9f.js.map → dep-bab9c4d6.js.map} +1 -1
  14. package/dist/node/chunks/{dep-3daf770c.js → dep-bc5f477e.js} +665 -209
  15. package/dist/node/chunks/dep-bc5f477e.js.map +1 -0
  16. package/dist/node/cli.d.ts +1 -0
  17. package/dist/node/cli.js +4 -4
  18. package/dist/node/cli.js.map +1 -1
  19. package/dist/node/config.d.ts +202 -0
  20. package/dist/node/constants.d.ts +33 -0
  21. package/dist/node/http.d.ts +84 -0
  22. package/dist/node/importGlob.d.ts +9 -0
  23. package/dist/node/index.d.ts +317 -322
  24. package/dist/node/index.js +1 -1
  25. package/dist/node/logger.d.ts +35 -0
  26. package/dist/node/optimizer/esbuildDepPlugin.d.ts +4 -0
  27. package/dist/node/optimizer/index.d.ts +66 -0
  28. package/dist/node/optimizer/registerMissing.d.ts +2 -0
  29. package/dist/node/optimizer/scan.d.ts +9 -0
  30. package/dist/node/packages.d.ts +25 -0
  31. package/dist/node/plugin.d.ts +115 -0
  32. package/dist/node/plugins/asset.d.ts +40 -0
  33. package/dist/node/plugins/assetImportMetaUrl.d.ts +13 -0
  34. package/dist/node/plugins/clientInjections.d.ts +7 -0
  35. package/dist/node/plugins/css.d.ts +70 -0
  36. package/dist/node/plugins/dataUri.d.ts +5 -0
  37. package/dist/node/plugins/define.d.ts +3 -0
  38. package/dist/node/plugins/esbuild.d.ts +15 -0
  39. package/dist/node/plugins/html.d.ts +102 -0
  40. package/dist/node/plugins/importAnalysis.d.ts +46 -0
  41. package/dist/node/plugins/importAnalysisBuild.d.ts +15 -0
  42. package/dist/node/plugins/index.d.ts +3 -0
  43. package/dist/node/plugins/json.d.ts +22 -0
  44. package/dist/node/plugins/loadFallback.d.ts +5 -0
  45. package/dist/node/plugins/manifest.d.ts +14 -0
  46. package/dist/node/plugins/modulePreloadPolyfill.d.ts +4 -0
  47. package/dist/node/plugins/preAlias.d.ts +5 -0
  48. package/dist/node/plugins/reporter.d.ts +3 -0
  49. package/dist/node/plugins/resolve.d.ts +38 -0
  50. package/dist/node/plugins/ssrRequireHook.d.ts +12 -0
  51. package/dist/node/plugins/terser.d.ts +3 -0
  52. package/dist/node/plugins/wasm.d.ts +3 -0
  53. package/dist/node/plugins/worker.d.ts +3 -0
  54. package/dist/node/preview.d.ts +31 -0
  55. package/dist/node/server/hmr.d.ts +37 -0
  56. package/dist/node/server/index.d.ts +215 -0
  57. package/dist/node/server/middlewares/base.d.ts +3 -0
  58. package/dist/node/server/middlewares/error.d.ts +8 -0
  59. package/dist/node/server/middlewares/indexHtml.d.ts +4 -0
  60. package/dist/node/server/middlewares/proxy.d.ts +20 -0
  61. package/dist/node/server/middlewares/spaFallback.d.ts +2 -0
  62. package/dist/node/server/middlewares/static.d.ts +6 -0
  63. package/dist/node/server/middlewares/time.d.ts +2 -0
  64. package/dist/node/server/middlewares/transform.d.ts +3 -0
  65. package/dist/node/server/moduleGraph.d.ts +53 -0
  66. package/dist/node/server/openBrowser.d.ts +15 -0
  67. package/dist/node/server/pluginContainer.d.ts +37 -0
  68. package/dist/node/server/searchRoot.d.ts +8 -0
  69. package/dist/node/server/send.d.ts +4 -0
  70. package/dist/node/server/sourcemap.d.ts +8 -0
  71. package/dist/node/server/transformRequest.d.ts +14 -0
  72. package/dist/node/server/ws.d.ts +14 -0
  73. package/dist/node/ssr/ssrExternal.d.ts +7 -0
  74. package/dist/node/ssr/ssrManifestPlugin.d.ts +3 -0
  75. package/dist/node/ssr/ssrModuleLoader.d.ts +7 -0
  76. package/dist/node/ssr/ssrStacktrace.d.ts +3 -0
  77. package/dist/node/ssr/ssrTransform.d.ts +8 -0
  78. package/dist/node/utils.d.ts +114 -0
  79. package/package.json +15 -15
  80. package/src/client/client.ts +3 -3
  81. package/src/client/overlay.ts +1 -1
  82. package/types/alias.d.ts +1 -1
  83. package/types/chokidar.d.ts +2 -2
  84. package/types/http-proxy.d.ts +4 -4
  85. package/types/importMeta.d.ts +6 -0
  86. package/types/shims.d.ts +5 -5
  87. package/types/ws.d.ts +284 -288
  88. package/dist/node/chunks/dep-3daf770c.js.map +0 -1
  89. package/dist/node/chunks/dep-58399509.js.map +0 -1
  90. package/dist/node/chunks/dep-76c973d0.js.map +0 -1
  91. package/dist/node/chunks/dep-8ff556de.js.map +0 -1
@@ -0,0 +1,114 @@
1
+ import debug from 'debug';
2
+ import type { FSWatcher } from 'chokidar';
3
+ import type { DecodedSourceMap, RawSourceMap } from '@ampproject/remapping/dist/types/types';
4
+ export declare function slash(p: string): string;
5
+ export declare function unwrapId(id: string): string;
6
+ export declare const flattenId: (id: string) => string;
7
+ export declare const normalizeId: (id: string) => string;
8
+ export declare function isBuiltin(id: string): boolean;
9
+ export declare function moduleListContains(moduleList: string[] | undefined, id: string): boolean | undefined;
10
+ export declare const bareImportRE: RegExp;
11
+ export declare const deepImportRE: RegExp;
12
+ export declare let isRunningWithYarnPnp: boolean;
13
+ export declare function resolveFrom(id: string, basedir: string, preserveSymlinks?: boolean, ssr?: boolean): string;
14
+ /**
15
+ * like `resolveFrom` but supports resolving `>` path in `id`,
16
+ * for example: `foo > bar > baz`
17
+ */
18
+ export declare function nestedResolveFrom(id: string, basedir: string, preserveSymlinks?: boolean): string;
19
+ interface DebuggerOptions {
20
+ onlyWhenFocused?: boolean | string;
21
+ }
22
+ export declare type ViteDebugScope = `vite:${string}`;
23
+ export declare function createDebugger(namespace: ViteDebugScope, options?: DebuggerOptions): debug.Debugger['log'];
24
+ export declare const isWindows: boolean;
25
+ export declare function normalizePath(id: string): string;
26
+ export declare function fsPathFromId(id: string): string;
27
+ export declare function ensureVolumeInPath(file: string): string;
28
+ export declare const queryRE: RegExp;
29
+ export declare const hashRE: RegExp;
30
+ export declare const cleanUrl: (url: string) => string;
31
+ export declare const externalRE: RegExp;
32
+ export declare const isExternalUrl: (url: string) => boolean;
33
+ export declare const dataUrlRE: RegExp;
34
+ export declare const isDataUrl: (url: string) => boolean;
35
+ export declare const virtualModuleRE: RegExp;
36
+ export declare const virtualModulePrefix = "virtual-module:";
37
+ export declare const isJSRequest: (url: string) => boolean;
38
+ export declare const isTsRequest: (url: string) => boolean;
39
+ export declare const isPossibleTsOutput: (url: string) => boolean;
40
+ export declare const getTsSrcPath: (filename: string) => string;
41
+ export declare const isImportRequest: (url: string) => boolean;
42
+ export declare const isInternalRequest: (url: string) => boolean;
43
+ export declare function removeImportQuery(url: string): string;
44
+ export declare function injectQuery(url: string, queryToInject: string): string;
45
+ export declare function removeTimestampQuery(url: string): string;
46
+ export declare function asyncReplace(input: string, re: RegExp, replacer: (match: RegExpExecArray) => string | Promise<string>): Promise<string>;
47
+ export declare function timeFrom(start: number, subtract?: number): string;
48
+ /**
49
+ * pretty url for logging.
50
+ */
51
+ export declare function prettifyUrl(url: string, root: string): string;
52
+ export declare function isObject(value: unknown): value is Record<string, any>;
53
+ export declare function isDefined<T>(value: T | undefined | null): value is T;
54
+ export declare function lookupFile(dir: string, formats: string[], pathOnly?: boolean): string | undefined;
55
+ export declare function pad(source: string, n?: number): string;
56
+ export declare function posToNumber(source: string, pos: number | {
57
+ line: number;
58
+ column: number;
59
+ }): number;
60
+ export declare function numberToPos(source: string, offset: number | {
61
+ line: number;
62
+ column: number;
63
+ }): {
64
+ line: number;
65
+ column: number;
66
+ };
67
+ export declare function generateCodeFrame(source: string, start?: number | {
68
+ line: number;
69
+ column: number;
70
+ }, end?: number): string;
71
+ export declare function writeFile(filename: string, content: string | Uint8Array): void;
72
+ /**
73
+ * Use instead of fs.existsSync(filename)
74
+ * #2051 if we don't have read permission on a directory, existsSync() still
75
+ * works and will result in massively slow subsequent checks (which are
76
+ * unnecessary in the first place)
77
+ */
78
+ export declare function isFileReadable(filename: string): boolean;
79
+ /**
80
+ * Delete every file and subdirectory. **The given directory must exist.**
81
+ * Pass an optional `skip` array to preserve files in the root directory.
82
+ */
83
+ export declare function emptyDir(dir: string, skip?: string[]): void;
84
+ export declare function copyDir(srcDir: string, destDir: string): void;
85
+ export declare function ensureLeadingSlash(path: string): string;
86
+ export declare function ensureWatchedFile(watcher: FSWatcher, file: string | null, root: string): void;
87
+ interface ImageCandidate {
88
+ url: string;
89
+ descriptor: string;
90
+ }
91
+ export declare function processSrcSet(srcs: string, replacer: (arg: ImageCandidate) => Promise<string>): Promise<string>;
92
+ export declare function combineSourcemaps(filename: string, sourcemapList: Array<DecodedSourceMap | RawSourceMap>): RawSourceMap;
93
+ export declare function unique<T>(arr: T[]): T[];
94
+ export interface Hostname {
95
+ host: string | undefined;
96
+ name: string;
97
+ }
98
+ export declare function resolveHostname(optionsHost: string | boolean | undefined): Hostname;
99
+ export declare function arraify<T>(target: T | T[]): T[];
100
+ export declare function toUpperCaseDriveLetter(pathName: string): string;
101
+ export declare const multilineCommentsRE: RegExp;
102
+ export declare const singlelineCommentsRE: RegExp;
103
+ export declare const usingDynamicImport: boolean;
104
+ /**
105
+ * Dynamically import files. It will make sure it's not being compiled away by TS/Rollup.
106
+ *
107
+ * As a temporary workaround for Jest's lack of stable ESM support, we fallback to require
108
+ * if we're in a Jest environment.
109
+ * See https://github.com/vitejs/vite/pull/5197#issuecomment-938054077
110
+ *
111
+ * @param file File path to import.
112
+ */
113
+ export declare const dynamicImport: Function;
114
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "2.7.1",
3
+ "version": "2.7.5",
4
4
  "license": "MIT",
5
5
  "author": "Evan You",
6
6
  "description": "Native-ESM powered web dev build tool",
@@ -35,17 +35,17 @@
35
35
  "build-types": "run-s build-temp-types patch-types roll-types",
36
36
  "build-temp-types": "tsc --emitDeclarationOnly --outDir temp/node -p src/node",
37
37
  "ci-build": "rimraf dist && run-s build-bundle build-types",
38
- "patch-types": "node scripts/patchTypes.cjs",
38
+ "patch-types": "ts-node scripts/patchTypes.ts",
39
39
  "roll-types": "api-extractor run && rimraf temp",
40
40
  "lint": "eslint --ext .ts src/**",
41
41
  "format": "prettier --write --parser typescript \"src/**/*.ts\"",
42
42
  "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s --commit-path .",
43
- "release": "node ../../scripts/release.cjs"
43
+ "release": "ts-node ../../scripts/release.ts"
44
44
  },
45
45
  "//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!",
46
46
  "dependencies": {
47
47
  "esbuild": "^0.13.12",
48
- "postcss": "^8.3.11",
48
+ "postcss": "^8.4.5",
49
49
  "resolve": "^1.20.0",
50
50
  "rollup": "^2.59.0"
51
51
  },
@@ -53,16 +53,16 @@
53
53
  "fsevents": "~2.3.2"
54
54
  },
55
55
  "devDependencies": {
56
- "@ampproject/remapping": "^1.0.1",
57
- "@babel/parser": "^7.16.4",
56
+ "@ampproject/remapping": "^1.0.2",
57
+ "@babel/parser": "^7.16.6",
58
58
  "@babel/types": "^7.16.0",
59
59
  "@rollup/plugin-alias": "^3.1.8",
60
60
  "@rollup/plugin-commonjs": "^21.0.1",
61
61
  "@rollup/plugin-dynamic-import-vars": "^1.4.1",
62
62
  "@rollup/plugin-json": "^4.1.0",
63
- "@rollup/plugin-node-resolve": "13.0.6",
63
+ "@rollup/plugin-node-resolve": "13.1.1",
64
64
  "@rollup/plugin-typescript": "^8.3.0",
65
- "@rollup/pluginutils": "^4.1.1",
65
+ "@rollup/pluginutils": "^4.1.2",
66
66
  "@types/convert-source-map": "^1.5.2",
67
67
  "@types/debug": "^4.1.7",
68
68
  "@types/estree": "^0.0.50",
@@ -70,12 +70,12 @@
70
70
  "@types/less": "^3.0.3",
71
71
  "@types/micromatch": "^4.0.2",
72
72
  "@types/mime": "^2.0.3",
73
- "@types/node": "^16.11.9",
73
+ "@types/node": "^16.11.14",
74
74
  "@types/resolve": "^1.20.1",
75
- "@types/sass": "~1.43.0",
75
+ "@types/sass": "~1.43.1",
76
76
  "@types/stylus": "^0.48.36",
77
- "@types/ws": "^8.2.0",
78
- "@vue/compiler-dom": "^3.2.22",
77
+ "@types/ws": "^8.2.2",
78
+ "@vue/compiler-dom": "^3.2.26",
79
79
  "acorn": "^8.6.0",
80
80
  "acorn-class-fields": "^1.0.0",
81
81
  "acorn-static-class-features": "^1.0.0",
@@ -87,7 +87,7 @@
87
87
  "connect-history-api-fallback": "^1.6.0",
88
88
  "convert-source-map": "^1.8.0",
89
89
  "cors": "^2.8.5",
90
- "debug": "^4.3.2",
90
+ "debug": "^4.3.3",
91
91
  "dotenv": "^10.0.0",
92
92
  "dotenv-expand": "^5.1.0",
93
93
  "es-module-lexer": "^0.9.3",
@@ -109,7 +109,7 @@
109
109
  "resolve.exports": "^1.1.0",
110
110
  "rollup-plugin-license": "^2.6.0",
111
111
  "selfsigned": "^1.10.11",
112
- "sirv": "^1.0.18",
112
+ "sirv": "^1.0.19",
113
113
  "source-map": "^0.6.1",
114
114
  "source-map-support": "^0.5.21",
115
115
  "strip-ansi": "^6.0.1",
@@ -117,7 +117,7 @@
117
117
  "tsconfck": "1.1.1",
118
118
  "tslib": "^2.3.1",
119
119
  "types": "link:./types",
120
- "ws": "^8.2.3"
120
+ "ws": "^8.3.0"
121
121
  },
122
122
  "peerDependencies": {
123
123
  "less": "*",
@@ -1,4 +1,4 @@
1
- import {
1
+ import type {
2
2
  ErrorPayload,
3
3
  FullReloadPayload,
4
4
  HMRPayload,
@@ -6,7 +6,7 @@ import {
6
6
  Update,
7
7
  UpdatePayload
8
8
  } from 'types/hmrPayload'
9
- import { CustomEventName } from 'types/customEvent'
9
+ import type { CustomEventName } from 'types/customEvent'
10
10
  import { ErrorOverlay, overlayId } from './overlay'
11
11
  // eslint-disable-next-line node/no-missing-import
12
12
  import '@vite/env'
@@ -100,7 +100,7 @@ async function handleMessage(payload: HMRPayload) {
100
100
  if (payload.path && payload.path.endsWith('.html')) {
101
101
  // if html file is edited, only reload the page if the browser is
102
102
  // currently on that page.
103
- const pagePath = location.pathname
103
+ const pagePath = decodeURI(location.pathname)
104
104
  const payloadPath = base + payload.path.slice(1)
105
105
  if (
106
106
  pagePath === payloadPath ||
@@ -1,4 +1,4 @@
1
- import { ErrorPayload } from 'types/hmrPayload'
1
+ import type { ErrorPayload } from 'types/hmrPayload'
2
2
 
3
3
  const template = /*html*/ `
4
4
  <style>
package/types/alias.d.ts CHANGED
@@ -27,7 +27,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
27
  THE SOFTWARE.
28
28
  */
29
29
 
30
- import { PluginHooks } from 'rollup'
30
+ import type { PluginHooks } from 'rollup'
31
31
 
32
32
  export interface Alias {
33
33
  find: string | RegExp
@@ -28,8 +28,8 @@ THE SOFTWARE.
28
28
  */
29
29
  /// <reference types="node" />
30
30
 
31
- import * as fs from 'fs'
32
- import { Matcher } from './anymatch'
31
+ import type * as fs from 'fs'
32
+ import type { Matcher } from './anymatch'
33
33
 
34
34
  export interface FSWatcher extends fs.FSWatcher {
35
35
  options: WatchOptions
@@ -13,11 +13,11 @@
13
13
 
14
14
  /// <reference types="node" />
15
15
 
16
- import * as net from 'net'
17
- import * as http from 'http'
16
+ import type * as net from 'net'
17
+ import type * as http from 'http'
18
18
  import * as events from 'events'
19
- import * as url from 'url'
20
- import * as stream from 'stream'
19
+ import type * as url from 'url'
20
+ import type * as stream from 'stream'
21
21
 
22
22
  export namespace HttpProxy {
23
23
  export type ProxyTarget = ProxyTargetUrl | ProxyTargetDetailed
@@ -1,3 +1,9 @@
1
+ // This file is an augmentation to the built-in ImportMeta interface
2
+ // Thus cannot contain any top-level imports
3
+ // <https://www.typescriptlang.org/docs/handbook/declaration-merging.html#module-augmentation>
4
+
5
+ /* eslint-disable @typescript-eslint/consistent-type-imports */
6
+
1
7
  interface ImportMeta {
2
8
  url: string
3
9
 
package/types/shims.d.ts CHANGED
@@ -38,7 +38,7 @@ declare module 'launch-editor-middleware' {
38
38
  }
39
39
 
40
40
  declare module 'postcss-load-config' {
41
- import { ProcessOptions, Plugin } from 'postcss'
41
+ import type { ProcessOptions, Plugin } from 'postcss'
42
42
  function load(
43
43
  inline: any,
44
44
  root: string
@@ -50,7 +50,7 @@ declare module 'postcss-load-config' {
50
50
  }
51
51
 
52
52
  declare module 'postcss-import' {
53
- import { Plugin } from 'postcss'
53
+ import type { Plugin } from 'postcss'
54
54
  const plugin: (options: {
55
55
  resolve: (
56
56
  id: string,
@@ -62,13 +62,13 @@ declare module 'postcss-import' {
62
62
  }
63
63
 
64
64
  declare module 'postcss-modules' {
65
- import { Plugin } from 'postcss'
65
+ import type { Plugin } from 'postcss'
66
66
  const plugin: (options: any) => Plugin
67
67
  export = plugin
68
68
  }
69
69
 
70
70
  declare module '@rollup/plugin-dynamic-import-vars' {
71
- import { Plugin } from 'rollup'
71
+ import type { Plugin } from 'rollup'
72
72
 
73
73
  interface Options {
74
74
  include?: string | RegExp | (string | RegExp)[]
@@ -81,7 +81,7 @@ declare module '@rollup/plugin-dynamic-import-vars' {
81
81
  }
82
82
 
83
83
  declare module 'rollup-plugin-web-worker-loader' {
84
- import { Plugin } from 'rollup'
84
+ import type { Plugin } from 'rollup'
85
85
 
86
86
  interface Options {
87
87
  targetPlatform?: string