vite 2.6.9 → 2.6.13
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.
- package/CHANGELOG.md +48 -0
- package/dist/client/client.mjs +2 -2
- package/dist/client/client.mjs.map +1 -1
- package/dist/node/chunks/{dep-8e7741a0.js → dep-1a7759b6.js} +2 -2
- package/dist/node/chunks/{dep-8e7741a0.js.map → dep-1a7759b6.js.map} +1 -1
- package/dist/node/chunks/{dep-b502d052.js → dep-724b1c48.js} +2 -2
- package/dist/node/chunks/{dep-b502d052.js.map → dep-724b1c48.js.map} +1 -1
- package/dist/node/chunks/{dep-be032392.js → dep-85dbaaa7.js} +101 -67
- package/dist/node/chunks/dep-85dbaaa7.js.map +1 -0
- package/dist/node/chunks/{dep-9b6b378f.js → dep-93e144c8.js} +2 -2
- package/dist/node/chunks/{dep-9b6b378f.js.map → dep-93e144c8.js.map} +1 -1
- package/dist/node/cli.js +5 -4
- package/dist/node/cli.js.map +1 -1
- package/dist/node/index.d.ts +515 -3
- package/dist/node/index.js +1 -1
- package/package.json +3 -1
- package/src/client/overlay.ts +2 -2
- package/types/ws.d.ts +532 -0
- package/dist/node/chunks/dep-be032392.js.map +0 -1
|
@@ -3883,6 +3883,8 @@ function unwrapId$1(id) {
|
|
|
3883
3883
|
const flattenId = (id) => id.replace(/(\s*>\s*)/g, '__').replace(/[\/\.]/g, '_');
|
|
3884
3884
|
const normalizeId$1 = (id) => id.replace(/(\s*>\s*)/g, ' > ');
|
|
3885
3885
|
function isBuiltin(id) {
|
|
3886
|
+
const deepMatch = id.match(deepImportRE);
|
|
3887
|
+
id = deepMatch ? deepMatch[1] || deepMatch[2] : id;
|
|
3886
3888
|
return builtinModules_1.includes(id);
|
|
3887
3889
|
}
|
|
3888
3890
|
const bareImportRE = /^[\w@](?!.*:\/\/)/;
|
|
@@ -4141,6 +4143,21 @@ function writeFile(filename, content) {
|
|
|
4141
4143
|
}
|
|
4142
4144
|
fs__default.writeFileSync(filename, content);
|
|
4143
4145
|
}
|
|
4146
|
+
/**
|
|
4147
|
+
* Use instead of fs.existsSync(filename)
|
|
4148
|
+
* #2051 if we don't have read permission on a directory, existsSync() still
|
|
4149
|
+
* works and will result in massively slow subsequent checks (which are
|
|
4150
|
+
* unnecessary in the first place)
|
|
4151
|
+
*/
|
|
4152
|
+
function isFileReadable(filename) {
|
|
4153
|
+
try {
|
|
4154
|
+
fs__default.accessSync(filename, fs__default.constants.R_OK);
|
|
4155
|
+
return true;
|
|
4156
|
+
}
|
|
4157
|
+
catch {
|
|
4158
|
+
return false;
|
|
4159
|
+
}
|
|
4160
|
+
}
|
|
4144
4161
|
/**
|
|
4145
4162
|
* Delete every file and subdirectory. **The given directory must exist.**
|
|
4146
4163
|
* Pass an optional `skip` array to preserve files in the root directory.
|
|
@@ -19873,7 +19890,7 @@ function cssPlugin(config) {
|
|
|
19873
19890
|
const thisModule = moduleGraph.getModuleById(id);
|
|
19874
19891
|
if (thisModule) {
|
|
19875
19892
|
// CSS modules cannot self-accept since it exports values
|
|
19876
|
-
const isSelfAccepting = !modules;
|
|
19893
|
+
const isSelfAccepting = !modules && !inlineRE.test(id);
|
|
19877
19894
|
if (deps) {
|
|
19878
19895
|
// record deps in the module graph so edits to @import css can trigger
|
|
19879
19896
|
// main import to hot update
|
|
@@ -19958,13 +19975,10 @@ function cssPostPlugin(config) {
|
|
|
19958
19975
|
if (!inlined) {
|
|
19959
19976
|
styles.set(id, css);
|
|
19960
19977
|
}
|
|
19961
|
-
else {
|
|
19962
|
-
css = await minifyCSS(css, config);
|
|
19963
|
-
}
|
|
19964
19978
|
return {
|
|
19965
19979
|
code: modulesCode ||
|
|
19966
19980
|
(usedRE.test(id)
|
|
19967
|
-
? `export default ${JSON.stringify(css)}`
|
|
19981
|
+
? `export default ${JSON.stringify(inlined ? await minifyCSS(css, config) : css)}`
|
|
19968
19982
|
: `export default ''`),
|
|
19969
19983
|
map: { mappings: '' },
|
|
19970
19984
|
// avoid the css module from being tree-shaken so that we can retrieve
|
|
@@ -20243,7 +20257,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
|
|
|
20243
20257
|
replacer: urlReplacer
|
|
20244
20258
|
}));
|
|
20245
20259
|
if (isModule) {
|
|
20246
|
-
postcssPlugins.unshift((await Promise.resolve().then(function () { return require('./dep-
|
|
20260
|
+
postcssPlugins.unshift((await Promise.resolve().then(function () { return require('./dep-1a7759b6.js'); }).then(function (n) { return n.index; })).default({
|
|
20247
20261
|
...modulesOptions,
|
|
20248
20262
|
getJSON(cssFileName, _modules, outputFileName) {
|
|
20249
20263
|
modules = _modules;
|
|
@@ -21208,7 +21222,7 @@ const assetAttrsConfig = {
|
|
|
21208
21222
|
const isAsyncScriptMap = new WeakMap();
|
|
21209
21223
|
async function traverseHtml(html, filePath, visitor) {
|
|
21210
21224
|
// lazy load compiler
|
|
21211
|
-
const { parse, transform } = await Promise.resolve().then(function () { return require('./dep-
|
|
21225
|
+
const { parse, transform } = await Promise.resolve().then(function () { return require('./dep-93e144c8.js'); }).then(function (n) { return n.compilerDom_cjs; });
|
|
21212
21226
|
// @vue/compiler-core doesn't like lowercase doctypes
|
|
21213
21227
|
html = html.replace(/<!doctype\s/i, '<!DOCTYPE ');
|
|
21214
21228
|
try {
|
|
@@ -29964,16 +29978,10 @@ function tryFsResolve(fsPath, options, preserveSymlinks, tryIndex = true, target
|
|
|
29964
29978
|
}
|
|
29965
29979
|
}
|
|
29966
29980
|
function tryResolveFile(file, postfix, options, tryIndex, targetWeb, preserveSymlinks, tryPrefix, skipPackageJson) {
|
|
29967
|
-
|
|
29968
|
-
|
|
29969
|
-
|
|
29970
|
-
|
|
29971
|
-
// unnecessary in the first place)
|
|
29972
|
-
fs__default.accessSync(file, fs__default.constants.R_OK);
|
|
29973
|
-
isReadable = true;
|
|
29974
|
-
}
|
|
29975
|
-
catch (e) { }
|
|
29976
|
-
if (isReadable) {
|
|
29981
|
+
// #2051 if we don't have read permission on a directory, existsSync() still
|
|
29982
|
+
// works and will result in massively slow subsequent checks (which are
|
|
29983
|
+
// unnecessary in the first place)
|
|
29984
|
+
if (isFileReadable(file)) {
|
|
29977
29985
|
if (!fs__default.statSync(file).isDirectory()) {
|
|
29978
29986
|
return getRealPath(file, preserveSymlinks) + postfix;
|
|
29979
29987
|
}
|
|
@@ -42060,36 +42068,11 @@ function errorMiddleware(server, allowNext = false) {
|
|
|
42060
42068
|
next();
|
|
42061
42069
|
}
|
|
42062
42070
|
else {
|
|
42063
|
-
if (err instanceof AccessRestrictedError) {
|
|
42064
|
-
res.statusCode = 403;
|
|
42065
|
-
res.write(renderErrorHTML(err.message));
|
|
42066
|
-
res.end();
|
|
42067
|
-
}
|
|
42068
42071
|
res.statusCode = 500;
|
|
42069
42072
|
res.end();
|
|
42070
42073
|
}
|
|
42071
42074
|
};
|
|
42072
42075
|
}
|
|
42073
|
-
class AccessRestrictedError extends Error {
|
|
42074
|
-
constructor(msg) {
|
|
42075
|
-
super(msg);
|
|
42076
|
-
}
|
|
42077
|
-
}
|
|
42078
|
-
function renderErrorHTML(msg) {
|
|
42079
|
-
// to have syntax highlighting and autocompletion in IDE
|
|
42080
|
-
const html = String.raw;
|
|
42081
|
-
return html `
|
|
42082
|
-
<body>
|
|
42083
|
-
<h1>403 Restricted</h1>
|
|
42084
|
-
<p>${msg.replace(/\n/g, '<br/>')}</p>
|
|
42085
|
-
<style>
|
|
42086
|
-
body {
|
|
42087
|
-
padding: 1em 2em;
|
|
42088
|
-
}
|
|
42089
|
-
</style>
|
|
42090
|
-
</body>
|
|
42091
|
-
`;
|
|
42092
|
-
}
|
|
42093
42076
|
|
|
42094
42077
|
/**
|
|
42095
42078
|
* This file is refactored into TypeScript based on
|
|
@@ -42877,7 +42860,7 @@ function loadFallbackPlugin() {
|
|
|
42877
42860
|
name: 'vite:load-fallback',
|
|
42878
42861
|
async load(id) {
|
|
42879
42862
|
try {
|
|
42880
|
-
return fs$r.promises.readFile(cleanUrl(id), 'utf-8');
|
|
42863
|
+
return await fs$r.promises.readFile(cleanUrl(id), 'utf-8');
|
|
42881
42864
|
}
|
|
42882
42865
|
catch (e) {
|
|
42883
42866
|
return fs$r.promises.readFile(id, 'utf-8');
|
|
@@ -43041,6 +43024,7 @@ async function doBuild(inlineConfig = {}) {
|
|
|
43041
43024
|
const rollup = require('rollup');
|
|
43042
43025
|
const rollupOptions = {
|
|
43043
43026
|
input,
|
|
43027
|
+
context: 'globalThis',
|
|
43044
43028
|
preserveEntrySignatures: ssr
|
|
43045
43029
|
? 'allow-extension'
|
|
43046
43030
|
: libOptions
|
|
@@ -49054,7 +49038,7 @@ function readFileIfExists(value) {
|
|
|
49054
49038
|
* https://github.com/webpack/webpack-dev-server/blob/master/LICENSE
|
|
49055
49039
|
*/
|
|
49056
49040
|
async function createCertificate() {
|
|
49057
|
-
const { generate } = await Promise.resolve().then(function () { return require('./dep-
|
|
49041
|
+
const { generate } = await Promise.resolve().then(function () { return require('./dep-724b1c48.js'); }).then(function (n) { return n.index; });
|
|
49058
49042
|
const pems = generate(null, {
|
|
49059
49043
|
algorithm: 'sha256',
|
|
49060
49044
|
days: 30,
|
|
@@ -56147,6 +56131,14 @@ function walk(root, { onIdentifier, onImportMeta, onDynamicImport }) {
|
|
|
56147
56131
|
}
|
|
56148
56132
|
}
|
|
56149
56133
|
else if (isFunction(node)) {
|
|
56134
|
+
// If it is a function declaration, it could be shadowing an import
|
|
56135
|
+
// Add its name to the scope so it won't get replaced
|
|
56136
|
+
if (node.type === 'FunctionDeclaration') {
|
|
56137
|
+
const parentFunction = findParentFunction(parentStack);
|
|
56138
|
+
if (parentFunction) {
|
|
56139
|
+
setScope(parentFunction, node.id.name);
|
|
56140
|
+
}
|
|
56141
|
+
}
|
|
56150
56142
|
// walk function expressions and add its arguments to known identifiers
|
|
56151
56143
|
// so that we don't prefix them
|
|
56152
56144
|
node.params.forEach((p) => walk$1(p.type === 'AssignmentPattern' ? p.left : p, {
|
|
@@ -56568,22 +56560,24 @@ function servePublicMiddleware(dir) {
|
|
|
56568
56560
|
serve(req, res, next);
|
|
56569
56561
|
};
|
|
56570
56562
|
}
|
|
56571
|
-
function serveStaticMiddleware(dir,
|
|
56563
|
+
function serveStaticMiddleware(dir, server) {
|
|
56572
56564
|
const serve = sirv(dir, sirvOptions);
|
|
56573
56565
|
// Keep the named function. The name is visible in debug logs via `DEBUG=connect:dispatcher ...`
|
|
56574
56566
|
return function viteServeStaticMiddleware(req, res, next) {
|
|
56575
|
-
// only serve the file if it's not an html request
|
|
56567
|
+
// only serve the file if it's not an html request or ends with `/`
|
|
56576
56568
|
// so that html requests can fallthrough to our html middleware for
|
|
56577
56569
|
// special processing
|
|
56578
56570
|
// also skip internal requests `/@fs/ /@vite-client` etc...
|
|
56579
|
-
|
|
56571
|
+
const cleanedUrl = cleanUrl(req.url);
|
|
56572
|
+
if (cleanedUrl.endsWith('/') ||
|
|
56573
|
+
path__default.extname(cleanedUrl) === '.html' ||
|
|
56580
56574
|
isInternalRequest(req.url)) {
|
|
56581
56575
|
return next();
|
|
56582
56576
|
}
|
|
56583
56577
|
const url = decodeURI(req.url);
|
|
56584
56578
|
// apply aliases to static requests as well
|
|
56585
56579
|
let redirected;
|
|
56586
|
-
for (const { find, replacement } of config.resolve.alias) {
|
|
56580
|
+
for (const { find, replacement } of server.config.resolve.alias) {
|
|
56587
56581
|
const matches = typeof find === 'string' ? url.startsWith(find) : find.test(url);
|
|
56588
56582
|
if (matches) {
|
|
56589
56583
|
redirected = url.replace(find, replacement);
|
|
@@ -56595,6 +56589,16 @@ function serveStaticMiddleware(dir, config) {
|
|
|
56595
56589
|
if (redirected.startsWith(dir)) {
|
|
56596
56590
|
redirected = redirected.slice(dir.length);
|
|
56597
56591
|
}
|
|
56592
|
+
}
|
|
56593
|
+
const resolvedUrl = redirected || url;
|
|
56594
|
+
let fileUrl = path__default.resolve(dir, resolvedUrl.replace(/^\//, ''));
|
|
56595
|
+
if (resolvedUrl.endsWith('/') && !fileUrl.endsWith('/')) {
|
|
56596
|
+
fileUrl = fileUrl + '/';
|
|
56597
|
+
}
|
|
56598
|
+
if (!ensureServingAccess(fileUrl, server, res, next)) {
|
|
56599
|
+
return;
|
|
56600
|
+
}
|
|
56601
|
+
if (redirected) {
|
|
56598
56602
|
req.url = redirected;
|
|
56599
56603
|
}
|
|
56600
56604
|
serve(req, res, next);
|
|
@@ -56611,7 +56615,9 @@ function serveRawFsMiddleware(server) {
|
|
|
56611
56615
|
// searching based from fs root.
|
|
56612
56616
|
if (url.startsWith(FS_PREFIX)) {
|
|
56613
56617
|
// restrict files outside of `fs.allow`
|
|
56614
|
-
ensureServingAccess(slash$3(path__default.resolve(fsPathFromId(url))), server)
|
|
56618
|
+
if (!ensureServingAccess(slash$3(path__default.resolve(fsPathFromId(url))), server, res, next)) {
|
|
56619
|
+
return;
|
|
56620
|
+
}
|
|
56615
56621
|
url = url.slice(FS_PREFIX.length);
|
|
56616
56622
|
if (isWindows$4)
|
|
56617
56623
|
url = url.replace(/^[A-Z]:/i, '');
|
|
@@ -56627,29 +56633,60 @@ function isFileServingAllowed(url, server) {
|
|
|
56627
56633
|
// explicitly disabled
|
|
56628
56634
|
if (server.config.server.fs.strict === false)
|
|
56629
56635
|
return true;
|
|
56630
|
-
const
|
|
56636
|
+
const cleanedUrl = cleanUrl(url);
|
|
56637
|
+
const file = ensureLeadingSlash(normalizePath$4(cleanedUrl));
|
|
56631
56638
|
if (server.moduleGraph.safeModulesPath.has(file))
|
|
56632
56639
|
return true;
|
|
56633
56640
|
if (server.config.server.fs.allow.some((i) => file.startsWith(i + '/')))
|
|
56634
56641
|
return true;
|
|
56635
56642
|
if (!server.config.server.fs.strict) {
|
|
56636
|
-
|
|
56637
|
-
|
|
56638
|
-
`
|
|
56639
|
-
|
|
56643
|
+
if (isFileReadable(cleanedUrl)) {
|
|
56644
|
+
server.config.logger.warnOnce(`Unrestricted file system access to "${url}"`);
|
|
56645
|
+
server.config.logger.warnOnce(`For security concerns, accessing files outside of serving allow list will ` +
|
|
56646
|
+
`be restricted by default in the future version of Vite. ` +
|
|
56647
|
+
`Refer to https://vitejs.dev/config/#server-fs-allow for more details.`);
|
|
56648
|
+
}
|
|
56640
56649
|
return true;
|
|
56641
56650
|
}
|
|
56642
56651
|
return false;
|
|
56643
56652
|
}
|
|
56644
|
-
function ensureServingAccess(url, server) {
|
|
56645
|
-
if (
|
|
56646
|
-
|
|
56647
|
-
|
|
56648
|
-
|
|
56649
|
-
|
|
56653
|
+
function ensureServingAccess(url, server, res, next) {
|
|
56654
|
+
if (isFileServingAllowed(url, server)) {
|
|
56655
|
+
return true;
|
|
56656
|
+
}
|
|
56657
|
+
if (isFileReadable(cleanUrl(url))) {
|
|
56658
|
+
const urlMessage = `The request url "${url}" is outside of Vite serving allow list.`;
|
|
56659
|
+
const hintMessage = `
|
|
56660
|
+
${server.config.server.fs.allow.map((i) => `- ${i}`).join('\n')}
|
|
56650
56661
|
|
|
56651
|
-
Refer to docs https://vitejs.dev/config/#server-fs-allow for configurations and more details
|
|
56662
|
+
Refer to docs https://vitejs.dev/config/#server-fs-allow for configurations and more details.`;
|
|
56663
|
+
server.config.logger.error(urlMessage);
|
|
56664
|
+
server.config.logger.warnOnce(hintMessage + '\n');
|
|
56665
|
+
res.statusCode = 403;
|
|
56666
|
+
res.write(renderRestrictedErrorHTML(urlMessage + '\n' + hintMessage));
|
|
56667
|
+
res.end();
|
|
56668
|
+
}
|
|
56669
|
+
else {
|
|
56670
|
+
// if the file doesn't exist, we shouldn't restrict this path as it can
|
|
56671
|
+
// be an API call. Middlewares would issue a 404 if the file isn't handled
|
|
56672
|
+
next();
|
|
56652
56673
|
}
|
|
56674
|
+
return false;
|
|
56675
|
+
}
|
|
56676
|
+
function renderRestrictedErrorHTML(msg) {
|
|
56677
|
+
// to have syntax highlighting and autocompletion in IDE
|
|
56678
|
+
const html = String.raw;
|
|
56679
|
+
return html `
|
|
56680
|
+
<body>
|
|
56681
|
+
<h1>403 Restricted</h1>
|
|
56682
|
+
<p>${msg.replace(/\n/g, '<br/>')}</p>
|
|
56683
|
+
<style>
|
|
56684
|
+
body {
|
|
56685
|
+
padding: 1em 2em;
|
|
56686
|
+
}
|
|
56687
|
+
</style>
|
|
56688
|
+
</body>
|
|
56689
|
+
`;
|
|
56653
56690
|
}
|
|
56654
56691
|
|
|
56655
56692
|
const debugLoad = createDebugger('vite:load');
|
|
@@ -66618,10 +66655,7 @@ const ROOT_FILES = [
|
|
|
66618
66655
|
// yarn: https://classic.yarnpkg.com/en/docs/workspaces/#toc-how-to-use-it
|
|
66619
66656
|
function hasWorkspacePackageJSON(root) {
|
|
66620
66657
|
const path = path$t.join(root, 'package.json');
|
|
66621
|
-
|
|
66622
|
-
fs__default.accessSync(path, fs__default.constants.R_OK);
|
|
66623
|
-
}
|
|
66624
|
-
catch {
|
|
66658
|
+
if (!isFileReadable(path)) {
|
|
66625
66659
|
return false;
|
|
66626
66660
|
}
|
|
66627
66661
|
const content = JSON.parse(fs__default.readFileSync(path, 'utf-8')) || {};
|
|
@@ -66839,7 +66873,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
66839
66873
|
middlewares.use(transformMiddleware(server));
|
|
66840
66874
|
// serve static files
|
|
66841
66875
|
middlewares.use(serveRawFsMiddleware(server));
|
|
66842
|
-
middlewares.use(serveStaticMiddleware(root,
|
|
66876
|
+
middlewares.use(serveStaticMiddleware(root, server));
|
|
66843
66877
|
// spa fallback
|
|
66844
66878
|
if (!middlewareMode || middlewareMode === 'html') {
|
|
66845
66879
|
middlewares.use(spaFallbackMiddleware(root));
|
|
@@ -92052,4 +92086,4 @@ exports.send = send$1;
|
|
|
92052
92086
|
exports.sortUserPlugins = sortUserPlugins;
|
|
92053
92087
|
exports.source = source;
|
|
92054
92088
|
exports.transformWithEsbuild = transformWithEsbuild;
|
|
92055
|
-
//# sourceMappingURL=dep-
|
|
92089
|
+
//# sourceMappingURL=dep-85dbaaa7.js.map
|