vite 2.6.0-beta.0 → 2.6.0-beta.4

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 (110) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/LICENSE.md +161 -3011
  3. package/bin/vite.js +2 -1
  4. package/dist/node/chunks/{dep-91aa74e8.js → dep-1e0a75a8.js} +58 -32
  5. package/dist/node/chunks/dep-1e0a75a8.js.map +1 -0
  6. package/dist/node/chunks/{dep-e36486f6.js → dep-ac1b4bf9.js} +1 -1
  7. package/dist/node/chunks/dep-ac1b4bf9.js.map +1 -0
  8. package/dist/node/chunks/{dep-c7e510f9.js → dep-ba6b30a0.js} +27538 -4953
  9. package/dist/node/chunks/dep-ba6b30a0.js.map +1 -0
  10. package/dist/node/chunks/{dep-11213a75.js → dep-c4cf6e92.js} +19 -6
  11. package/dist/node/chunks/dep-c4cf6e92.js.map +1 -0
  12. package/dist/node/chunks/{dep-eb6ef720.js → dep-d574094c.js} +18 -5
  13. package/dist/node/chunks/dep-d574094c.js.map +1 -0
  14. package/dist/node/chunks/{dep-0d2f9464.js → dep-e39b05d6.js} +18 -5
  15. package/dist/node/chunks/dep-e39b05d6.js.map +1 -0
  16. package/dist/node/cli.js +60 -23992
  17. package/dist/node/cli.js.map +1 -1
  18. package/dist/node/index.d.ts +26 -8
  19. package/dist/node/index.js +18 -15
  20. package/dist/node/index.js.map +1 -1
  21. package/dist/node/terser.js +102 -55
  22. package/package.json +28 -13
  23. package/types/package.json +3 -0
  24. package/api-extractor.json +0 -54
  25. package/dist/node/chunks/dep-0d2f9464.js.map +0 -1
  26. package/dist/node/chunks/dep-11213a75.js.map +0 -1
  27. package/dist/node/chunks/dep-91aa74e8.js.map +0 -1
  28. package/dist/node/chunks/dep-c7e510f9.js.map +0 -1
  29. package/dist/node/chunks/dep-e36486f6.js.map +0 -1
  30. package/dist/node/chunks/dep-eb6ef720.js.map +0 -1
  31. package/dist/node/terser.js.map +0 -1
  32. package/rollup.config.js +0 -389
  33. package/scripts/patchTypes.js +0 -70
  34. package/src/node/__tests__/asset.spec.ts +0 -156
  35. package/src/node/__tests__/build.spec.ts +0 -67
  36. package/src/node/__tests__/config.spec.ts +0 -166
  37. package/src/node/__tests__/packages/name/package.json +0 -3
  38. package/src/node/__tests__/packages/noname/package.json +0 -1
  39. package/src/node/__tests__/plugins/css.spec.ts +0 -116
  40. package/src/node/__tests__/scan.spec.ts +0 -118
  41. package/src/node/__tests__/utils.spec.ts +0 -40
  42. package/src/node/build.ts +0 -783
  43. package/src/node/cli.ts +0 -239
  44. package/src/node/config.ts +0 -1033
  45. package/src/node/constants.ts +0 -87
  46. package/src/node/importGlob.ts +0 -173
  47. package/src/node/index.ts +0 -88
  48. package/src/node/logger.ts +0 -167
  49. package/src/node/optimizer/esbuildDepPlugin.ts +0 -216
  50. package/src/node/optimizer/index.ts +0 -410
  51. package/src/node/optimizer/registerMissing.ts +0 -102
  52. package/src/node/optimizer/scan.ts +0 -457
  53. package/src/node/plugin.ts +0 -138
  54. package/src/node/plugins/asset.ts +0 -365
  55. package/src/node/plugins/assetImportMetaUrl.ts +0 -99
  56. package/src/node/plugins/clientInjections.ts +0 -72
  57. package/src/node/plugins/css.ts +0 -1279
  58. package/src/node/plugins/dataUri.ts +0 -64
  59. package/src/node/plugins/define.ts +0 -107
  60. package/src/node/plugins/esbuild.ts +0 -280
  61. package/src/node/plugins/html.ts +0 -673
  62. package/src/node/plugins/importAnalysis.ts +0 -614
  63. package/src/node/plugins/importAnalysisBuild.ts +0 -334
  64. package/src/node/plugins/index.ts +0 -69
  65. package/src/node/plugins/json.ts +0 -75
  66. package/src/node/plugins/loadFallback.ts +0 -19
  67. package/src/node/plugins/manifest.ts +0 -123
  68. package/src/node/plugins/modulePreloadPolyfill.ts +0 -100
  69. package/src/node/plugins/preAlias.ts +0 -22
  70. package/src/node/plugins/reporter.ts +0 -244
  71. package/src/node/plugins/resolve.ts +0 -925
  72. package/src/node/plugins/terser.ts +0 -40
  73. package/src/node/plugins/wasm.ts +0 -72
  74. package/src/node/plugins/worker.ts +0 -117
  75. package/src/node/preview.ts +0 -82
  76. package/src/node/server/__tests__/fixtures/none/nested/package.json +0 -3
  77. package/src/node/server/__tests__/fixtures/pnpm/nested/package.json +0 -3
  78. package/src/node/server/__tests__/fixtures/pnpm/package.json +0 -3
  79. package/src/node/server/__tests__/fixtures/pnpm/pnpm-workspace.yaml +0 -0
  80. package/src/node/server/__tests__/fixtures/yarn/nested/package.json +0 -3
  81. package/src/node/server/__tests__/fixtures/yarn/package.json +0 -6
  82. package/src/node/server/__tests__/search-root.spec.ts +0 -31
  83. package/src/node/server/hmr.ts +0 -489
  84. package/src/node/server/http.ts +0 -198
  85. package/src/node/server/index.ts +0 -705
  86. package/src/node/server/middlewares/base.ts +0 -52
  87. package/src/node/server/middlewares/error.ts +0 -98
  88. package/src/node/server/middlewares/indexHtml.ts +0 -170
  89. package/src/node/server/middlewares/proxy.ts +0 -124
  90. package/src/node/server/middlewares/spaFallback.ts +0 -32
  91. package/src/node/server/middlewares/static.ts +0 -153
  92. package/src/node/server/middlewares/time.ts +0 -18
  93. package/src/node/server/middlewares/transform.ts +0 -196
  94. package/src/node/server/moduleGraph.ts +0 -200
  95. package/src/node/server/openBrowser.ts +0 -101
  96. package/src/node/server/pluginContainer.ts +0 -546
  97. package/src/node/server/searchRoot.ts +0 -70
  98. package/src/node/server/send.ts +0 -54
  99. package/src/node/server/sourcemap.ts +0 -54
  100. package/src/node/server/transformRequest.ts +0 -168
  101. package/src/node/server/ws.ts +0 -131
  102. package/src/node/ssr/__tests__/ssrTransform.spec.ts +0 -309
  103. package/src/node/ssr/ssrExternal.ts +0 -161
  104. package/src/node/ssr/ssrManifestPlugin.ts +0 -53
  105. package/src/node/ssr/ssrModuleLoader.ts +0 -214
  106. package/src/node/ssr/ssrStacktrace.ts +0 -75
  107. package/src/node/ssr/ssrTransform.ts +0 -452
  108. package/src/node/tsconfig.json +0 -14
  109. package/src/node/utils.ts +0 -565
  110. package/tsconfig.base.json +0 -11
