vite 5.0.0-beta.1 → 5.0.0-beta.2

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.
package/dist/node/cli.js CHANGED
@@ -2,7 +2,7 @@ import path from 'node:path';
2
2
  import fs from 'node:fs';
3
3
  import { performance } from 'node:perf_hooks';
4
4
  import { EventEmitter } from 'events';
5
- import { C as colors, x as createLogger, h as resolveConfig } from './chunks/dep-e31699fa.js';
5
+ import { C as colors, x as createLogger, h as resolveConfig } from './chunks/dep-82f73734.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -31,13 +31,13 @@ import 'node:assert';
31
31
  import 'node:process';
32
32
  import 'node:v8';
33
33
  import 'rollup';
34
- import 'worker_threads';
35
34
  import 'node:http';
36
35
  import 'node:https';
37
36
  import 'zlib';
38
37
  import 'buffer';
39
38
  import 'https';
40
39
  import 'tls';
40
+ import 'worker_threads';
41
41
  import 'querystring';
42
42
  import 'node:readline';
43
43
  import 'node:zlib';
@@ -758,7 +758,7 @@ cli
758
758
  filterDuplicateOptions(options);
759
759
  // output structure is preserved even after bundling so require()
760
760
  // is ok here
761
- const { createServer } = await import('./chunks/dep-e31699fa.js').then(function (n) { return n.H; });
761
+ const { createServer } = await import('./chunks/dep-82f73734.js').then(function (n) { return n.H; });
762
762
  try {
763
763
  const server = await createServer({
764
764
  root,
@@ -836,7 +836,7 @@ cli
836
836
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
837
837
  .action(async (root, options) => {
838
838
  filterDuplicateOptions(options);
839
- const { build } = await import('./chunks/dep-e31699fa.js').then(function (n) { return n.G; });
839
+ const { build } = await import('./chunks/dep-82f73734.js').then(function (n) { return n.G; });
840
840
  const buildOptions = cleanOptions(options);
841
841
  try {
842
842
  await build({
@@ -864,7 +864,7 @@ cli
864
864
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
865
865
  .action(async (root, options) => {
866
866
  filterDuplicateOptions(options);
867
- const { optimizeDeps } = await import('./chunks/dep-e31699fa.js').then(function (n) { return n.F; });
867
+ const { optimizeDeps } = await import('./chunks/dep-82f73734.js').then(function (n) { return n.F; });
868
868
  try {
869
869
  const config = await resolveConfig({
870
870
  root,
@@ -891,7 +891,7 @@ cli
891
891
  .option('--outDir <dir>', `[string] output directory (default: dist)`)
892
892
  .action(async (root, options) => {
893
893
  filterDuplicateOptions(options);
894
- const { preview } = await import('./chunks/dep-e31699fa.js').then(function (n) { return n.I; });
894
+ const { preview } = await import('./chunks/dep-82f73734.js').then(function (n) { return n.I; });
895
895
  try {
896
896
  const server = await preview({
897
897
  root,
@@ -296,7 +296,6 @@ export declare interface BuildOptions {
296
296
  ssrManifest?: boolean | string;
297
297
  /**
298
298
  * Emit assets during SSR.
299
- * @experimental
300
299
  * @default false
301
300
  */
302
301
  ssrEmitAssets?: boolean;
@@ -1586,7 +1585,7 @@ declare interface Plugin_2 extends Plugin_3 {
1586
1585
  * Note: User plugins are resolved before running this hook so injecting other
1587
1586
  * plugins inside the `config` hook will have no effect.
1588
1587
  */
1589
- config?: ObjectHook<(this: void, config: UserConfig, env: ConfigEnv) => UserConfig | null | void | Promise<UserConfig | null | void>>;
1588
+ config?: ObjectHook<(this: void, config: UserConfig, env: ConfigEnv) => Omit<UserConfig, 'plugins'> | null | void | Promise<Omit<UserConfig, 'plugins'> | null | void>>;
1590
1589
  /**
1591
1590
  * Use this hook to read and store the final resolved vite config.
1592
1591
  */
@@ -1,5 +1,5 @@
1
- import { i as isInNodeModules } from './chunks/dep-e31699fa.js';
2
- export { b as build, e as buildErrorMessage, v as createFilter, x as createLogger, c as createServer, g as defineConfig, f as formatPostcssSourceMap, k as getDepOptimizationConfig, m as isDepsOptimizerEnabled, z as isFileServingAllowed, l as loadConfigFromFile, A as loadEnv, u as mergeAlias, q as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, j as resolveBaseUrl, h as resolveConfig, B as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, y as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-e31699fa.js';
1
+ import { i as isInNodeModules } from './chunks/dep-82f73734.js';
2
+ export { b as build, e as buildErrorMessage, v as createFilter, x as createLogger, c as createServer, g as defineConfig, f as formatPostcssSourceMap, k as getDepOptimizationConfig, m as isDepsOptimizerEnabled, z as isFileServingAllowed, l as loadConfigFromFile, A as loadEnv, u as mergeAlias, q as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, j as resolveBaseUrl, h as resolveConfig, B as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, y as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-82f73734.js';
3
3
  export { VERSION as version } from './constants.js';
4
4
  export { version as esbuildVersion } from 'esbuild';
5
5
  export { VERSION as rollupVersion } from 'rollup';
@@ -32,13 +32,13 @@ import 'module';
32
32
  import 'node:assert';
33
33
  import 'node:process';
34
34
  import 'node:v8';
35
- import 'worker_threads';
36
35
  import 'node:http';
37
36
  import 'node:https';
38
37
  import 'zlib';
39
38
  import 'buffer';
40
39
  import 'https';
41
40
  import 'tls';
41
+ import 'worker_threads';
42
42
  import 'querystring';
43
43
  import 'node:readline';
44
44
  import 'node:zlib';
@@ -1228,7 +1228,7 @@ if (typeof process === 'undefined' || process.type === 'renderer' || process.bro
1228
1228
  }
1229
1229
 
1230
1230
  var srcExports = src.exports;
1231
- var debug$1 = /*@__PURE__*/getDefaultExportFromCjs(srcExports);
1231
+ var debug$2 = /*@__PURE__*/getDefaultExportFromCjs(srcExports);
1232
1232
 
1233
1233
  var utils$3 = {};
1234
1234
 
@@ -3385,7 +3385,7 @@ const _require = node_module.createRequire((typeof document === 'undefined' ? re
3385
3385
  const filter = process.env.VITE_DEBUG_FILTER;
3386
3386
  const DEBUG = process.env.DEBUG;
3387
3387
  function createDebugger(namespace, options = {}) {
3388
- const log = debug$1(namespace);
3388
+ const log = debug$2(namespace);
3389
3389
  const { onlyWhenFocused } = options;
3390
3390
  let enabled = log.enabled;
3391
3391
  if (enabled && onlyWhenFocused) {
@@ -3704,6 +3704,245 @@ function splitVendorChunkPlugin() {
3704
3704
  };
3705
3705
  }
3706
3706
 
3707
+ var convertSourceMap$1 = {};
3708
+
3709
+ (function (exports) {
3710
+
3711
+ Object.defineProperty(exports, 'commentRegex', {
3712
+ get: function getCommentRegex () {
3713
+ // Groups: 1: media type, 2: MIME type, 3: charset, 4: encoding, 5: data.
3714
+ return /^\s*?\/[\/\*][@#]\s+?sourceMappingURL=data:(((?:application|text)\/json)(?:;charset=([^;,]+?)?)?)?(?:;(base64))?,(.*?)$/mg;
3715
+ }
3716
+ });
3717
+
3718
+
3719
+ Object.defineProperty(exports, 'mapFileCommentRegex', {
3720
+ get: function getMapFileCommentRegex () {
3721
+ // Matches sourceMappingURL in either // or /* comment styles.
3722
+ return /(?:\/\/[@#][ \t]+?sourceMappingURL=([^\s'"`]+?)[ \t]*?$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^*]+?)[ \t]*?(?:\*\/){1}[ \t]*?$)/mg;
3723
+ }
3724
+ });
3725
+
3726
+ var decodeBase64;
3727
+ if (typeof Buffer !== 'undefined') {
3728
+ if (typeof Buffer.from === 'function') {
3729
+ decodeBase64 = decodeBase64WithBufferFrom;
3730
+ } else {
3731
+ decodeBase64 = decodeBase64WithNewBuffer;
3732
+ }
3733
+ } else {
3734
+ decodeBase64 = decodeBase64WithAtob;
3735
+ }
3736
+
3737
+ function decodeBase64WithBufferFrom(base64) {
3738
+ return Buffer.from(base64, 'base64').toString();
3739
+ }
3740
+
3741
+ function decodeBase64WithNewBuffer(base64) {
3742
+ if (typeof value === 'number') {
3743
+ throw new TypeError('The value to decode must not be of type number.');
3744
+ }
3745
+ return new Buffer(base64, 'base64').toString();
3746
+ }
3747
+
3748
+ function decodeBase64WithAtob(base64) {
3749
+ return decodeURIComponent(escape(atob(base64)));
3750
+ }
3751
+
3752
+ function stripComment(sm) {
3753
+ return sm.split(',').pop();
3754
+ }
3755
+
3756
+ function readFromFileMap(sm, read) {
3757
+ var r = exports.mapFileCommentRegex.exec(sm);
3758
+ // for some odd reason //# .. captures in 1 and /* .. */ in 2
3759
+ var filename = r[1] || r[2];
3760
+
3761
+ try {
3762
+ var sm = read(filename);
3763
+ if (sm != null && typeof sm.catch === 'function') {
3764
+ return sm.catch(throwError);
3765
+ } else {
3766
+ return sm;
3767
+ }
3768
+ } catch (e) {
3769
+ throwError(e);
3770
+ }
3771
+
3772
+ function throwError(e) {
3773
+ throw new Error('An error occurred while trying to read the map file at ' + filename + '\n' + e.stack);
3774
+ }
3775
+ }
3776
+
3777
+ function Converter (sm, opts) {
3778
+ opts = opts || {};
3779
+
3780
+ if (opts.hasComment) {
3781
+ sm = stripComment(sm);
3782
+ }
3783
+
3784
+ if (opts.encoding === 'base64') {
3785
+ sm = decodeBase64(sm);
3786
+ } else if (opts.encoding === 'uri') {
3787
+ sm = decodeURIComponent(sm);
3788
+ }
3789
+
3790
+ if (opts.isJSON || opts.encoding) {
3791
+ sm = JSON.parse(sm);
3792
+ }
3793
+
3794
+ this.sourcemap = sm;
3795
+ }
3796
+
3797
+ Converter.prototype.toJSON = function (space) {
3798
+ return JSON.stringify(this.sourcemap, null, space);
3799
+ };
3800
+
3801
+ if (typeof Buffer !== 'undefined') {
3802
+ if (typeof Buffer.from === 'function') {
3803
+ Converter.prototype.toBase64 = encodeBase64WithBufferFrom;
3804
+ } else {
3805
+ Converter.prototype.toBase64 = encodeBase64WithNewBuffer;
3806
+ }
3807
+ } else {
3808
+ Converter.prototype.toBase64 = encodeBase64WithBtoa;
3809
+ }
3810
+
3811
+ function encodeBase64WithBufferFrom() {
3812
+ var json = this.toJSON();
3813
+ return Buffer.from(json, 'utf8').toString('base64');
3814
+ }
3815
+
3816
+ function encodeBase64WithNewBuffer() {
3817
+ var json = this.toJSON();
3818
+ if (typeof json === 'number') {
3819
+ throw new TypeError('The json to encode must not be of type number.');
3820
+ }
3821
+ return new Buffer(json, 'utf8').toString('base64');
3822
+ }
3823
+
3824
+ function encodeBase64WithBtoa() {
3825
+ var json = this.toJSON();
3826
+ return btoa(unescape(encodeURIComponent(json)));
3827
+ }
3828
+
3829
+ Converter.prototype.toURI = function () {
3830
+ var json = this.toJSON();
3831
+ return encodeURIComponent(json);
3832
+ };
3833
+
3834
+ Converter.prototype.toComment = function (options) {
3835
+ var encoding, content, data;
3836
+ if (options != null && options.encoding === 'uri') {
3837
+ encoding = '';
3838
+ content = this.toURI();
3839
+ } else {
3840
+ encoding = ';base64';
3841
+ content = this.toBase64();
3842
+ }
3843
+ data = 'sourceMappingURL=data:application/json;charset=utf-8' + encoding + ',' + content;
3844
+ return options != null && options.multiline ? '/*# ' + data + ' */' : '//# ' + data;
3845
+ };
3846
+
3847
+ // returns copy instead of original
3848
+ Converter.prototype.toObject = function () {
3849
+ return JSON.parse(this.toJSON());
3850
+ };
3851
+
3852
+ Converter.prototype.addProperty = function (key, value) {
3853
+ if (this.sourcemap.hasOwnProperty(key)) throw new Error('property "' + key + '" already exists on the sourcemap, use set property instead');
3854
+ return this.setProperty(key, value);
3855
+ };
3856
+
3857
+ Converter.prototype.setProperty = function (key, value) {
3858
+ this.sourcemap[key] = value;
3859
+ return this;
3860
+ };
3861
+
3862
+ Converter.prototype.getProperty = function (key) {
3863
+ return this.sourcemap[key];
3864
+ };
3865
+
3866
+ exports.fromObject = function (obj) {
3867
+ return new Converter(obj);
3868
+ };
3869
+
3870
+ exports.fromJSON = function (json) {
3871
+ return new Converter(json, { isJSON: true });
3872
+ };
3873
+
3874
+ exports.fromURI = function (uri) {
3875
+ return new Converter(uri, { encoding: 'uri' });
3876
+ };
3877
+
3878
+ exports.fromBase64 = function (base64) {
3879
+ return new Converter(base64, { encoding: 'base64' });
3880
+ };
3881
+
3882
+ exports.fromComment = function (comment) {
3883
+ var m, encoding;
3884
+ comment = comment
3885
+ .replace(/^\/\*/g, '//')
3886
+ .replace(/\*\/$/g, '');
3887
+ m = exports.commentRegex.exec(comment);
3888
+ encoding = m && m[4] || 'uri';
3889
+ return new Converter(comment, { encoding: encoding, hasComment: true });
3890
+ };
3891
+
3892
+ function makeConverter(sm) {
3893
+ return new Converter(sm, { isJSON: true });
3894
+ }
3895
+
3896
+ exports.fromMapFileComment = function (comment, read) {
3897
+ if (typeof read === 'string') {
3898
+ throw new Error(
3899
+ 'String directory paths are no longer supported with `fromMapFileComment`\n' +
3900
+ 'Please review the Upgrading documentation at https://github.com/thlorenz/convert-source-map#upgrading'
3901
+ )
3902
+ }
3903
+
3904
+ var sm = readFromFileMap(comment, read);
3905
+ if (sm != null && typeof sm.then === 'function') {
3906
+ return sm.then(makeConverter);
3907
+ } else {
3908
+ return makeConverter(sm);
3909
+ }
3910
+ };
3911
+
3912
+ // Finds last sourcemap comment in file or returns null if none was found
3913
+ exports.fromSource = function (content) {
3914
+ var m = content.match(exports.commentRegex);
3915
+ return m ? exports.fromComment(m.pop()) : null;
3916
+ };
3917
+
3918
+ // Finds last sourcemap comment in file or returns null if none was found
3919
+ exports.fromMapFileSource = function (content, read) {
3920
+ if (typeof read === 'string') {
3921
+ throw new Error(
3922
+ 'String directory paths are no longer supported with `fromMapFileSource`\n' +
3923
+ 'Please review the Upgrading documentation at https://github.com/thlorenz/convert-source-map#upgrading'
3924
+ )
3925
+ }
3926
+ var m = content.match(exports.mapFileCommentRegex);
3927
+ return m ? exports.fromMapFileComment(m.pop(), read) : null;
3928
+ };
3929
+
3930
+ exports.removeComments = function (src) {
3931
+ return src.replace(exports.commentRegex, '');
3932
+ };
3933
+
3934
+ exports.removeMapFileComments = function (src) {
3935
+ return src.replace(exports.mapFileCommentRegex, '');
3936
+ };
3937
+
3938
+ exports.generateMapFileComment = function (file, options) {
3939
+ var data = 'sourceMappingURL=' + file;
3940
+ return options && options.multiline ? '/*# ' + data + ' */' : '//# ' + data;
3941
+ };
3942
+ } (convertSourceMap$1));
3943
+
3944
+ var convertSourceMap = /*@__PURE__*/getDefaultExportFromCjs(convertSourceMap$1);
3945
+
3707
3946
  /*!
3708
3947
  * etag
3709
3948
  * Copyright(c) 2014-2016 Douglas Christopher Wilson
@@ -4016,7 +4255,7 @@ function getBtoa() {
4016
4255
  }
4017
4256
  }
4018
4257
 
4019
- const btoa = /*#__PURE__*/ getBtoa();
4258
+ const btoa$1 = /*#__PURE__*/ getBtoa();
4020
4259
 
4021
4260
  class SourceMap {
4022
4261
  constructor(properties) {
@@ -4036,7 +4275,7 @@ class SourceMap {
4036
4275
  }
4037
4276
 
4038
4277
  toUrl() {
4039
- return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());
4278
+ return 'data:application/json;charset=utf-8;base64,' + btoa$1(this.toString());
4040
4279
  }
4041
4280
  }
4042
4281
 
@@ -5003,7 +5242,7 @@ class MagicString {
5003
5242
  }
5004
5243
  }
5005
5244
 
5006
- const debug = createDebugger('vite:sourcemap', {
5245
+ const debug$1 = createDebugger('vite:sourcemap', {
5007
5246
  onlyWhenFocused: true,
5008
5247
  });
5009
5248
  function genSourceMapUrl(map) {
@@ -5013,7 +5252,7 @@ function genSourceMapUrl(map) {
5013
5252
  return `data:application/json;base64,${Buffer.from(map).toString('base64')}`;
5014
5253
  }
5015
5254
  function getCodeWithSourcemap(type, code, map) {
5016
- if (debug) {
5255
+ if (debug$1) {
5017
5256
  code += `\n/*${JSON.stringify(map, null, 2).replace(/\*\//g, '*\\/')}*/\n`;
5018
5257
  }
5019
5258
  if (type === 'js') {
@@ -5025,6 +5264,9 @@ function getCodeWithSourcemap(type, code, map) {
5025
5264
  return code;
5026
5265
  }
5027
5266
 
5267
+ const debug = createDebugger('vite:send', {
5268
+ onlyWhenFocused: true,
5269
+ });
5028
5270
  const alias = {
5029
5271
  js: 'application/javascript',
5030
5272
  css: 'text/css',
@@ -5055,11 +5297,22 @@ function send(req, res, content, type, options) {
5055
5297
  content = getCodeWithSourcemap(type, content.toString(), map);
5056
5298
  }
5057
5299
  }
5058
- else {
5059
- if (type === 'js' && (!map || map.mappings !== '')) {
5300
+ // inject fallback sourcemap for js for improved debugging
5301
+ // https://github.com/vitejs/vite/pull/13514#issuecomment-1592431496
5302
+ else if (type === 'js' && (!map || map.mappings !== '')) {
5303
+ const code = content.toString();
5304
+ // if the code has existing inline sourcemap, assume it's correct and skip
5305
+ if (convertSourceMap.mapFileCommentRegex.test(code)) {
5306
+ debug?.(`Skipped injecting fallback sourcemap for ${req.url}`);
5307
+ }
5308
+ else {
5060
5309
  const urlWithoutTimestamp = removeTimestampQuery(req.url);
5061
- const ms = new MagicString(content.toString());
5062
- content = getCodeWithSourcemap(type, content.toString(), ms.generateMap({ source: urlWithoutTimestamp, hires: 'boundary' }));
5310
+ const ms = new MagicString(code);
5311
+ content = getCodeWithSourcemap(type, code, ms.generateMap({
5312
+ source: path$3.basename(urlWithoutTimestamp),
5313
+ hires: 'boundary',
5314
+ includeContent: true,
5315
+ }));
5063
5316
  }
5064
5317
  }
5065
5318
  res.statusCode = 200;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "5.0.0-beta.1",
3
+ "version": "5.0.0-beta.2",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",
@@ -65,7 +65,7 @@
65
65
  "devDependencies": {
66
66
  "@ampproject/remapping": "^2.2.1",
67
67
  "@babel/parser": "^7.22.7",
68
- "@babel/types": "^7.22.5",
68
+ "@babel/types": "^7.22.17",
69
69
  "@jridgewell/trace-mapping": "^0.3.18",
70
70
  "@rollup/plugin-alias": "^4.0.4",
71
71
  "@rollup/plugin-commonjs": "^25.0.3",
@@ -77,6 +77,7 @@
77
77
  "@types/escape-html": "^1.0.2",
78
78
  "@types/pnpapi": "^0.0.2",
79
79
  "acorn": "^8.10.0",
80
+ "acorn-import-assertions": "^1.9.0",
80
81
  "acorn-walk": "^8.2.0",
81
82
  "cac": "^6.7.14",
82
83
  "chokidar": "^3.5.3",
@@ -105,7 +106,7 @@
105
106
  "okie": "^1.0.1",
106
107
  "open": "^8.4.2",
107
108
  "parse5": "^7.1.2",
108
- "periscopic": "^3.1.0",
109
+ "periscopic": "^4.0.2",
109
110
  "picocolors": "^1.0.0",
110
111
  "picomatch": "^2.3.1",
111
112
  "postcss-import": "^15.1.0",
@@ -117,7 +118,7 @@
117
118
  "source-map-support": "^0.5.21",
118
119
  "strip-ansi": "^7.1.0",
119
120
  "strip-literal": "^1.3.0",
120
- "tsconfck": "^2.1.2",
121
+ "tsconfck": "^3.0.0-next.8",
121
122
  "tslib": "^2.6.1",
122
123
  "types": "link:./types",
123
124
  "ufo": "^1.2.0",