vite 2.6.6 → 2.6.10

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 (82) hide show
  1. package/dist/node/chunks/{dep-8fc3d0a8.js → dep-8e7741a0.js} +2 -2
  2. package/dist/node/chunks/{dep-8fc3d0a8.js.map → dep-8e7741a0.js.map} +1 -1
  3. package/dist/node/chunks/{dep-6a58f2f7.js → dep-9b6b378f.js} +2 -2
  4. package/dist/node/chunks/{dep-6a58f2f7.js.map → dep-9b6b378f.js.map} +1 -1
  5. package/dist/node/chunks/{dep-da8087f5.js → dep-b502d052.js} +2 -2
  6. package/dist/node/chunks/{dep-da8087f5.js.map → dep-b502d052.js.map} +1 -1
  7. package/dist/node/chunks/{dep-713b45e1.js → dep-be032392.js} +59 -27
  8. package/dist/node/chunks/dep-be032392.js.map +1 -0
  9. package/dist/node/cli.js +4 -4
  10. package/dist/node/index.d.ts +517 -2
  11. package/dist/node/index.js +1 -1
  12. package/package.json +6 -6
  13. package/types/ws.d.ts +532 -0
  14. package/CHANGELOG.md +0 -2265
  15. package/dist/client/client.d.ts +0 -17
  16. package/dist/client/env.d.ts +0 -4
  17. package/dist/client/overlay.d.ts +0 -8
  18. package/dist/node/build.d.ts +0 -191
  19. package/dist/node/chunks/dep-1ee92c88.js +0 -10031
  20. package/dist/node/chunks/dep-1ee92c88.js.map +0 -1
  21. package/dist/node/chunks/dep-51d7aa64.js +0 -10032
  22. package/dist/node/chunks/dep-51d7aa64.js.map +0 -1
  23. package/dist/node/chunks/dep-713b45e1.js.map +0 -1
  24. package/dist/node/chunks/dep-e5804462.js +0 -10032
  25. package/dist/node/chunks/dep-e5804462.js.map +0 -1
  26. package/dist/node/cli.d.ts +0 -1
  27. package/dist/node/config.d.ts +0 -193
  28. package/dist/node/constants.d.ts +0 -27
  29. package/dist/node/importGlob.d.ts +0 -9
  30. package/dist/node/logger.d.ts +0 -28
  31. package/dist/node/optimizer/esbuildDepPlugin.d.ts +0 -4
  32. package/dist/node/optimizer/index.d.ts +0 -66
  33. package/dist/node/optimizer/registerMissing.d.ts +0 -2
  34. package/dist/node/optimizer/scan.d.ts +0 -9
  35. package/dist/node/plugin.d.ts +0 -110
  36. package/dist/node/plugins/asset.d.ts +0 -40
  37. package/dist/node/plugins/assetImportMetaUrl.d.ts +0 -13
  38. package/dist/node/plugins/clientInjections.d.ts +0 -7
  39. package/dist/node/plugins/css.d.ts +0 -68
  40. package/dist/node/plugins/dataUri.d.ts +0 -5
  41. package/dist/node/plugins/define.d.ts +0 -3
  42. package/dist/node/plugins/esbuild.d.ts +0 -15
  43. package/dist/node/plugins/html.d.ts +0 -74
  44. package/dist/node/plugins/importAnalysis.d.ts +0 -32
  45. package/dist/node/plugins/importAnalysisBuild.d.ts +0 -15
  46. package/dist/node/plugins/index.d.ts +0 -3
  47. package/dist/node/plugins/json.d.ts +0 -22
  48. package/dist/node/plugins/loadFallback.d.ts +0 -5
  49. package/dist/node/plugins/manifest.d.ts +0 -14
  50. package/dist/node/plugins/modulePreloadPolyfill.d.ts +0 -4
  51. package/dist/node/plugins/preAlias.d.ts +0 -5
  52. package/dist/node/plugins/reporter.d.ts +0 -3
  53. package/dist/node/plugins/resolve.d.ts +0 -51
  54. package/dist/node/plugins/terser.d.ts +0 -3
  55. package/dist/node/plugins/wasm.d.ts +0 -3
  56. package/dist/node/plugins/worker.d.ts +0 -3
  57. package/dist/node/preview.d.ts +0 -2
  58. package/dist/node/server/hmr.d.ts +0 -37
  59. package/dist/node/server/http.d.ts +0 -14
  60. package/dist/node/server/index.d.ts +0 -235
  61. package/dist/node/server/middlewares/base.d.ts +0 -3
  62. package/dist/node/server/middlewares/error.d.ts +0 -11
  63. package/dist/node/server/middlewares/indexHtml.d.ts +0 -4
  64. package/dist/node/server/middlewares/proxy.d.ts +0 -20
  65. package/dist/node/server/middlewares/spaFallback.d.ts +0 -2
  66. package/dist/node/server/middlewares/static.d.ts +0 -7
  67. package/dist/node/server/middlewares/time.d.ts +0 -2
  68. package/dist/node/server/middlewares/transform.d.ts +0 -3
  69. package/dist/node/server/moduleGraph.d.ts +0 -46
  70. package/dist/node/server/openBrowser.d.ts +0 -15
  71. package/dist/node/server/pluginContainer.d.ts +0 -27
  72. package/dist/node/server/searchRoot.d.ts +0 -8
  73. package/dist/node/server/send.d.ts +0 -4
  74. package/dist/node/server/sourcemap.d.ts +0 -8
  75. package/dist/node/server/transformRequest.d.ts +0 -14
  76. package/dist/node/server/ws.d.ts +0 -11
  77. package/dist/node/ssr/ssrExternal.d.ts +0 -10
  78. package/dist/node/ssr/ssrManifestPlugin.d.ts +0 -3
  79. package/dist/node/ssr/ssrModuleLoader.d.ts +0 -8
  80. package/dist/node/ssr/ssrStacktrace.d.ts +0 -3
  81. package/dist/node/ssr/ssrTransform.d.ts +0 -8
  82. package/dist/node/utils.d.ts +0 -90