package/bin/vite.js CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ const { performance } = require('perf_hooks')
2
3
 
3
4
  if (!__dirname.includes('node_modules')) {
4
5
  try {
@@ -7,7 +8,7 @@ if (!__dirname.includes('node_modules')) {
7
8
  } catch (e) {}
8
9
  }
9
10
 
10
- global.__vite_start_time = Date.now()
11
+ global.__vite_start_time = performance.now()
11
12
 
12
13
  // check debug mode first before requiring the CLI.
13
14
  const debugIndex = process.argv.findIndex((arg) => /^(?:-d|--debug)$/.test(arg))
@@ -1,6 +1,18 @@
1
1
  'use strict';
2
2
 
3
- var build = require('./dep-c7e510f9.js');
3
+ var build = require('./dep-ba6b30a0.js');
4
+
5
+ function _mergeNamespaces(n, m) {
6
+ for (var i = 0; i < m.length; i++) {
7
+ var e = m[i];
8
+ for (var k in e) {
9
+ if (k !== 'default' && !(k in n)) {
10
+ n[k] = e[k];
11
+ }
12
+ }
13
+ }
14
+ return n;
15
+ }
4
16
 
5
17
  var compilerDom_cjs$2 = {};
6
18
 
@@ -698,7 +710,7 @@ const errorMessages = {
698
710
  // transform errors
699
711
  [28 /* X_V_IF_NO_EXPRESSION */]: `v-if/v-else-if is missing expression.`,
700
712
  [29 /* X_V_IF_SAME_KEY */]: `v-if/else branches must use unique keys.`,
701
- [30 /* X_V_ELSE_NO_ADJACENT_IF */]: `v-else/v-else-if has no adjacent v-if.`,
713
+ [30 /* X_V_ELSE_NO_ADJACENT_IF */]: `v-else/v-else-if has no adjacent v-if or v-else-if.`,
702
714
  [31 /* X_V_FOR_NO_EXPRESSION */]: `v-for is missing expression.`,
703
715
  [32 /* X_V_FOR_MALFORMED_EXPRESSION */]: `v-for has invalid expression.`,
704
716
  [33 /* X_V_FOR_TEMPLATE_KEY_PLACEMENT */]: `<template v-for> key should be placed on the <template> tag.`,
@@ -722,7 +734,7 @@ const errorMessages = {
722
734
  [47 /* X_MODULE_MODE_NOT_SUPPORTED */]: `ES module mode is not supported in this build of compiler.`,
723
735
  [48 /* X_CACHE_HANDLER_NOT_SUPPORTED */]: `"cacheHandlers" option is only supported when the "prefixIdentifiers" option is enabled.`,
724
736
  [49 /* X_SCOPE_ID_NOT_SUPPORTED */]: `"scopeId" option is only supported in module mode.`,
725
- // just to fullfill types
737
+ // just to fulfill types
726
738
  [50 /* __EXTEND_POINT__ */]: ``
727
739
  };
728
740
 
@@ -1023,7 +1035,7 @@ const whitespaceRE = /\s+[.[]\s*|\s*[.[]\s+/g;
1023
1035
  * inside square brackets), but it's ok since these are only used on template
1024
1036
  * expressions and false positives are invalid expressions in the first place.
1025
1037
  */
1026
- const isMemberExpression = (path) => {
1038
+ const isMemberExpressionBrowser = (path) => {
1027
1039
  // remove whitespaces around . or [ first
1028
1040
  path = path.trim().replace(whitespaceRE, s => s.trim());
1029
1041
  let state = 0 /* inMemberExp */;
@@ -1093,6 +1105,10 @@ const isMemberExpression = (path) => {
1093
1105
  }
1094
1106
  return !currentOpenBracketCount && !currentOpenParensCount;
1095
1107
  };
1108
+ const isMemberExpressionNode = NOOP
1109
+ ;
1110
+ const isMemberExpression = isMemberExpressionBrowser
1111
+ ;
1096
1112
  function getInnerRange(loc, offset, length) {
1097
1113
  const source = loc.source.substr(offset, length);
1098
1114
  const newLoc = {
@@ -2285,7 +2301,7 @@ function walk(node, context, doNotHoistNode = false) {
2285
2301
  // This is only a concern for pre-stringification (via transformHoist by
2286
2302
  // @vue/compiler-dom), but doing it here allows us to perform only one full
2287
2303
  // walk of the AST and allow `stringifyStatic` to stop walking as soon as its
2288
- // stringficiation threshold is met.
2304
+ // stringification threshold is met.
2289
2305
  let canStringify = true;
2290
2306
  const { children } = node;
2291
2307
  const originalCount = children.length;
@@ -2532,7 +2548,7 @@ function getGeneratedPropsConstantType(node, context) {
2532
2548
  else if (value.type === 14 /* JS_CALL_EXPRESSION */) {
2533
2549
  // some helper calls can be hoisted,
2534
2550
  // such as the `normalizeProps` generated by the compiler for pre-normalize class,
2535
- // in this case we need to respect the ConstanType of the helper's argments
2551
+ // in this case we need to respect the ConstantType of the helper's argments
2536
2552
  valueType = getConstantTypeOfHelperCall(value, context);
2537
2553
  }
2538
2554
  else {
@@ -2851,7 +2867,7 @@ function createStructuralDirectiveTransform(name, fn) {
2851
2867
  }
2852
2868
 
2853
2869
  const PURE_ANNOTATION = `/*#__PURE__*/`;
2854
- function createCodegenContext(ast, { mode = 'function', prefixIdentifiers = mode === 'module', sourceMap = false, filename = `template.vue.html`, scopeId = null, optimizeImports = false, runtimeGlobalName = `Vue`, runtimeModuleName = `vue`, ssr = false, isTS = false, inSSR = false }) {
2870
+ function createCodegenContext(ast, { mode = 'function', prefixIdentifiers = mode === 'module', sourceMap = false, filename = `template.vue.html`, scopeId = null, optimizeImports = false, runtimeGlobalName = `Vue`, runtimeModuleName = `vue`, ssrRuntimeModuleName = 'vue/server-renderer', ssr = false, isTS = false, inSSR = false }) {
2855
2871
  const context = {
2856
2872
  mode,
2857
2873
  prefixIdentifiers,
@@ -2861,6 +2877,7 @@ function createCodegenContext(ast, { mode = 'function', prefixIdentifiers = mode
2861
2877
  optimizeImports,
2862
2878
  runtimeGlobalName,
2863
2879
  runtimeModuleName,
2880
+ ssrRuntimeModuleName,
2864
2881
  ssr,
2865
2882
  isTS,
2866
2883
  inSSR,
@@ -2986,7 +3003,7 @@ function generate(ast, options = {}) {
2986
3003
  };
2987
3004
  }
2988
3005
  function genFunctionPreamble(ast, context) {
2989
- const { ssr, prefixIdentifiers, push, newline, runtimeModuleName, runtimeGlobalName } = context;
3006
+ const { ssr, prefixIdentifiers, push, newline, runtimeModuleName, runtimeGlobalName, ssrRuntimeModuleName } = context;
2990
3007
  const VueBinding = runtimeGlobalName;
2991
3008
  const aliasHelper = (s) => `${helperNameMap[s]}: _${helperNameMap[s]}`;
2992
3009
  // Generate const declaration for helpers
@@ -3046,13 +3063,14 @@ function genHoists(hoists, context) {
3046
3063
  context.pure = true;
3047
3064
  const { push, newline, helper, scopeId, mode } = context;
3048
3065
  newline();
3049
- hoists.forEach((exp, i) => {
3066
+ for (let i = 0; i < hoists.length; i++) {
3067
+ const exp = hoists[i];
3050
3068
  if (exp) {
3051
- push(`const _hoisted_${i + 1} = `);
3069
+ push(`const _hoisted_${i + 1} = ${``}`);
3052
3070
  genNode(exp, context);
3053
3071
  newline();
3054
3072
  }
3055
- });
3073
+ }
3056
3074
  context.pure = false;
3057
3075
  }
3058
3076
  function isText$1(n) {
@@ -3658,6 +3676,11 @@ function processIf(node, dir, context, processCodegen) {
3658
3676
  continue;
3659
3677
  }
3660
3678
  if (sibling && sibling.type === 9 /* IF */) {
3679
+ // Check if v-else was followed by v-else-if
3680
+ if (dir.name === 'else-if' &&
3681
+ sibling.branches[sibling.branches.length - 1].condition === undefined) {
3682
+ context.onError(createCompilerError(30 /* X_V_ELSE_NO_ADJACENT_IF */, node.loc));
3683
+ }
3661
3684
  // move the node to the if node's branches
3662
3685
  context.removeNode();
3663
3686
  const branch = createIfBranch(node, dir);
@@ -4776,7 +4799,7 @@ function dedupeProperties(properties) {
4776
4799
  const name = prop.key.content;
4777
4800
  const existing = knownProps.get(name);
4778
4801
  if (existing) {
4779
- if (name === 'style' || name === 'class' || name.startsWith('on')) {
4802
+ if (name === 'style' || name === 'class' || isOn(name)) {
4780
4803
  mergeAsArray(existing, prop);
4781
4804
  }
4782
4805
  // unexpected duplicate, should have emitted error during parse
@@ -4870,26 +4893,24 @@ const transformSlotOutlet = (node, context) => {
4870
4893
  const { slotName, slotProps } = processSlotOutlet(node, context);
4871
4894
  const slotArgs = [
4872
4895
  context.prefixIdentifiers ? `_ctx.$slots` : `$slots`,
4873
- slotName
4896
+ slotName,
4897
+ '{}',
4898
+ 'undefined',
4899
+ 'true'
4874
4900
  ];
4901
+ let expectedLen = 2;
4875
4902
  if (slotProps) {
4876
- slotArgs.push(slotProps);
4903
+ slotArgs[2] = slotProps;
4904
+ expectedLen = 3;
4877
4905
  }
4878
4906
  if (children.length) {
4879
- if (!slotProps) {
4880
- slotArgs.push(`{}`);
4881
- }
4882
- slotArgs.push(createFunctionExpression([], children, false, false, loc));
4907
+ slotArgs[3] = createFunctionExpression([], children, false, false, loc);
4908
+ expectedLen = 4;
4883
4909
  }
4884
4910
  if (context.scopeId && !context.slotted) {
4885
- if (!slotProps) {
4886
- slotArgs.push(`{}`);
4887
- }
4888
- if (!children.length) {
4889
- slotArgs.push(`undefined`);
4890
- }
4891
- slotArgs.push(`true`);
4911
+ expectedLen = 5;
4892
4912
  }
4913
+ slotArgs.splice(expectedLen); // remove unused arguments
4893
4914
  node.codegenNode = createCallExpression(context.helper(RENDER_SLOT), slotArgs, loc);
4894
4915
  }
4895
4916
  };
@@ -5188,7 +5209,8 @@ const transformModel = (dir, node, context) => {
5188
5209
  const rawExp = exp.loc.source;
5189
5210
  const expString = exp.type === 4 /* SIMPLE_EXPRESSION */ ? exp.content : rawExp;
5190
5211
  const maybeRef = !true /* SETUP_CONST */;
5191
- if (!expString.trim() || (!isMemberExpression(expString) && !maybeRef)) {
5212
+ if (!expString.trim() ||
5213
+ (!isMemberExpression(expString) && !maybeRef)) {
5192
5214
  context.onError(createCompilerError(42 /* X_V_MODEL_MALFORMED_EXPRESSION */, exp.loc));
5193
5215
  return createTransformProps();
5194
5216
  }
@@ -5202,9 +5224,9 @@ const transformModel = (dir, node, context) => {
5202
5224
  const eventArg = context.isTS ? `($event: any)` : `$event`;
5203
5225
  {
5204
5226
  assignmentExp = createCompoundExpression([
5205
- `${eventArg} => (`,
5227
+ `${eventArg} => ((`,
5206
5228
  exp,
5207
- ` = $event)`
5229
+ `) = $event)`
5208
5230
  ]);
5209
5231
  }
5210
5232
  const props = [
@@ -5576,6 +5598,8 @@ var compilerCore_esmBundler = {
5576
5598
  isFunctionType: isFunctionType,
5577
5599
  isInDestructureAssignment: isInDestructureAssignment,
5578
5600
  isMemberExpression: isMemberExpression,
5601
+ isMemberExpressionBrowser: isMemberExpressionBrowser,
5602
+ isMemberExpressionNode: isMemberExpressionNode,
5579
5603
  isReferencedIdentifier: isReferencedIdentifier,
5580
5604
  isSimpleIdentifier: isSimpleIdentifier,
5581
5605
  isSlotOutlet: isSlotOutlet,
@@ -8372,7 +8396,8 @@ const warnTransitionChildren = (node, context) => {
8372
8396
  };
8373
8397
  function hasMultipleChildren(node) {
8374
8398
  // #1352 filter out potential comment nodes.
8375
- const children = (node.children = node.children.filter(c => c.type !== 3 /* COMMENT */));
8399
+ const children = (node.children = node.children.filter(c => c.type !== 3 /* COMMENT */ &&
8400
+ !(c.type === 2 /* TEXT */ && !c.content.trim())));
8376
8401
  const child = children[0];
8377
8402
  return (children.length !== 1 ||
8378
8403
  child.type === 11 /* FOR */ ||
@@ -8700,9 +8725,10 @@ exports.transformStyle = transformStyle;
8700
8725
 
8701
8726
  var compilerDom_cjs = /*@__PURE__*/build.getDefaultExportFromCjs(compilerDom_cjs$2);
8702
8727
 
8703
- var compilerDom_cjs$1 = /*#__PURE__*/Object.assign(/*#__PURE__*/Object.create(null), compilerDom_cjs$2, {
8728
+ var compilerDom_cjs$1 = /*#__PURE__*/_mergeNamespaces({
8729
+ __proto__: null,
8704
8730
  'default': compilerDom_cjs
8705
- });
8731
+ }, [compilerDom_cjs$2]);
8706
8732
 
8707
8733
  exports.compilerDom_cjs = compilerDom_cjs$1;
8708
- //# sourceMappingURL=dep-91aa74e8.js.map
8734
+ //# sourceMappingURL=dep-1e0a75a8.js.map