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
@@ -30,8 +30,8 @@ import { SourceDescription } from 'rollup';
30
30
  import { SourceMap } from 'rollup';
31
31
  import * as stream from 'stream';
32
32
  import { TransformPluginContext } from 'rollup';
33
- import { TransformResult as TransformResult_2 } from 'rollup';
34
- import { TransformResult as TransformResult_3 } from 'esbuild';
33
+ import { TransformResult as TransformResult_2 } from 'esbuild';
34
+ import { TransformResult as TransformResult_3 } from 'rollup';
35
35
  import * as url from 'url';
36
36
  import { WatcherOptions } from 'rollup';
37
37
 
@@ -139,7 +139,7 @@ export declare interface BuildOptions {
139
139
  /**
140
140
  * Set to `false` to disable minification, or specify the minifier to use.
141
141
  * Available options are 'terser' or 'esbuild'.
142
- * @default 'terser'
142
+ * @default 'esbuild'
143
143
  */
144
144
  minify?: boolean | 'terser' | 'esbuild';
145
145
  /**
@@ -485,7 +485,7 @@ export declare interface ESBuildOptions extends EsbuildTransformOptions {
485
485
 
486
486
  export { EsbuildTransformOptions }
487
487
 
488
- export declare type ESBuildTransformResult = Omit<TransformResult_3, 'map'> & {
488
+ export declare type ESBuildTransformResult = Omit<TransformResult_2, 'map'> & {
489
489
  map: SourceMap;
490
490
  };
491
491
 
@@ -496,7 +496,7 @@ export declare interface FileSystemServeOptions {
496
496
  * Set to `false` to disable the warning
497
497
  * Default to false at this moment, will enabled by default in the future versions.
498
498
  *
499
- * @expiremental
499
+ * @experimental
500
500
  * @default undefined
501
501
  */
502
502
  strict?: boolean | undefined;
@@ -506,7 +506,7 @@ export declare interface FileSystemServeOptions {
506
506
  * Accepts absolute path or a path relative to project root.
507
507
  * Will try to search up for workspace root by default.
508
508
  *
509
- * @expiremental
509
+ * @experimental
510
510
  */
511
511
  allow?: string[];
512
512
  }
@@ -1144,7 +1144,7 @@ export declare interface Plugin extends Plugin_2 {
1144
1144
  custom?: CustomPluginOptions;
1145
1145
  }, ssr?: boolean): Promise<ResolveIdResult> | ResolveIdResult;
1146
1146
  load?(this: PluginContext, id: string, ssr?: boolean): Promise<LoadResult> | LoadResult;
1147
- transform?(this: TransformPluginContext, code: string, id: string, ssr?: boolean): Promise<TransformResult_2> | TransformResult_2;
1147
+ transform?(this: TransformPluginContext, code: string, id: string, ssr?: boolean): Promise<TransformResult_3> | TransformResult_3;
1148
1148
  }
1149
1149
 