@@ -20243,7 +20243,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
20243
20243
  replacer: urlReplacer
20244
20244
  }));
20245
20245
  if (isModule) {
20246
- postcssPlugins.unshift((await Promise.resolve().then(function () { return require('./dep-8fc3d0a8.js'); }).then(function (n) { return n.index; })).default({
20246
+ postcssPlugins.unshift((await Promise.resolve().then(function () { return require('./dep-8e7741a0.js'); }).then(function (n) { return n.index; })).default({
20247
20247
  ...modulesOptions,
20248
20248
  getJSON(cssFileName, _modules, outputFileName) {
20249
20249
  modules = _modules;
@@ -21156,9 +21156,9 @@ function polyfill() {
21156
21156
 
21157
21157
  const htmlProxyRE = /\?html-proxy&index=(\d+)\.js$/;
21158
21158
  const isHTMLProxy = (id) => htmlProxyRE.test(id);
21159
- const htmlCommentRE = /<!--[\s\S]*?-->/g;
21160
- const scriptModuleRE$1 = /(<script\b[^>]*type\s*=\s*(?:"module"|'module')[^>]*>)(.*?)<\/script>/gims;
21161
- function htmlInlineScriptProxyPlugin() {
21159
+ // HTML Proxy Caches are stored by config -> filePath -> index
21160
+ const htmlProxyMap = new WeakMap();
21161
+ function htmlInlineScriptProxyPlugin(config) {
21162
21162
  return {
21163
21163
  name: 'vite:html-inline-script-proxy',
21164
21164
  resolveId(id) {
@@ -21166,27 +21166,36 @@ function htmlInlineScriptProxyPlugin() {
21166
21166
  return id;
21167
21167
  }
21168
21168
  },
21169
+ buildStart() {
21170
+ htmlProxyMap.set(config, new Map());
21171
+ },
21169
21172
  load(id) {
21170
21173
  const proxyMatch = id.match(htmlProxyRE);
21171
21174
  if (proxyMatch) {
21172
21175
  const index = Number(proxyMatch[1]);
21173
21176
  const file = cleanUrl(id);
21174
- const html = fs__default.readFileSync(file, 'utf-8').replace(htmlCommentRE, '');
21175
- let match;
21176
- scriptModuleRE$1.lastIndex = 0;
21177
- for (let i = 0; i <= index; i++) {
21178
- match = scriptModuleRE$1.exec(html);
21179
- }
21180
- if (match) {
21181
- return match[2];
21177
+ const url = file.replace(config.root, '');
21178
+ const result = htmlProxyMap.get(config).get(url)[index];
21179
+ if (result) {
21180
+ return result;
21182
21181
  }
21183
21182
  else {
21184
- throw new Error(`No matching html proxy module found from ${id}`);
21183
+ throw new Error(`No matching HTML proxy module found from ${id}`);
21185
21184
  }
21186
21185
  }
21187
21186
  }
21188
21187
  };
21189
21188
  }
21189
+ /** Add script to cache */
21190
+ function addToHTMLProxyCache(config, filePath, index, code) {
21191
+ if (!htmlProxyMap.get(config)) {
21192
+ htmlProxyMap.set(config, new Map());
21193
+ }
21194
+ if (!htmlProxyMap.get(config).get(filePath)) {
21195
+ htmlProxyMap.get(config).set(filePath, []);
21196
+ }
21197
+ htmlProxyMap.get(config).get(filePath)[index] = code;
21198
+ }
21190
21199
  // this extends the config in @vue/compiler-sfc with <link href>
21191
21200
  const assetAttrsConfig = {
21192
21201
  link: ['href'],
@@ -21199,7 +21208,7 @@ const assetAttrsConfig = {
21199
21208
  const isAsyncScriptMap = new WeakMap();
21200
21209
  async function traverseHtml(html, filePath, visitor) {
21201
21210
  // lazy load compiler
21202
- const { parse, transform } = await Promise.resolve().then(function () { return require('./dep-6a58f2f7.js'); }).then(function (n) { return n.compilerDom_cjs; });
21211
+ const { parse, transform } = await Promise.resolve().then(function () { return require('./dep-9b6b378f.js'); }).then(function (n) { return n.compilerDom_cjs; });
21203
21212
  // @vue/compiler-core doesn't like lowercase doctypes
21204
21213
  html = html.replace(/<!doctype\s/i, '<!DOCTYPE ');
21205
21214
  try {
@@ -21301,7 +21310,12 @@ function buildHtmlPlugin(config) {
21301
21310
  shouldRemove = true;
21302
21311
  }
21303
21312
  else if (node.children.length) {
21313
+ const contents = node.children
21314
+ .map((child) => child.content || '')
21315
+ .join('');
21304
21316
  // <script type="module">...</script>
21317
+ const filePath = id.replace(config.root, '');
21318
+ addToHTMLProxyCache(config, filePath, inlineModuleIndex, contents);
21305
21319
  js += `\nimport "${id}?html-proxy&index=${inlineModuleIndex}.js"`;
21306
21320
  shouldRemove = true;
21307
21321
  }
@@ -21577,14 +21591,16 @@ function toPublicPath(filename, config) {
21577
21591
  return isExternalUrl(filename) ? filename : config.base + filename;
21578
21592
  }
21579
21593
  const headInjectRE = /([ \t]*)<\/head>/;
21580
- const headPrependInjectRE = [/([ \t]*)<head>/, /<!doctype html>/i];
21594
+ const headPrependInjectRE = /([ \t]*)<head[^>]*>/;
21595
+ const doctypePrependInjectRE = /<!doctype html>/i;
21581
21596
  function injectToHead(html, tags, prepend = false) {
21582
21597
  if (prepend) {
21583
21598
  // inject after head or doctype
21584
- for (const re of headPrependInjectRE) {
21585
- if (re.test(html)) {
21586
- return html.replace(re, (match, p1) => `${match}\n${serializeTags(tags, incrementIndent(p1))}`);
21587
- }
21599
+ if (headPrependInjectRE.test(html)) {
21600
+ return html.replace(headPrependInjectRE, (match, p1) => `${match}\n${serializeTags(tags, incrementIndent(p1))}`);
21601
+ }
21602
+ else if (doctypePrependInjectRE.test(html)) {
21603
+ return html.replace(doctypePrependInjectRE, `$&\n${serializeTags(tags)}`);
21588
21604
  }
21589
21605
  }
21590
21606
  else {
@@ -42620,10 +42636,14 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
42620
42636
  js += `\nimport ${m[1]}`;
42621
42637
  }
42622
42638
  }
42623
- if (!code.includes(`export default`)) {
42624
- js += `\nexport default {}`;
42639
+ // This will trigger incorrectly if `export default` is contained
42640
+ // anywhere in a string. Svelte and Astro files can't have
42641
+ // `export default` as code so we know if it's encountered it's a
42642
+ // false positive (e.g. contained in a string)
42643
+ if (!path.endsWith('.vue') || !js.includes('export default')) {
42644
+ js += '\nexport default {}';
42625
42645
  }
42626
- if (code.includes('import.meta.glob')) {
42646
+ if (js.includes('import.meta.glob')) {
42627
42647
  return {
42628
42648
  // transformGlob already transforms to js
42629
42649
  loader: 'js',
@@ -49034,7 +49054,7 @@ function readFileIfExists(value) {
49034
49054
  * https://github.com/webpack/webpack-dev-server/blob/master/LICENSE
49035
49055
  */
49036
49056
  async function createCertificate() {
49037
- const { generate } = await Promise.resolve().then(function () { return require('./dep-da8087f5.js'); }).then(function (n) { return n.index; });
49057
+ const { generate } = await Promise.resolve().then(function () { return require('./dep-b502d052.js'); }).then(function (n) { return n.index; });
49038
49058
  const pems = generate(null, {
49039
49059
  algorithm: 'sha256',
49040
49060
  days: 30,
@@ -53176,6 +53196,8 @@ function createWebSocketServer(server, config, httpsOptions) {
53176
53196
  // connected client.
53177
53197
  let bufferedError = null;
53178
53198
  return {
53199
+ on: wss.on.bind(wss),
53200
+ off: wss.off.bind(wss),
53179
53201
  send(payload) {
53180
53202
  if (payload.type === 'error' && !wss.clients.size) {
53181
53203
  bufferedError = payload;
@@ -56934,6 +56956,7 @@ const devHtmlHook = async (html, { path: htmlPath, server, originalUrl }) => {
56934
56956
  const base = config.base || '/';
56935
56957
  const s = new MagicString(html);
56936
56958
  let scriptModuleIndex = -1;
56959
+ const filePath = cleanUrl(htmlPath);
56937
56960
  await traverseHtml(html, htmlPath, (node) => {
56938
56961
  if (node.type !== 1 /* ELEMENT */) {
56939
56962
  return;
@@ -56948,8 +56971,14 @@ const devHtmlHook = async (html, { path: htmlPath, server, originalUrl }) => {
56948
56971
  processNodeUrl(src, s, config, htmlPath, originalUrl);
56949
56972
  }
56950
56973
  else if (isModule) {
56974
+ const url = filePath.replace(config.root, '');
56975
+ const contents = node.children
56976
+ .map((child) => child.content || '')
56977
+ .join('');
56978
+ // add HTML Proxy to Map
56979
+ addToHTMLProxyCache(config, url, scriptModuleIndex, contents);
56951
56980
  // inline js module. convert to src="proxy"
56952
- s.overwrite(node.loc.start.offset, node.loc.end.offset, `<script type="module" src="${config.base + htmlPath.slice(1)}?html-proxy&index=${scriptModuleIndex}.js"></script>`);
56981
+ s.overwrite(node.loc.start.offset, node.loc.end.offset, `<script type="module" src="${config.base + url.slice(1)}?html-proxy&index=${scriptModuleIndex}.js"></script>`);
56953
56982
  }
56954
56983
  }
56955
56984
  // elements with [href/src] attrs
@@ -66417,7 +66446,10 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
66417
66446
  // Tolerate circular imports by ensuring the module can be
66418
66447
  // referenced before it's been instantiated.
66419
66448
  mod.ssrModule = ssrModule;
66420
- const ssrImportMeta = { url };
66449
+ const ssrImportMeta = {
66450
+ // The filesystem URL, matching native Node.js modules
66451
+ url: require$$0$8.pathToFileURL(mod.file).toString(),
66452
+ };
66421
66453
  urlStack = urlStack.concat(url);
66422
66454
  const isCircular = (url) => urlStack.includes(url);
66423
66455
  // Since dynamic imports can happen in parallel, we need to
@@ -67899,7 +67931,7 @@ async function resolvePlugins(config, prePlugins, normalPlugins, postPlugins) {
67899
67931
  ssrConfig: config.ssr,
67900
67932
  asSrc: true
67901
67933
  }),
67902
- htmlInlineScriptProxyPlugin(),
67934
+ htmlInlineScriptProxyPlugin(config),
67903
67935
  cssPlugin(config),
67904
67936
  config.esbuild !== false ? esbuildPlugin(config.esbuild) : null,
67905
67937
  jsonPlugin({
@@ -92020,4 +92052,4 @@ exports.send = send$1;
92020
92052
  exports.sortUserPlugins = sortUserPlugins;
92021
92053
  exports.source = source;
92022
92054
  exports.transformWithEsbuild = transformWithEsbuild;
92023
- //# sourceMappingURL=dep-713b45e1.js.map
92055
+ //# sourceMappingURL=dep-be032392.js.map