vite 6.0.0-alpha.9 → 6.0.0-beta.1
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 +115 -206
- package/bin/vite.js +1 -1
- package/client.d.ts +12 -0
- package/dist/client/client.mjs +614 -612
- package/dist/client/env.mjs +18 -24
- package/dist/node/chunks/{dep--Oy4lQ4n.js → dep-BZ_CwQkz.js} +43095 -44742
- package/dist/node/chunks/{dep-BJOLgJFH.js → dep-BZeeNeMJ.js} +165 -968
- package/dist/node/chunks/{dep-CrWVpuYf.js → dep-D-7KCb9p.js} +32 -2
- package/dist/node/chunks/{dep-m9gtlanK.js → dep-DiM5uMHt.js} +1 -1
- package/dist/node/cli.js +282 -257
- package/dist/node/constants.js +108 -84
- package/dist/node/index.d.ts +2010 -1956
- package/dist/node/index.js +237 -148
- package/dist/node/module-runner.d.ts +31 -12
- package/dist/node/module-runner.js +262 -204
- package/dist/node-cjs/publicUtils.cjs +679 -717
- package/index.cjs +27 -4
- package/package.json +34 -31
- package/types/customEvent.d.ts +1 -0
- package/types/hmrPayload.d.ts +3 -1
- package/dist/client/client.mjs.map +0 -1
- package/dist/client/env.mjs.map +0 -1
- package/dist/node/chunks/dep-C7zR1Rh8.js +0 -233
package/dist/node/constants.js
CHANGED
@@ -2,114 +2,138 @@ import path, { resolve } from 'node:path';
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
3
3
|
import { readFileSync } from 'node:fs';
|
4
4
|
|
5
|
-
const { version } = JSON.parse(
|
5
|
+
const { version } = JSON.parse(
|
6
|
+
readFileSync(new URL("../../package.json", import.meta.url)).toString()
|
7
|
+
);
|
8
|
+
const ROLLUP_HOOKS = [
|
9
|
+
"buildStart",
|
10
|
+
"buildEnd",
|
11
|
+
"renderStart",
|
12
|
+
"renderError",
|
13
|
+
"renderChunk",
|
14
|
+
"writeBundle",
|
15
|
+
"generateBundle",
|
16
|
+
"banner",
|
17
|
+
"footer",
|
18
|
+
"augmentChunkHash",
|
19
|
+
"outputOptions",
|
20
|
+
"renderDynamicImport",
|
21
|
+
"resolveFileUrl",
|
22
|
+
"resolveImportMeta",
|
23
|
+
"intro",
|
24
|
+
"outro",
|
25
|
+
"closeBundle",
|
26
|
+
"closeWatcher",
|
27
|
+
"load",
|
28
|
+
"moduleParsed",
|
29
|
+
"watchChange",
|
30
|
+
"resolveDynamicImport",
|
31
|
+
"resolveId",
|
32
|
+
"shouldTransformCachedModule",
|
33
|
+
"transform"
|
34
|
+
];
|
6
35
|
const VERSION = version;
|
7
36
|
const DEFAULT_MAIN_FIELDS = [
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
37
|
+
"browser",
|
38
|
+
"module",
|
39
|
+
"jsnext:main",
|
40
|
+
// moment still uses this...
|
41
|
+
"jsnext"
|
12
42
|
];
|
13
|
-
// Baseline support browserslist
|
14
|
-
// "defaults and supports es6-module and supports es6-module-dynamic-import"
|
15
|
-
// Higher browser versions may be needed for extra features.
|
16
43
|
const ESBUILD_MODULES_TARGET = [
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
44
|
+
"es2020",
|
45
|
+
// support import.meta.url
|
46
|
+
"edge88",
|
47
|
+
"firefox78",
|
48
|
+
"chrome87",
|
49
|
+
"safari14"
|
22
50
|
];
|
23
51
|
const DEFAULT_EXTENSIONS = [
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
52
|
+
".mjs",
|
53
|
+
".js",
|
54
|
+
".mts",
|
55
|
+
".ts",
|
56
|
+
".jsx",
|
57
|
+
".tsx",
|
58
|
+
".json"
|
31
59
|
];
|
32
60
|
const DEFAULT_CONFIG_FILES = [
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
61
|
+
"vite.config.js",
|
62
|
+
"vite.config.mjs",
|
63
|
+
"vite.config.ts",
|
64
|
+
"vite.config.cjs",
|
65
|
+
"vite.config.mts",
|
66
|
+
"vite.config.cts"
|
39
67
|
];
|
40
68
|
const JS_TYPES_RE = /\.(?:j|t)sx?$|\.mjs$/;
|
41
69
|
const CSS_LANGS_RE = /\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/;
|
42
70
|
const OPTIMIZABLE_ENTRY_RE = /\.[cm]?[jt]s$/;
|
43
71
|
const SPECIAL_QUERY_RE = /[?&](?:worker|sharedworker|raw|url)\b/;
|
44
|
-
/**
|
45
|
-
* Prefix for resolved fs paths, since windows paths may not be valid as URLs.
|
46
|
-
*/
|
47
72
|
const FS_PREFIX = `/@fs/`;
|
48
73
|
const CLIENT_PUBLIC_PATH = `/@vite/client`;
|
49
74
|
const ENV_PUBLIC_PATH = `/@vite/env`;
|
50
75
|
const VITE_PACKAGE_DIR = resolve(
|
51
|
-
// import.meta.url is `dist/node/constants.js` after bundle
|
52
|
-
fileURLToPath(import.meta.url),
|
53
|
-
|
54
|
-
|
76
|
+
// import.meta.url is `dist/node/constants.js` after bundle
|
77
|
+
fileURLToPath(import.meta.url),
|
78
|
+
"../../.."
|
79
|
+
);
|
80
|
+
const CLIENT_ENTRY = resolve(VITE_PACKAGE_DIR, "dist/client/client.mjs");
|
81
|
+
const ENV_ENTRY = resolve(VITE_PACKAGE_DIR, "dist/client/env.mjs");
|
55
82
|
const CLIENT_DIR = path.dirname(CLIENT_ENTRY);
|
56
|
-
// ** READ THIS ** before editing `KNOWN_ASSET_TYPES`.
|
57
|
-
// If you add an asset to `KNOWN_ASSET_TYPES`, make sure to also add it
|
58
|
-
// to the TypeScript declaration file `packages/vite/client.d.ts` and
|
59
|
-
// add a mime type to the `registerCustomMime` in
|
60
|
-
// `packages/vite/src/node/plugin/assets.ts` if mime type cannot be
|
61
|
-
// looked up by mrmime.
|
62
83
|
const KNOWN_ASSET_TYPES = [
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
84
|
+
// images
|
85
|
+
"apng",
|
86
|
+
"bmp",
|
87
|
+
"png",
|
88
|
+
"jpe?g",
|
89
|
+
"jfif",
|
90
|
+
"pjpeg",
|
91
|
+
"pjp",
|
92
|
+
"gif",
|
93
|
+
"svg",
|
94
|
+
"ico",
|
95
|
+
"webp",
|
96
|
+
"avif",
|
97
|
+
// media
|
98
|
+
"mp4",
|
99
|
+
"webm",
|
100
|
+
"ogg",
|
101
|
+
"mp3",
|
102
|
+
"wav",
|
103
|
+
"flac",
|
104
|
+
"aac",
|
105
|
+
"opus",
|
106
|
+
"mov",
|
107
|
+
"m4a",
|
108
|
+
"vtt",
|
109
|
+
// fonts
|
110
|
+
"woff2?",
|
111
|
+
"eot",
|
112
|
+
"ttf",
|
113
|
+
"otf",
|
114
|
+
// other
|
115
|
+
"webmanifest",
|
116
|
+
"pdf",
|
117
|
+
"txt"
|
96
118
|
];
|
97
|
-
const DEFAULT_ASSETS_RE = new RegExp(
|
119
|
+
const DEFAULT_ASSETS_RE = new RegExp(
|
120
|
+
`\\.(` + KNOWN_ASSET_TYPES.join("|") + `)(\\?.*)?$`
|
121
|
+
);
|
98
122
|
const DEP_VERSION_RE = /[?&](v=[\w.-]+)\b/;
|
99
|
-
const loopbackHosts = new Set([
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
123
|
+
const loopbackHosts = /* @__PURE__ */ new Set([
|
124
|
+
"localhost",
|
125
|
+
"127.0.0.1",
|
126
|
+
"::1",
|
127
|
+
"0000:0000:0000:0000:0000:0000:0000:0001"
|
104
128
|
]);
|
105
|
-
const wildcardHosts = new Set([
|
106
|
-
|
107
|
-
|
108
|
-
|
129
|
+
const wildcardHosts = /* @__PURE__ */ new Set([
|
130
|
+
"0.0.0.0",
|
131
|
+
"::",
|
132
|
+
"0000:0000:0000:0000:0000:0000:0000:0000"
|
109
133
|
]);
|
110
134
|
const DEFAULT_DEV_PORT = 5173;
|
111
135
|
const DEFAULT_PREVIEW_PORT = 4173;
|
112
136
|
const DEFAULT_ASSETS_INLINE_LIMIT = 4096;
|
113
|
-
const METADATA_FILENAME =
|
137
|
+
const METADATA_FILENAME = "_metadata.json";
|
114
138
|
|
115
|
-
export { CLIENT_DIR, CLIENT_ENTRY, CLIENT_PUBLIC_PATH, CSS_LANGS_RE, DEFAULT_ASSETS_INLINE_LIMIT, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES, DEFAULT_DEV_PORT, DEFAULT_EXTENSIONS, DEFAULT_MAIN_FIELDS, DEFAULT_PREVIEW_PORT, DEP_VERSION_RE, ENV_ENTRY, ENV_PUBLIC_PATH, ESBUILD_MODULES_TARGET, FS_PREFIX, JS_TYPES_RE, KNOWN_ASSET_TYPES, METADATA_FILENAME, OPTIMIZABLE_ENTRY_RE, SPECIAL_QUERY_RE, VERSION, VITE_PACKAGE_DIR, loopbackHosts, wildcardHosts };
|
139
|
+
export { CLIENT_DIR, CLIENT_ENTRY, CLIENT_PUBLIC_PATH, CSS_LANGS_RE, DEFAULT_ASSETS_INLINE_LIMIT, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES, DEFAULT_DEV_PORT, DEFAULT_EXTENSIONS, DEFAULT_MAIN_FIELDS, DEFAULT_PREVIEW_PORT, DEP_VERSION_RE, ENV_ENTRY, ENV_PUBLIC_PATH, ESBUILD_MODULES_TARGET, FS_PREFIX, JS_TYPES_RE, KNOWN_ASSET_TYPES, METADATA_FILENAME, OPTIMIZABLE_ENTRY_RE, ROLLUP_HOOKS, SPECIAL_QUERY_RE, VERSION, VITE_PACKAGE_DIR, loopbackHosts, wildcardHosts };
|