1150
1150
  export declare interface PluginContainer {
@@ -1158,6 +1158,14 @@ export declare interface PluginContainer {
1158
1158
 
1159
1159
  export declare type PluginOption = Plugin | false | null | undefined;
1160
1160
 
1161
+ /**
1162
+ * Starts the Vite server in preview mode, to simulate a production deployment
1163
+ * @param config - the resolve Vite config
1164
+ * @param serverOptions - what host and port to use
1165
+ * @experimental
1166
+ */
1167
+ export declare function preview(config: ResolvedConfig, serverOptions: Pick<ServerOptions, 'port' | 'host'>): Promise<Server>;
1168
+
1161
1169
  export declare interface ProxyOptions extends HttpProxy.ServerOptions {
1162
1170
  /**
1163
1171
  * rewrite path
@@ -1413,6 +1421,11 @@ export declare interface RollupDynamicImportVarsOptions {
1413
1421
  warnOnError?: boolean
1414
1422
  }
1415
1423
 
1424
+ /**
1425
+ * Search up for the nearest workspace root
1426
+ */
1427
+ export declare function searchForWorkspaceRoot(current: string, root?: string): string;
1428
+
1416
1429
  export declare function send(req: IncomingMessage, res: ServerResponse, content: string | Buffer, type: string, etag?: string, cacheControl?: string, map?: SourceMap | null): void;
1417
1430
 
1418
1431
  export declare type ServerHook = (server: ViteDevServer) => (() => void) | void | Promise<(() => void) | void>;
@@ -1489,6 +1502,10 @@ export declare interface ServerOptions {
1489
1502
  * Options for files served via '/\@fs/'.
1490
1503
  */
1491
1504
  fs?: FileSystemServeOptions;
1505
+ /**
1506
+ * Origin for the generated asset URLs.
1507
+ */
1508
+ origin?: string;
1492
1509
  }
1493
1510
 
1494
1511
  export declare function sortUserPlugins(plugins: (Plugin | Plugin[])[] | undefined): [Plugin[], Plugin[], Plugin[]];
@@ -1873,7 +1890,7 @@ export declare interface ViteDevServer {
1873
1890
  * Programmatically resolve, load and transform a URL and get the result
1874
1891
  * without going through the http request pipeline.
1875
1892
  */
1876
- transformRequest(url: string, options?: TransformOptions): Promise<TransformResult_2 | null>;
1893
+ transformRequest(url: string, options?: TransformOptions): Promise<TransformResult | null>;
1877
1894
  /**
1878
1895
  * Apply vite built-in HTML transforms and any plugin HTML transforms.
1879
1896
  */
@@ -1907,6 +1924,7 @@ export declare interface ViteDevServer {
1907
1924
  /* Excluded from this release type: _isRunningOptimizer */
1908
1925
  /* Excluded from this release type: _registerMissingImport */
1909
1926
  /* Excluded from this release type: _pendingReload */
1927
+ /* Excluded from this release type: _pendingRequests */
1910
1928
  }
1911
1929
 
1912
1930
  export declare interface WatchOptions {
@@ -2,33 +2,34 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var build = require('./chunks/dep-c7e510f9.js');
5
+ var build = require('./chunks/dep-ba6b30a0.js');
6
6
  require('fs');
7
7
  require('path');
8
- require('os');
9
- require('tty');
10
- require('util');
11
- require('net');
12
8
  require('events');
13
- require('url');
14
- require('http');
9
+ require('util');
15
10
  require('stream');
16
- require('resolve');
17
- require('module');
18
- require('https');
19
- require('tls');
11
+ require('os');
12
+ require('perf_hooks');
13
+ require('url');
20
14
  require('crypto');
21
- require('zlib');
22
- require('assert');
23
- require('buffer');
24
- require('querystring');
15
+ require('module');
25
16
  require('repl');
26
17
  require('vm');
27
18
  require('console');
19
+ require('assert');
28
20
  require('esbuild');
29
21
  require('worker_threads');
30
22
  require('child_process');
31
23
  require('readline');
24
+ require('zlib');
25
+ require('resolve');
26
+ require('querystring');
27
+ require('tty');
28
+ require('net');
29
+ require('http');
30
+ require('buffer');
31
+ require('https');
32
+ require('tls');
32
33
 
33
34
 
34
35
 
@@ -41,10 +42,12 @@ exports.loadEnv = build.loadEnv;
41
42
  exports.mergeConfig = build.mergeConfig;
42
43
  exports.normalizePath = build.normalizePath;
43
44
  exports.optimizeDeps = build.optimizeDeps;
45
+ exports.preview = build.preview;
44
46
  exports.resolveConfig = build.resolveConfig;
45
47
  exports.resolveEnvPrefix = build.resolveEnvPrefix;
46
48
  exports.resolvePackageData = build.resolvePackageData;
47
49
  exports.resolvePackageEntry = build.resolvePackageEntry;
50
+ exports.searchForWorkspaceRoot = build.searchForWorkspaceRoot;
48
51
  exports.send = build.send;
49
52
  exports.sortUserPlugins = build.sortUserPlugins;
50
53
  exports.transformWithEsbuild = build.transformWithEsbuild;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -3,7 +3,7 @@
3
3
  var require$$0 = require('fs');
4
4
  var require$$1 = require('path');
5
5
 
6
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e['default'] : e; }
6
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
7
7
 
8
8
  var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
9
9
  var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
@@ -20077,9 +20077,8 @@ function is_undefined(node, compressor) {
20077
20077
  );
20078
20078
  }
20079
20079
 
20080
- // Find out if something is == null
20081
- // Used to optimize ?. and ??
20082
- function is_nullish(node, compressor) {
20080
+ // Is the node explicitly null or undefined.
20081
+ function is_null_or_undefined(node, compressor) {
20083
20082
  let fixed;
20084
20083
  return (
20085
20084
  node instanceof AST_Null
@@ -20089,13 +20088,29 @@ function is_nullish(node, compressor) {
20089
20088
  && (fixed = node.definition().fixed) instanceof AST_Node
20090
20089
  && is_nullish(fixed, compressor)
20091
20090
  )
20092
- // Recurse into those optional chains!
20093
- || node instanceof AST_PropAccess && node.optional && is_nullish(node.expression, compressor)
20094
- || node instanceof AST_Call && node.optional && is_nullish(node.expression, compressor)
20095
- || node instanceof AST_Chain && is_nullish(node.expression, compressor)
20096
20091
  );
20097
20092
  }
20098
20093
 
20094
+ // Find out if this expression is optionally chained from a base-point that we
20095
+ // can statically analyze as null or undefined.
20096
+ function is_nullish_shortcircuited(node, compressor) {
20097
+ if (node instanceof AST_PropAccess || node instanceof AST_Call) {
20098
+ return (
20099
+ (node.optional && is_null_or_undefined(node.expression, compressor))
20100
+ || is_nullish_shortcircuited(node.expression, compressor)
20101
+ );
20102
+ }
20103
+ if (node instanceof AST_Chain) return is_nullish_shortcircuited(node.expression, compressor);
20104
+ return false;
20105
+ }
20106
+
20107
+ // Find out if something is == null, or can short circuit into nullish.
20108
+ // Used to optimize ?. and ??
20109
+ function is_nullish(node, compressor) {
20110
+ if (is_null_or_undefined(node, compressor)) return true;
20111
+ return is_nullish_shortcircuited(node, compressor);
20112
+ }
20113
+
20099
20114
  // Determine if expression might cause side effects
20100
20115
  // If there's a possibility that a node may change something when it's executed, this returns true
20101
20116
  (function(def_has_side_effects) {
@@ -20203,13 +20218,12 @@ function is_nullish(node, compressor) {
20203
20218
  return any(this.elements, compressor);
20204
20219
  });
20205
20220
  def_has_side_effects(AST_Dot, function(compressor) {
20221
+ if (is_nullish(this, compressor)) return false;
20206
20222
  return !this.optional && this.expression.may_throw_on_access(compressor)
20207
20223
  || this.expression.has_side_effects(compressor);
20208
20224
  });
20209
20225
  def_has_side_effects(AST_Sub, function(compressor) {
20210
- if (this.optional && is_nullish(this.expression, compressor)) {
20211
- return false;
20212
- }
20226
+ if (is_nullish(this, compressor)) return false;
20213
20227
 
20214
20228
  return !this.optional && this.expression.may_throw_on_access(compressor)
20215
20229
  || this.expression.has_side_effects(compressor)
@@ -20277,7 +20291,7 @@ function is_nullish(node, compressor) {
20277
20291
  return any(this.body, compressor);
20278
20292
  });
20279
20293
  def_may_throw(AST_Call, function(compressor) {
20280
- if (this.optional && is_nullish(this.expression, compressor)) return false;
20294
+ if (is_nullish(this, compressor)) return false;
20281
20295
  if (any(this.args, compressor)) return true;
20282
20296
  if (this.is_callee_pure(compressor)) return false;
20283
20297
  if (this.expression.may_throw(compressor)) return true;
@@ -20336,12 +20350,12 @@ function is_nullish(node, compressor) {
20336
20350
  return this.body.may_throw(compressor);
20337
20351
  });
20338
20352
  def_may_throw(AST_Dot, function(compressor) {
20353
+ if (is_nullish(this, compressor)) return false;
20339
20354
  return !this.optional && this.expression.may_throw_on_access(compressor)
20340
20355
  || this.expression.may_throw(compressor);
20341
20356
  });
20342
20357
  def_may_throw(AST_Sub, function(compressor) {
20343
- if (this.optional && is_nullish(this.expression, compressor)) return false;
20344
-
20358
+ if (is_nullish(this, compressor)) return false;
20345
20359
  return !this.optional && this.expression.may_throw_on_access(compressor)
20346
20360
  || this.expression.may_throw(compressor)
20347
20361
  || this.property.may_throw(compressor);
@@ -20833,6 +20847,9 @@ function def_eval(node, func) {
20833
20847
  node.DEFMETHOD("_eval", func);
20834
20848
  }
20835
20849
 
20850
+ // Used to propagate a nullish short-circuit signal upwards through the chain.
20851
+ const nullish = Symbol("This AST_Chain is nullish");
20852
+
20836
20853
  // If the node has been successfully reduced to a constant,
20837
20854
  // then its value is returned; otherwise the element itself
20838
20855
  // is returned.
@@ -20844,7 +20861,7 @@ AST_Node.DEFMETHOD("evaluate", function (compressor) {
20844
20861
  var val = this._eval(compressor, 1);
20845
20862
  if (!val || val instanceof RegExp)
20846
20863
  return val;
20847
- if (typeof val == "function" || typeof val == "object")
20864
+ if (typeof val == "function" || typeof val == "object" || val == nullish)
20848
20865
  return this;
20849
20866
  return val;
20850
20867
  });
@@ -21089,11 +21106,8 @@ const regexp_flags = new Set([
21089
21106
  ]);
21090
21107
 
21091
21108
  def_eval(AST_PropAccess, function (compressor, depth) {
21092
- if (this.optional) {
21093
- const obj = this.expression._eval(compressor, depth);
21094
- if (obj == null)
21095
- return undefined;
21096
- }
21109
+ const obj = this.expression._eval(compressor, depth);
21110
+ if (obj === nullish || (this.optional && obj == null)) return nullish;
21097
21111
  if (compressor.option("unsafe")) {
21098
21112
  var key = this.property;
21099
21113
  if (key instanceof AST_Node) {
@@ -21148,16 +21162,19 @@ def_eval(AST_PropAccess, function (compressor, depth) {
21148
21162
 
21149
21163
  def_eval(AST_Chain, function (compressor, depth) {
21150
21164
  const evaluated = this.expression._eval(compressor, depth);
21151
- return evaluated === this.expression ? this : evaluated;
21165
+ return evaluated === nullish
21166
+ ? undefined
21167
+ : evaluated === this.expression
21168
+ ? this
21169
+ : evaluated;
21152
21170
  });
21153
21171
 
21154
21172
  def_eval(AST_Call, function (compressor, depth) {
21155
21173
  var exp = this.expression;
21156
- if (this.optional) {
21157
- const callee = this.expression._eval(compressor, depth);
21158
- if (callee == null)
21159
- return undefined;
21160
- }
21174
+
21175
+ const callee = exp._eval(compressor, depth);
21176
+ if (callee === nullish || (this.optional && callee == null)) return nullish;
21177
+
21161
21178
  if (compressor.option("unsafe") && exp instanceof AST_PropAccess) {
21162
21179
  var key = exp.property;
21163
21180
  if (key instanceof AST_Node) {
@@ -21289,8 +21306,8 @@ def_drop_side_effect_free(AST_Constant, return_null);
21289
21306
  def_drop_side_effect_free(AST_This, return_null);
21290
21307
 
21291
21308
  def_drop_side_effect_free(AST_Call, function (compressor, first_in_statement) {
21292
- if (this.optional && is_nullish(this.expression, compressor)) {
21293
- return make_node(AST_Undefined, this);
21309
+ if (is_nullish_shortcircuited(this, compressor)) {
21310
+ return this.expression.drop_side_effect_free(compressor, first_in_statement);
21294
21311
  }
21295
21312
 
21296
21313
  if (!this.is_callee_pure(compressor)) {
@@ -21466,21 +21483,19 @@ def_drop_side_effect_free(AST_Array, function (compressor, first_in_statement) {
21466
21483
  });
21467
21484
 
21468
21485
  def_drop_side_effect_free(AST_Dot, function (compressor, first_in_statement) {
21469
- if (this.optional) {
21470
- return is_nullish(this.expression, compressor) ? make_node(AST_Undefined, this) : this;
21486
+ if (is_nullish_shortcircuited(this, compressor)) {
21487
+ return this.expression.drop_side_effect_free(compressor, first_in_statement);
21471
21488
  }
21472
- if (this.expression.may_throw_on_access(compressor))
21473
- return this;
21489
+ if (this.expression.may_throw_on_access(compressor)) return this;
21474
21490
 
21475
21491
  return this.expression.drop_side_effect_free(compressor, first_in_statement);
21476
21492
  });
21477
21493
 
21478
21494
  def_drop_side_effect_free(AST_Sub, function (compressor, first_in_statement) {
21479
- if (this.optional) {
21480
- return is_nullish(this.expression, compressor) ? make_node(AST_Undefined, this) : this;
21495
+ if (is_nullish_shortcircuited(this, compressor)) {
21496
+ return this.expression.drop_side_effect_free(compressor, first_in_statement);
21481
21497
  }
21482
- if (this.expression.may_throw_on_access(compressor))
21483
- return this;
21498
+ if (this.expression.may_throw_on_access(compressor)) return this;
21484
21499
 
21485
21500
  var expression = this.expression.drop_side_effect_free(compressor, first_in_statement);
21486
21501
  if (!expression)
@@ -24908,6 +24923,49 @@ def_optimize(AST_Switch, function(self, compressor) {
24908
24923
  while (i < len) eliminate_branch(self.body[i++], body[body.length - 1]);
24909
24924
  self.body = body;
24910
24925
 
24926
+ let default_or_exact = default_branch || exact_match;
24927
+ default_branch = null;
24928
+ exact_match = null;
24929
+
24930
+ // group equivalent branches so they will be located next to each other,
24931
+ // that way the next micro-optimization will merge them.
24932
+ // ** bail micro-optimization if not a simple switch case with breaks
24933
+ if (body.every((branch, i) =>
24934
+ (branch === default_or_exact || !branch.expression.has_side_effects(compressor))
24935
+ && (branch.body.length === 0 || aborts(branch) || body.length - 1 === i))
24936
+ ) {
24937
+ for (let i = 0; i < body.length; i++) {
24938
+ const branch = body[i];
24939
+ for (let j = i + 1; j < body.length; j++) {
24940
+ const next = body[j];
24941
+ if (next.body.length === 0) continue;
24942
+ const last_branch = j === (body.length - 1);
24943
+ const equivalentBranch = branches_equivalent(next, branch, false);
24944
+ if (equivalentBranch || (last_branch && branches_equivalent(next, branch, true))) {
24945
+ if (!equivalentBranch && last_branch) {
24946
+ next.body.push(make_node(AST_Break));
24947
+ }
24948
+
24949
+ // let's find previous siblings with inert fallthrough...
24950
+ let x = j - 1;
24951
+ let fallthroughDepth = 0;
24952
+ while (x > i) {
24953
+ if (is_inert_body(body[x--])) {
24954
+ fallthroughDepth++;
24955
+ } else {
24956
+ break;
24957
+ }
24958
+ }
24959
+
24960
+ const plucked = body.splice(j - fallthroughDepth, 1 + fallthroughDepth);
24961
+ body.splice(i + 1, 0, ...plucked);
24962
+ i += plucked.length;
24963
+ }
24964
+ }
24965
+ }
24966
+ }
24967
+
24968
+ // merge equivalent branches in a row
24911
24969
  for (let i = 0; i < body.length; i++) {
24912
24970
  let branch = body[i];
24913
24971
  if (branch.body.length === 0) continue;
@@ -24928,10 +24986,6 @@ def_optimize(AST_Switch, function(self, compressor) {
24928
24986
  }
24929
24987
  }
24930
24988
 
24931
- let default_or_exact = default_branch || exact_match;
24932
- default_branch = null;
24933
- exact_match = null;
24934
-
24935
24989
  // Prune any empty branches at the end of the switch statement.
24936
24990
  {
24937
24991
  let i = body.length - 1;
@@ -25322,10 +25376,6 @@ def_optimize(AST_Call, function(self, compressor) {
25322
25376
  }
25323
25377
  }
25324
25378
 
25325
- if (self.optional && is_nullish(fn, compressor)) {
25326
- return make_node(AST_Undefined, self);
25327
- }
25328
-
25329
25379
  var is_func = fn instanceof AST_Lambda;
25330
25380
 
25331
25381
  if (is_func && fn.pinned()) return self;
@@ -25722,6 +25772,7 @@ def_optimize(AST_Call, function(self, compressor) {
25722
25772
  if (can_inline && has_annotation(self, _INLINE)) {
25723
25773
  set_flag(fn, SQUEEZED);
25724
25774
  fn = make_node(fn.CTOR === AST_Defun ? AST_Function : fn.CTOR, fn, fn);
25775
+ fn = fn.clone(true);
25725
25776
  fn.figure_out_scope({}, {
25726
25777
  parent_scope: find_scope(compressor),
25727
25778
  toplevel: compressor.get_toplevel()
@@ -27509,14 +27560,11 @@ def_optimize(AST_Sub, function(self, compressor) {
27509
27560
  ev = make_node_from_constant(ev, self).optimize(compressor);
27510
27561
  return best_of(compressor, ev, self);
27511
27562
  }
27512
- if (self.optional && is_nullish(self.expression, compressor)) {
27513
- return make_node(AST_Undefined, self);
27514
- }
27515
27563
  return self;
27516
27564
  });
27517
27565
 
27518
27566
  def_optimize(AST_Chain, function (self, compressor) {
27519
- self.expression = self.expression.optimize(compressor);
27567
+ if (is_nullish(self.expression, compressor)) return make_node(AST_Undefined, self);
27520
27568
  return self;
27521
27569
  });
27522
27570
 
@@ -27583,9 +27631,6 @@ def_optimize(AST_Dot, function(self, compressor) {
27583
27631
  ev = make_node_from_constant(ev, self).optimize(compressor);
27584
27632
  return best_of(compressor, ev, self);
27585
27633
  }
27586
- if (self.optional && is_nullish(self.expression, compressor)) {
27587
- return make_node(AST_Undefined, self);
27588
- }
27589
27634
  return self;
27590
27635
  });
27591
27636
 
@@ -27645,9 +27690,11 @@ function inline_object_prop_spread(props, compressor) {
27645
27690
  // non-iterable value silently does nothing; it is thus safe
27646
27691
  // to remove. AST_String is the only iterable AST_Constant.
27647
27692
  props.splice(i, 1);
27693
+ i--;
27648
27694
  } else if (is_nullish(expr, compressor)) {
27649
27695
  // Likewise, null and undefined can be silently removed.
27650
27696
  props.splice(i, 1);
27697
+ i--;
27651
27698
  }
27652
27699
  }
27653
27700
  }
@@ -35966,9 +36013,6 @@ function mangle_properties(ast, options) {
35966
36013
  var cache;
35967
36014
  if (options.cache) {
35968
36015
  cache = options.cache.props;
35969
- cache.forEach(function(mangled_name) {
35970
- reserved.add(mangled_name);
35971
- });
35972
36016
  } else {
35973
36017
  cache = new Map();
35974
36018
  }
@@ -35986,6 +36030,9 @@ function mangle_properties(ast, options) {
35986
36030
 
35987
36031
  var names_to_mangle = new Set();
35988
36032
  var unmangleable = new Set();
36033
+ // Track each already-mangled name to prevent nth_identifier from generating
36034
+ // the same name.
36035
+ cache.forEach((mangled_name) => unmangleable.add(mangled_name));
35989
36036
 
35990
36037
  var keep_quoted = !!options.keep_quoted;
35991
36038
 
@@ -36229,6 +36276,7 @@ async function minify(files, options) {
36229
36276
  keep_classnames: false,
36230
36277
  keep_fnames: false,
36231
36278
  module: false,
36279
+ nth_identifier: base54,
36232
36280
  properties: false,
36233
36281
  reserved: [],
36234
36282
  safari10: false,
@@ -36880,4 +36928,3 @@ exports.minify = minify;
36880
36928
  var bundle_min = bundle_min$1.exports;
36881
36929
 
36882
36930
  module.exports = bundle_min;
36883
- //# sourceMappingURL=terser.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "2.6.0-beta.0",
3
+ "version": "2.6.0-beta.4",
4
4
  "license": "MIT",
5
5
  "author": "Evan You",
6
6
  "description": "Native-ESM powered web dev build tool",
@@ -13,9 +13,8 @@
13
13
  "bin",
14
14
  "dist",
15
15
  "client.d.ts",
16
- "src",
17
- "types",
18
- "!/src/**/__tests__/"
16
+ "src/client",
17
+ "types"
19
18
  ],
20
19
  "engines": {
21
20
  "node": ">=12.2.0"
@@ -32,12 +31,12 @@
32
31
  "scripts": {
33
32
  "predev": "rimraf dist",
34
33
  "dev": "rollup -c -w",
35
- "prebuild": "rimraf dist && yarn lint",
34
+ "prebuild": "rimraf dist && npm run lint",
36
35
  "build": "run-s build-bundle build-types",
37
36
  "build-bundle": "rollup -c",
38
37
  "build-types": "run-s build-temp-types patch-types roll-types",
39
38
  "build-temp-types": "tsc --emitDeclarationOnly --outDir temp/node -p src/node",
40
- "ci-build": "rimraf dist && yarn run-s build-bundle build-types",
39
+ "ci-build": "rimraf dist && run-s build-bundle build-types",
41
40
  "patch-types": "node scripts/patchTypes",
42
41
  "roll-types": "api-extractor run && rimraf temp",
43
42
  "lint": "eslint --ext .ts src/**",
@@ -47,10 +46,10 @@
47
46
  },
48
47
  "//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!",
49
48
  "dependencies": {
50
- "esbuild": "^0.12.17",
51
- "postcss": "^8.3.6",
49
+ "esbuild": "^0.13.2",
50
+ "postcss": "^8.3.8",
52
51
  "resolve": "^1.20.0",
53
- "rollup": "^2.38.5"
52
+ "rollup": "^2.57.0"
54
53
  },
55
54
  "optionalDependencies": {
56
55
  "fsevents": "~2.3.2"
@@ -61,7 +60,7 @@
61
60
  "@rollup/plugin-commonjs": "^20.0.0",
62
61
  "@rollup/plugin-dynamic-import-vars": "^1.4.0",
63
62
  "@rollup/plugin-json": "^4.1.0",
64
- "@rollup/plugin-node-resolve": "13.0.4",
63
+ "@rollup/plugin-node-resolve": "13.0.5",
65
64
  "@rollup/plugin-typescript": "^8.2.5",
66
65
  "@rollup/pluginutils": "^4.1.1",
67
66
  "@types/convert-source-map": "^1.5.2",
@@ -76,7 +75,7 @@
76
75
  "@types/sass": "^1.16.1",
77
76
  "@types/stylus": "^0.48.36",
78
77
  "@types/ws": "^7.4.7",
79
- "@vue/compiler-dom": "^3.2.12",
78
+ "@vue/compiler-dom": "^3.2.19",
80
79
  "acorn": "^8.5.0",
81
80
  "acorn-class-fields": "^1.0.0",
82
81
  "acorn-static-class-features": "^1.0.0",
@@ -92,7 +91,7 @@
92
91
  "debug": "^4.3.2",
93
92
  "dotenv": "^10.0.0",
94
93
  "dotenv-expand": "^5.1.0",
95
- "es-module-lexer": "^0.8.0",
94
+ "es-module-lexer": "^0.9.0",
96
95
  "estree-walker": "^2.0.2",
97
96
  "etag": "^1.8.1",
98
97
  "execa": "^5.1.1",
@@ -115,10 +114,26 @@
115
114
  "source-map": "^0.6.1",
116
115
  "source-map-support": "^0.5.20",
117
116
  "strip-ansi": "^6.0.0",
118
- "terser": "^5.8.0",
117
+ "terser": "^5.9.0",
119
118
  "tsconfck": "^1.0.0",
120
119
  "tslib": "^2.3.1",
121
120
  "types": "link:./types",
122
121
  "ws": "^7.5.5"
122
+ },
123
+ "peerDependencies": {
124
+ "less": "*",
125
+ "sass": "*",
126
+ "stylus": "*"
127
+ },
128
+ "peerDependenciesMeta": {
129
+ "sass": {
130
+ "optional": true
131
+ },
132
+ "stylus": {
133
+ "optional": true
134
+ },
135
+ "less": {
136
+ "optional": true
137
+ }
123
138
  }
124
139
  }
@@ -0,0 +1,3 @@
1
+ {
2
+ "//": "this file is just here to make pnpm happy with --frozen-lockfile"
3
+ }
@@ -1,54 +0,0 @@
1
- {
2
- "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
-
4
- "projectFolder": "./src/node",
5
-
6
- "mainEntryPointFilePath": "./temp/node/index.d.ts",
7
-
8
- "dtsRollup": {
9
- "enabled": true,
10
- "untrimmedFilePath": "",
11
- "publicTrimmedFilePath": "./dist/node/index.d.ts"
12
- },
13
-
14
- "apiReport": {
15
- "enabled": false
16
- },
17
-
18
- "docModel": {
19
- "enabled": false
20
- },
21
-
22
- "tsdocMetadata": {
23
- "enabled": false
24
- },
25
-
26
- "messages": {
27
- "compilerMessageReporting": {
28
- "default": {
29
- "logLevel": "warning"
30
- }
31
- },
32
-
33
- "extractorMessageReporting": {
34
- "default": {
35
- "logLevel": "warning",
36
- "addToApiReportFile": true
37
- },
38
-
39
- "ae-missing-release-tag": {
40
- "logLevel": "none"
41
- }
42
- },
43
-
44
- "tsdocMessageReporting": {
45
- "default": {
46
- "logLevel": "warning"
47
- },
48
-
49
- "tsdoc-undefined-tag": {
50
- "logLevel": "none"
51
- }
52
- }
53
- }
54
- }