vite 2.7.0-beta.6 → 2.7.0-beta.7

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 CHANGED
@@ -1,3 +1,14 @@
1
+ # [2.7.0-beta.7](https://github.com/vitejs/vite/compare/v2.7.0-beta.6...v2.7.0-beta.7) (2021-11-17)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **build:** keep IIFE name after minifying (fix [#5490](https://github.com/vitejs/vite/issues/5490)) ([#5715](https://github.com/vitejs/vite/issues/5715)) ([1544211](https://github.com/vitejs/vite/commit/1544211767695982597c18d028a2edf15372931f))
7
+ * **scan:** correctly resolve virtual modules ([#5711](https://github.com/vitejs/vite/issues/5711)) ([01f9b16](https://github.com/vitejs/vite/commit/01f9b16a8bdfa182890924ac00207fe54496b99f))
8
+ * **ssr:** skip dedupe require in esm ([#5714](https://github.com/vitejs/vite/issues/5714)) ([9666446](https://github.com/vitejs/vite/commit/96664469e49d44f8c628bf0310bdd03d1c4556de))
9
+
10
+
11
+
1
12
  # [2.7.0-beta.6](https://github.com/vitejs/vite/compare/v2.7.0-beta.5...v2.7.0-beta.6) (2021-11-16)
2
13
 
3
14
 
@@ -3958,7 +3958,8 @@ const externalRE = /^(https?:)?\/\//;
3958
3958
  const isExternalUrl = (url) => externalRE.test(url);
3959
3959
  const dataUrlRE = /^\s*data:/i;
3960
3960
  const isDataUrl = (url) => dataUrlRE.test(url);
3961
- const virtualModuleRE = /virtual-module:.*/;
3961
+ const virtualModuleRE = /^virtual-module:.*/;
3962
+ const virtualModulePrefix = 'virtual-module:';
3962
3963
  const knownJsSrcRE = /\.((j|t)sx?|mjs|vue|marko|svelte|astro)($|\?)/;
3963
3964
  const isJSRequest = (url) => {
3964
3965
  url = cleanUrl(url);
@@ -20385,7 +20386,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
20385
20386
  replacer: urlReplacer
20386
20387
  }));
20387
20388
  if (isModule) {
20388
- postcssPlugins.unshift((await Promise.resolve().then(function () { return require('./dep-48461e78.js'); }).then(function (n) { return n.index; })).default({
20389
+ postcssPlugins.unshift((await Promise.resolve().then(function () { return require('./dep-707302f6.js'); }).then(function (n) { return n.index; })).default({
20389
20390
  ...modulesOptions,
20390
20391
  getJSON(cssFileName, _modules, outputFileName) {
20391
20392
  modules = _modules;
@@ -21350,7 +21351,7 @@ const assetAttrsConfig = {
21350
21351
  const isAsyncScriptMap = new WeakMap();
21351
21352
  async function traverseHtml(html, filePath, visitor) {
21352
21353
  // lazy load compiler
21353
- const { parse, transform } = await Promise.resolve().then(function () { return require('./dep-1b2328e8.js'); }).then(function (n) { return n.compilerDom_cjs; });
21354
+ const { parse, transform } = await Promise.resolve().then(function () { return require('./dep-9a51c06c.js'); }).then(function (n) { return n.compilerDom_cjs; });
21354
21355
  // @vue/compiler-core doesn't like lowercase doctypes
21355
21356
  html = html.replace(/<!doctype\s/i, '<!DOCTYPE ');
21356
21357
  try {
@@ -22434,7 +22435,15 @@ function esbuildPlugin(options = {}) {
22434
22435
  const rollupToEsbuildFormatMap = {
22435
22436
  es: 'esm',
22436
22437
  cjs: 'cjs',
22437
- iife: 'iife'
22438
+ // passing `var Lib = (() => {})()` to esbuild with format = "iife"
22439
+ // will turn it to `(() => { var Lib = (() => {})() })()`,
22440
+ // so we remove the format config to tell esbuild not doing this
22441
+ //
22442
+ // although esbuild doesn't change format, there is still possibility
22443
+ // that `{ treeShaking: true }` removes a top-level no-side-effect variable
22444
+ // like: `var Lib = 1`, which becomes `` after esbuild transforming,
22445
+ // but thankfully rollup does not do this optimization now
22446
+ iife: undefined
22438
22447
  };
22439
22448
  const buildEsbuildPlugin = (config) => {
22440
22449
  return {
@@ -42809,7 +42818,7 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
42809
42818
  return {
42810
42819
  name: 'vite:dep-scan',
42811
42820
  setup(build) {
42812
- const moduleScripts = {};
42821
+ const localScripts = {};
42813
42822
  // external urls
42814
42823
  build.onResolve({ filter: externalRE }, ({ path }) => ({
42815
42824
  path,
@@ -42820,12 +42829,17 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
42820
42829
  path,
42821
42830
  external: true
42822
42831
  }));
42823
- build.onResolve({ filter: virtualModuleRE }, async ({ path, importer }) => {
42832
+ // local scripts (`<script>` in Svelte and `<script setup>` in Vue)
42833
+ build.onResolve({ filter: virtualModuleRE }, ({ path }) => {
42824
42834
  return {
42825
- path: await resolve(path.substring('virtual-module:'.length), importer),
42826
- namespace: 'html'
42835
+ // strip prefix to get valid filesystem path so esbuild can resolve imports in the file
42836
+ path: path.replace(virtualModulePrefix, ''),
42837
+ namespace: 'local-script'
42827
42838
  };
42828
42839
  });
42840
+ build.onLoad({ filter: /.*/, namespace: 'local-script' }, ({ path }) => {
42841
+ return localScripts[path];
42842
+ });
42829
42843
  // html types: extract script contents -----------------------------------
42830
42844
  build.onResolve({ filter: htmlTypesRE }, async ({ path, importer }) => {
42831
42845
  return {
@@ -42833,9 +42847,6 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
42833
42847
  namespace: 'html'
42834
42848
  };
42835
42849
  });
42836
- build.onLoad({ filter: virtualModuleRE, namespace: 'html' }, async ({ path }) => {
42837
- return moduleScripts[path];
42838
- });
42839
42850
  // extract scripts inside HTML-like files and treat it as a js module
42840
42851
  build.onLoad({ filter: htmlTypesRE, namespace: 'html' }, async ({ path }) => {
42841
42852
  let raw = fs__default.readFileSync(path, 'utf-8');
@@ -42877,12 +42888,11 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
42877
42888
  (contextMatch[1] || contextMatch[2] || contextMatch[3]);
42878
42889
  if ((path.endsWith('.vue') && setupRE.test(raw)) ||
42879
42890
  (path.endsWith('.svelte') && context !== 'module')) {
42880
- const id = `virtual-module:${path}`;
42881
- moduleScripts[id] = {
42891
+ localScripts[path] = {
42882
42892
  loader,
42883
42893
  contents: content
42884
42894
  };
42885
- js += `import '${id}';\n`;
42895
+ js += `import '${virtualModulePrefix}${path}';\n`;
42886
42896
  }
42887
42897
  else {
42888
42898
  js += content + '\n';
@@ -43202,9 +43212,12 @@ function resolveBuildOptions(root, raw) {
43202
43212
  let input;
43203
43213
  if ((_a = raw === null || raw === void 0 ? void 0 : raw.rollupOptions) === null || _a === void 0 ? void 0 : _a.input) {
43204
43214
  input = Array.isArray(raw.rollupOptions.input)
43205
- ? raw.rollupOptions.input.map(input => resolve(input))
43215
+ ? raw.rollupOptions.input.map((input) => resolve(input))
43206
43216
  : typeof raw.rollupOptions.input === 'object'
43207
- ? Object.fromEntries(Object.entries(raw.rollupOptions.input).map(([key, value]) => [key, resolve(value)]))
43217
+ ? Object.fromEntries(Object.entries(raw.rollupOptions.input).map(([key, value]) => [
43218
+ key,
43219
+ resolve(value)
43220
+ ]))
43208
43221
  : resolve(raw.rollupOptions.input);
43209
43222
  }
43210
43223
  else {
@@ -49362,7 +49375,7 @@ function readFileIfExists(value) {
49362
49375
  * https://github.com/webpack/webpack-dev-server/blob/master/LICENSE
49363
49376
  */
49364
49377
  async function createCertificate() {
49365
- const { generate } = await Promise.resolve().then(function () { return require('./dep-146e2d5f.js'); }).then(function (n) { return n.index; });
49378
+ const { generate } = await Promise.resolve().then(function () { return require('./dep-606d0866.js'); }).then(function (n) { return n.index; });
49366
49379
  const pems = generate(null, {
49367
49380
  algorithm: 'sha256',
49368
49381
  days: 30,
@@ -66996,7 +67009,9 @@ function rebindErrorStacktrace(e, stacktrace) {
66996
67009
  */
66997
67010
  function ssrRequireHookPlugin(config) {
66998
67011
  var _a;
66999
- if (config.command !== 'build' || !((_a = config.resolve.dedupe) === null || _a === void 0 ? void 0 : _a.length)) {
67012
+ if (config.command !== 'build' ||
67013
+ !((_a = config.resolve.dedupe) === null || _a === void 0 ? void 0 : _a.length) ||
67014
+ isBuildOutputEsm(config)) {
67000
67015
  return null;
67001
67016
  }
67002
67017
  return {
@@ -67040,6 +67055,11 @@ function hookNodeResolve(getResolver) {
67040
67055
  Module._resolveFilename = prevResolver;
67041
67056
  };
67042
67057
  }
67058
+ function isBuildOutputEsm(config) {
67059
+ var _a;
67060
+ const outputs = arraify((_a = config.build.rollupOptions) === null || _a === void 0 ? void 0 : _a.output);
67061
+ return outputs.some((output) => (output === null || output === void 0 ? void 0 : output.format) === 'es' || (output === null || output === void 0 ? void 0 : output.format) === 'esm');
67062
+ }
67043
67063
 
67044
67064
  const pendingModules = new Map();
67045
67065
  const pendingImports = new Map();
@@ -82219,4 +82239,4 @@ exports.send = send$1;
82219
82239
  exports.sortUserPlugins = sortUserPlugins;
82220
82240
  exports.source = source;
82221
82241
  exports.transformWithEsbuild = transformWithEsbuild;
82222
- //# sourceMappingURL=dep-0183a921.js.map
82242
+ //# sourceMappingURL=dep-56ab4c22.js.map