vite 2.8.0-beta.0 → 2.8.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.
Potentially problematic release.
This version of vite might be problematic. Click here for more details.
- package/CHANGELOG.md +9 -0
- package/dist/node/chunks/{dep-7cd25957.js → dep-51191982.js} +2 -2
- package/dist/node/chunks/{dep-7cd25957.js.map → dep-51191982.js.map} +1 -1
- package/dist/node/chunks/{dep-372aad6a.js → dep-e4a9e288.js} +2 -2
- package/dist/node/chunks/{dep-372aad6a.js.map → dep-e4a9e288.js.map} +1 -1
- package/dist/node/chunks/{dep-5ad1713b.js → dep-e4dc9ea2.js} +122 -48
- package/dist/node/chunks/dep-e4dc9ea2.js.map +1 -0
- package/dist/node/chunks/{dep-920a704a.js → dep-fccf00e1.js} +2 -2
- package/dist/node/chunks/{dep-920a704a.js.map → dep-fccf00e1.js.map} +1 -1
- package/dist/node/cli.js +4 -4
- package/dist/node/config.d.ts +7 -1
- package/dist/node/index.d.ts +8 -1
- package/dist/node/index.js +1 -1
- package/dist/node/plugins/css.d.ts +2 -1
- package/dist/node/plugins/html.d.ts +4 -2
- package/dist/node/plugins/worker.d.ts +2 -0
- package/dist/node/plugins/workerImportMetaUrl.d.ts +3 -0
- package/package.json +1 -1
- package/dist/node/chunks/dep-5ad1713b.js.map +0 -1
|
@@ -18916,7 +18916,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
|
|
|
18916
18916
|
replacer: urlReplacer
|
|
18917
18917
|
}));
|
|
18918
18918
|
if (isModule) {
|
|
18919
|
-
postcssPlugins.unshift((await Promise.resolve().then(function () { return require('./dep-
|
|
18919
|
+
postcssPlugins.unshift((await Promise.resolve().then(function () { return require('./dep-e4a9e288.js'); }).then(function (n) { return n.index; })).default({
|
|
18920
18920
|
...modulesOptions,
|
|
18921
18921
|
getJSON(cssFileName, _modules, outputFileName) {
|
|
18922
18922
|
modules = _modules;
|
|
@@ -19939,7 +19939,7 @@ const assetAttrsConfig = {
|
|
|
19939
19939
|
const isAsyncScriptMap = new WeakMap();
|
|
19940
19940
|
async function traverseHtml(html, filePath, visitor) {
|
|
19941
19941
|
// lazy load compiler
|
|
19942
|
-
const { parse, transform } = await Promise.resolve().then(function () { return require('./dep-
|
|
19942
|
+
const { parse, transform } = await Promise.resolve().then(function () { return require('./dep-51191982.js'); }).then(function (n) { return n.compilerDom_cjs; });
|
|
19943
19943
|
// @vue/compiler-core doesn't like lowercase doctypes
|
|
19944
19944
|
html = html.replace(/<!doctype\s/i, '<!DOCTYPE ');
|
|
19945
19945
|
try {
|
|
@@ -44442,7 +44442,7 @@ function readFileIfExists(value) {
|
|
|
44442
44442
|
return value;
|
|
44443
44443
|
}
|
|
44444
44444
|
async function createCertificateLazily() {
|
|
44445
|
-
const { createCertificate } = await Promise.resolve().then(function () { return require('./dep-
|
|
44445
|
+
const { createCertificate } = await Promise.resolve().then(function () { return require('./dep-fccf00e1.js'); });
|
|
44446
44446
|
return createCertificate();
|
|
44447
44447
|
}
|
|
44448
44448
|
async function getCertificate(cacheDir) {
|
|
@@ -69652,14 +69652,34 @@ export default opts => initWasm(opts, ${JSON.stringify(url)})
|
|
|
69652
69652
|
};
|
|
69653
69653
|
|
|
69654
69654
|
const WorkerFileId = 'worker_file';
|
|
69655
|
+
async function bundleWorkerEntry(config, id) {
|
|
69656
|
+
// bundle the file as entry to support imports
|
|
69657
|
+
const rollup = require('rollup');
|
|
69658
|
+
const { plugins, rollupOptions, format } = config.worker;
|
|
69659
|
+
const bundle = await rollup.rollup({
|
|
69660
|
+
...rollupOptions,
|
|
69661
|
+
input: cleanUrl(id),
|
|
69662
|
+
plugins,
|
|
69663
|
+
onwarn(warning, warn) {
|
|
69664
|
+
onRollupWarning(warning, warn, config);
|
|
69665
|
+
},
|
|
69666
|
+
preserveEntrySignatures: false
|
|
69667
|
+
});
|
|
69668
|
+
let code;
|
|
69669
|
+
try {
|
|
69670
|
+
const { output } = await bundle.generate({
|
|
69671
|
+
format,
|
|
69672
|
+
sourcemap: config.build.sourcemap
|
|
69673
|
+
});
|
|
69674
|
+
code = output[0].code;
|
|
69675
|
+
}
|
|
69676
|
+
finally {
|
|
69677
|
+
await bundle.close();
|
|
69678
|
+
}
|
|
69679
|
+
return Buffer.from(code);
|
|
69680
|
+
}
|
|
69655
69681
|
function webWorkerPlugin(config) {
|
|
69656
|
-
var _a, _b, _c;
|
|
69657
69682
|
const isBuild = config.command === 'build';
|
|
69658
|
-
const workerBundleOptions = {
|
|
69659
|
-
format: ((_a = config.worker) === null || _a === void 0 ? void 0 : _a.format) || 'iife',
|
|
69660
|
-
plugins: sortUserPlugins((_b = config.worker) === null || _b === void 0 ? void 0 : _b.plugins),
|
|
69661
|
-
rollupOptions: ((_c = config.worker) === null || _c === void 0 ? void 0 : _c.rollupOptions) || {}
|
|
69662
|
-
};
|
|
69663
69683
|
return {
|
|
69664
69684
|
name: 'vite:worker',
|
|
69665
69685
|
load(id) {
|
|
@@ -69686,35 +69706,12 @@ function webWorkerPlugin(config) {
|
|
|
69686
69706
|
}
|
|
69687
69707
|
let url;
|
|
69688
69708
|
if (isBuild) {
|
|
69689
|
-
|
|
69690
|
-
const rollup = require('rollup');
|
|
69691
|
-
const { plugins, rollupOptions, format } = workerBundleOptions;
|
|
69692
|
-
const [prePlugins, normalPlugins, postPlugins] = plugins;
|
|
69693
|
-
const bundle = await rollup.rollup({
|
|
69694
|
-
...rollupOptions,
|
|
69695
|
-
input: cleanUrl(id),
|
|
69696
|
-
plugins: await resolvePlugins({ ...config }, prePlugins, normalPlugins, postPlugins),
|
|
69697
|
-
onwarn(warning, warn) {
|
|
69698
|
-
onRollupWarning(warning, warn, config);
|
|
69699
|
-
},
|
|
69700
|
-
preserveEntrySignatures: false
|
|
69701
|
-
});
|
|
69702
|
-
let code;
|
|
69703
|
-
try {
|
|
69704
|
-
const { output } = await bundle.generate({
|
|
69705
|
-
format,
|
|
69706
|
-
sourcemap: config.build.sourcemap
|
|
69707
|
-
});
|
|
69708
|
-
code = output[0].code;
|
|
69709
|
-
}
|
|
69710
|
-
finally {
|
|
69711
|
-
await bundle.close();
|
|
69712
|
-
}
|
|
69713
|
-
const content = Buffer.from(code);
|
|
69709
|
+
const code = await bundleWorkerEntry(config, id);
|
|
69714
69710
|
if (query.inline != null) {
|
|
69711
|
+
const { format } = config.worker;
|
|
69715
69712
|
const workerOptions = format === 'es' ? '{type: "module"}' : '{}';
|
|
69716
69713
|
// inline as blob data url
|
|
69717
|
-
return `const encodedJs = "${
|
|
69714
|
+
return `const encodedJs = "${code.toString('base64')}";
|
|
69718
69715
|
const blob = typeof window !== "undefined" && window.Blob && new Blob([atob(encodedJs)], { type: "text/javascript;charset=utf-8" });
|
|
69719
69716
|
export default function WorkerWrapper() {
|
|
69720
69717
|
const objURL = blob && (window.URL || window.webkitURL).createObjectURL(blob);
|
|
@@ -69727,7 +69724,7 @@ function webWorkerPlugin(config) {
|
|
|
69727
69724
|
}
|
|
69728
69725
|
else {
|
|
69729
69726
|
const basename = path__default.parse(cleanUrl(id)).name;
|
|
69730
|
-
const contentHash = getAssetHash(
|
|
69727
|
+
const contentHash = getAssetHash(code);
|
|
69731
69728
|
const fileName = path__default.posix.join(config.build.assetsDir, `${basename}.${contentHash}.js`);
|
|
69732
69729
|
url = `__VITE_ASSET__${this.emitFile({
|
|
69733
69730
|
fileName,
|
|
@@ -69869,6 +69866,69 @@ function definePlugin(config) {
|
|
|
69869
69866
|
};
|
|
69870
69867
|
}
|
|
69871
69868
|
|
|
69869
|
+
const WORKER_FILE_ID = 'worker_url_file';
|
|
69870
|
+
function workerImportMetaUrlPlugin(config) {
|
|
69871
|
+
const isBuild = config.command === 'build';
|
|
69872
|
+
return {
|
|
69873
|
+
name: 'vite:worker-import-meta-url',
|
|
69874
|
+
async transform(code, id, options) {
|
|
69875
|
+
const query = parseRequest(id);
|
|
69876
|
+
if (query && query[WORKER_FILE_ID] != null) {
|
|
69877
|
+
return {
|
|
69878
|
+
code: `import '${ENV_PUBLIC_PATH}'\n` + code
|
|
69879
|
+
};
|
|
69880
|
+
}
|
|
69881
|
+
if ((code.includes('new Worker') || code.includes('new ShareWorker')) &&
|
|
69882
|
+
code.includes('new URL') &&
|
|
69883
|
+
code.includes(`import.meta.url`)) {
|
|
69884
|
+
const importMetaUrlRE = /\bnew\s+(Worker|SharedWorker)\s*\(\s*(new\s+URL\s*\(\s*('[^']+'|"[^"]+"|`[^`]+`)\s*,\s*import\.meta\.url\s*\))/g;
|
|
69885
|
+
const noCommentsCode = code
|
|
69886
|
+
.replace(multilineCommentsRE$1, (m) => ' '.repeat(m.length))
|
|
69887
|
+
.replace(singlelineCommentsRE$1, (m) => ' '.repeat(m.length));
|
|
69888
|
+
let match;
|
|
69889
|
+
let s = null;
|
|
69890
|
+
while ((match = importMetaUrlRE.exec(noCommentsCode))) {
|
|
69891
|
+
const { 0: allExp, 2: exp, 3: rawUrl, index } = match;
|
|
69892
|
+
const urlIndex = allExp.indexOf(exp) + index;
|
|
69893
|
+
if (options === null || options === void 0 ? void 0 : options.ssr) {
|
|
69894
|
+
this.error(`\`new URL(url, import.meta.url)\` is not supported in SSR.`, urlIndex);
|
|
69895
|
+
}
|
|
69896
|
+
// potential dynamic template string
|
|
69897
|
+
if (rawUrl[0] === '`' && /\$\{/.test(rawUrl)) {
|
|
69898
|
+
this.error(`\`new URL(url, import.meta.url)\` is not supported in dynamic template string.`, urlIndex);
|
|
69899
|
+
}
|
|
69900
|
+
s || (s = new MagicString(code));
|
|
69901
|
+
const file = path__default.resolve(path__default.dirname(id), rawUrl.slice(1, -1));
|
|
69902
|
+
let url;
|
|
69903
|
+
if (isBuild) {
|
|
69904
|
+
const content = await bundleWorkerEntry(config, file);
|
|
69905
|
+
const basename = path__default.parse(cleanUrl(file)).name;
|
|
69906
|
+
const contentHash = getAssetHash(content);
|
|
69907
|
+
const fileName = path__default.posix.join(config.build.assetsDir, `${basename}.${contentHash}.js`);
|
|
69908
|
+
url = `__VITE_ASSET__${this.emitFile({
|
|
69909
|
+
fileName,
|
|
69910
|
+
type: 'asset',
|
|
69911
|
+
source: content
|
|
69912
|
+
})}__`;
|
|
69913
|
+
}
|
|
69914
|
+
else {
|
|
69915
|
+
url = await fileToUrl(cleanUrl(file), config, this);
|
|
69916
|
+
url = injectQuery(url, WORKER_FILE_ID);
|
|
69917
|
+
}
|
|
69918
|
+
s.overwrite(urlIndex, urlIndex + exp.length, JSON.stringify(url));
|
|
69919
|
+
}
|
|
69920
|
+
if (s) {
|
|
69921
|
+
return {
|
|
69922
|
+
code: s.toString(),
|
|
69923
|
+
map: config.build.sourcemap ? s.generateMap({ hires: true }) : null
|
|
69924
|
+
};
|
|
69925
|
+
}
|
|
69926
|
+
return null;
|
|
69927
|
+
}
|
|
69928
|
+
}
|
|
69929
|
+
};
|
|
69930
|
+
}
|
|
69931
|
+
|
|
69872
69932
|
async function resolvePlugins(config, prePlugins, normalPlugins, postPlugins) {
|
|
69873
69933
|
const isBuild = config.command === 'build';
|
|
69874
69934
|
const buildPlugins = isBuild
|
|
@@ -69899,6 +69959,7 @@ async function resolvePlugins(config, prePlugins, normalPlugins, postPlugins) {
|
|
|
69899
69959
|
}, isBuild),
|
|
69900
69960
|
wasmPlugin(config),
|
|
69901
69961
|
webWorkerPlugin(config),
|
|
69962
|
+
workerImportMetaUrlPlugin(config),
|
|
69902
69963
|
assetPlugin(config),
|
|
69903
69964
|
...normalPlugins,
|
|
69904
69965
|
definePlugin(config),
|
|
@@ -70092,7 +70153,7 @@ function defineConfig(config) {
|
|
|
70092
70153
|
return config;
|
|
70093
70154
|
}
|
|
70094
70155
|
async function resolveConfig(inlineConfig, command, defaultMode = 'development') {
|
|
70095
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
70156
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
70096
70157
|
let config = inlineConfig;
|
|
70097
70158
|
let configFileDependencies = [];
|
|
70098
70159
|
let mode = inlineConfig.mode || defaultMode;
|
|
@@ -70139,6 +70200,12 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
|
|
|
70139
70200
|
}
|
|
70140
70201
|
});
|
|
70141
70202
|
const [prePlugins, normalPlugins, postPlugins] = sortUserPlugins(rawUserPlugins);
|
|
70203
|
+
// resolve worker
|
|
70204
|
+
const resolvedWorkerOptions = {
|
|
70205
|
+
format: ((_a = config.worker) === null || _a === void 0 ? void 0 : _a.format) || 'iife',
|
|
70206
|
+
plugins: [],
|
|
70207
|
+
rollupOptions: ((_b = config.worker) === null || _b === void 0 ? void 0 : _b.rollupOptions) || {}
|
|
70208
|
+
};
|
|
70142
70209
|
// run config hooks
|
|
70143
70210
|
const userPlugins = [...prePlugins, ...normalPlugins, ...postPlugins];
|
|
70144
70211
|
for (const p of userPlugins) {
|
|
@@ -70159,7 +70226,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
|
|
|
70159
70226
|
const resolvedAlias = mergeAlias(
|
|
70160
70227
|
// @ts-ignore because @rollup/plugin-alias' type doesn't allow function
|
|
70161
70228
|
// replacement, but its implementation does work with function values.
|
|
70162
|
-
clientAlias, ((
|
|
70229
|
+
clientAlias, ((_c = config.resolve) === null || _c === void 0 ? void 0 : _c.alias) || config.alias || []);
|
|
70163
70230
|
const resolveOptions = {
|
|
70164
70231
|
dedupe: config.dedupe,
|
|
70165
70232
|
...config.resolve,
|
|
@@ -70268,12 +70335,19 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
|
|
|
70268
70335
|
optimizeDeps: {
|
|
70269
70336
|
...config.optimizeDeps,
|
|
70270
70337
|
esbuildOptions: {
|
|
70271
|
-
keepNames: (
|
|
70272
|
-
preserveSymlinks: (
|
|
70273
|
-
...(
|
|
70338
|
+
keepNames: (_d = config.optimizeDeps) === null || _d === void 0 ? void 0 : _d.keepNames,
|
|
70339
|
+
preserveSymlinks: (_e = config.resolve) === null || _e === void 0 ? void 0 : _e.preserveSymlinks,
|
|
70340
|
+
...(_f = config.optimizeDeps) === null || _f === void 0 ? void 0 : _f.esbuildOptions
|
|
70274
70341
|
}
|
|
70275
|
-
}
|
|
70342
|
+
},
|
|
70343
|
+
worker: resolvedWorkerOptions
|
|
70276
70344
|
};
|
|
70345
|
+
// flat config.worker.plugin
|
|
70346
|
+
const [workerPrePlugins, workerNormalPlugins, workerPostPlugins] = sortUserPlugins((_g = config.worker) === null || _g === void 0 ? void 0 : _g.plugins);
|
|
70347
|
+
const workerResolved = { ...resolved };
|
|
70348
|
+
resolved.worker.plugins = await resolvePlugins(workerResolved, workerPrePlugins, workerNormalPlugins, workerPostPlugins);
|
|
70349
|
+
// call configResolved worker plugins hooks
|
|
70350
|
+
await Promise.all(resolved.worker.plugins.map((p) => { var _a; return (_a = p.configResolved) === null || _a === void 0 ? void 0 : _a.call(p, workerResolved); }));
|
|
70277
70351
|
resolved.plugins = await resolvePlugins(resolved, prePlugins, normalPlugins, postPlugins);
|
|
70278
70352
|
// call configResolved hooks
|
|
70279
70353
|
await Promise.all(userPlugins.map((p) => { var _a; return (_a = p.configResolved) === null || _a === void 0 ? void 0 : _a.call(p, resolved); }));
|
|
@@ -70287,7 +70361,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
|
|
|
70287
70361
|
const logDeprecationWarning = (deprecatedOption, hint, error) => {
|
|
70288
70362
|
logger.warn(colors$1.yellow(colors$1.bold(`(!) "${deprecatedOption}" option is deprecated. ${hint}${error ? `\n${error.stack}` : ''}`)));
|
|
70289
70363
|
};
|
|
70290
|
-
if ((
|
|
70364
|
+
if ((_h = config.build) === null || _h === void 0 ? void 0 : _h.base) {
|
|
70291
70365
|
logDeprecationWarning('build.base', '"base" is now a root-level config option.');
|
|
70292
70366
|
config.base = config.build.base;
|
|
70293
70367
|
}
|
|
@@ -70318,7 +70392,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
|
|
|
70318
70392
|
return resolved.resolve.dedupe;
|
|
70319
70393
|
}
|
|
70320
70394
|
});
|
|
70321
|
-
if ((
|
|
70395
|
+
if ((_j = config.optimizeDeps) === null || _j === void 0 ? void 0 : _j.keepNames) {
|
|
70322
70396
|
logDeprecationWarning('optimizeDeps.keepNames', 'Use "optimizeDeps.esbuildOptions.keepNames" instead.');
|
|
70323
70397
|
}
|
|
70324
70398
|
Object.defineProperty(resolved.optimizeDeps, 'keepNames', {
|
|
@@ -70329,7 +70403,7 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
|
|
|
70329
70403
|
return (_a = resolved.optimizeDeps.esbuildOptions) === null || _a === void 0 ? void 0 : _a.keepNames;
|
|
70330
70404
|
}
|
|
70331
70405
|
});
|
|
70332
|
-
if ((
|
|
70406
|
+
if ((_k = config.build) === null || _k === void 0 ? void 0 : _k.polyfillDynamicImport) {
|
|
70333
70407
|
logDeprecationWarning('build.polyfillDynamicImport', '"polyfillDynamicImport" has been removed. Please use @vitejs/plugin-legacy if your target browsers do not support dynamic imports.');
|
|
70334
70408
|
}
|
|
70335
70409
|
Object.defineProperty(resolvedBuildOptions, 'polyfillDynamicImport', {
|
|
@@ -70339,10 +70413,10 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
|
|
|
70339
70413
|
return false;
|
|
70340
70414
|
}
|
|
70341
70415
|
});
|
|
70342
|
-
if ((
|
|
70416
|
+
if ((_l = config.build) === null || _l === void 0 ? void 0 : _l.cleanCssOptions) {
|
|
70343
70417
|
logDeprecationWarning('build.cleanCssOptions', 'Vite now uses esbuild for CSS minification.');
|
|
70344
70418
|
}
|
|
70345
|
-
if (((
|
|
70419
|
+
if (((_m = config.build) === null || _m === void 0 ? void 0 : _m.terserOptions) && config.build.minify === 'esbuild') {
|
|
70346
70420
|
logger.warn(colors$1.yellow(`build.terserOptions is specified but build.minify is not set to use Terser. ` +
|
|
70347
70421
|
`Note Vite now defaults to use esbuild for minification. If you still ` +
|
|
70348
70422
|
`prefer Terser, set build.minify to "terser".`));
|
|
@@ -70713,4 +70787,4 @@ exports.searchForWorkspaceRoot = searchForWorkspaceRoot;
|
|
|
70713
70787
|
exports.send = send$1;
|
|
70714
70788
|
exports.sortUserPlugins = sortUserPlugins;
|
|
70715
70789
|
exports.transformWithEsbuild = transformWithEsbuild;
|
|
70716
|
-
//# sourceMappingURL=dep-
|
|
70790
|
+
//# sourceMappingURL=dep-e4dc9ea2.js.map
|