vite 2.4.0-beta.1 → 2.4.1

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 (41) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/LICENSE.md +95 -0
  3. package/client.d.ts +1 -1
  4. package/dist/client/{client.js → client.mjs} +1 -1
  5. package/dist/client/client.mjs.map +1 -0
  6. package/dist/client/{env.js → env.mjs} +1 -1
  7. package/dist/client/env.mjs.map +1 -0
  8. package/dist/node/chunks/{dep-1e79df13.js → dep-7db2a04d.js} +14 -8
  9. package/dist/node/chunks/dep-7db2a04d.js.map +1 -0
  10. package/dist/node/chunks/{dep-d89c6c28.js → dep-b2288281.js} +2 -2
  11. package/dist/node/chunks/{dep-d89c6c28.js.map → dep-b2288281.js.map} +1 -1
  12. package/dist/node/chunks/{dep-3136f934.js → dep-cb9bf5e2.js} +2 -2
  13. package/dist/node/chunks/{dep-3136f934.js.map → dep-cb9bf5e2.js.map} +1 -1
  14. package/dist/node/chunks/{dep-200de8ae.js → dep-cc49d7be.js} +282 -310
  15. package/dist/node/chunks/dep-cc49d7be.js.map +1 -0
  16. package/dist/node/chunks/{dep-e462ce9f.js → dep-d25c0094.js} +2 -2
  17. package/dist/node/chunks/{dep-e462ce9f.js.map → dep-d25c0094.js.map} +1 -1
  18. package/dist/node/cli.js +4 -4
  19. package/dist/node/index.d.ts +13 -0
  20. package/dist/node/index.js +1 -1
  21. package/package.json +9 -9
  22. package/rollup.config.js +2 -2
  23. package/src/node/__tests__/scan.spec.ts +33 -1
  24. package/src/node/build.ts +1 -4
  25. package/src/node/config.ts +1 -0
  26. package/src/node/constants.ts +2 -2
  27. package/src/node/optimizer/esbuildDepPlugin.ts +1 -1
  28. package/src/node/optimizer/index.ts +7 -5
  29. package/src/node/optimizer/scan.ts +3 -2
  30. package/src/node/plugins/css.ts +7 -6
  31. package/src/node/plugins/importAnalysisBuild.ts +5 -1
  32. package/src/node/server/hmr.ts +5 -5
  33. package/src/node/server/middlewares/base.ts +9 -1
  34. package/src/node/server/openBrowser.ts +1 -1
  35. package/src/node/ssr/__tests__/ssrTransform.spec.ts +49 -1
  36. package/src/node/ssr/ssrTransform.ts +18 -5
  37. package/types/commonjs.d.ts +12 -0
  38. package/dist/client/client.js.map +0 -1
  39. package/dist/client/env.js.map +0 -1
  40. package/dist/node/chunks/dep-1e79df13.js.map +0 -1
  41. package/dist/node/chunks/dep-200de8ae.js.map +0 -1
@@ -24,7 +24,7 @@ var require$$4 = require('vm');
24
24
  var require$$7 = require('console');
25
25
  var esbuild = require('esbuild');
26
26
  var require$$1$3 = require('worker_threads');
27
- var require$$2$1 = require('child_process');
27
+ var require$$1$5 = require('child_process');
28
28
  var readline = require('readline');
29
29
 
30
30
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e['default'] : e; }
@@ -66,7 +66,7 @@ var require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3$1);
66
66
  var require$$4__default = /*#__PURE__*/_interopDefaultLegacy(require$$4);
67
67
  var require$$7__default = /*#__PURE__*/_interopDefaultLegacy(require$$7);
68
68
  var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1$3);
69
- var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2$1);
69
+ var require$$1__default$3 = /*#__PURE__*/_interopDefaultLegacy(require$$1$5);
70
70
  var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);
71
71
 
72
72
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
@@ -3181,9 +3181,9 @@ const NULL_BYTE_PLACEHOLDER = `__x00__`;
3181
3181
  const CLIENT_PUBLIC_PATH = `/@vite/client`;
3182
3182
  const ENV_PUBLIC_PATH = `/@vite/env`;
3183
3183
  // eslint-disable-next-line node/no-missing-require
3184
- const CLIENT_ENTRY = require.resolve('vite/dist/client/client.js');
3184
+ const CLIENT_ENTRY = require.resolve('vite/dist/client/client.mjs');
3185
3185
  // eslint-disable-next-line node/no-missing-require
3186
- const ENV_ENTRY = require.resolve('vite/dist/client/env.js');
3186
+ const ENV_ENTRY = require.resolve('vite/dist/client/env.mjs');
3187
3187
  const CLIENT_DIR = path__default.dirname(CLIENT_ENTRY);
3188
3188
  const KNOWN_ASSET_TYPES = [
3189
3189
  // images
@@ -11777,14 +11777,14 @@ const stream_1$8 = stream$8;
11777
11777
  const sync_1$4 = sync$9;
11778
11778
  const settings_1$2 = settings$2;
11779
11779
  out$3.Settings = settings_1$2.default;
11780
- function walk$4(directory, optionsOrSettingsOrCallback, callback) {
11780
+ function walk$3(directory, optionsOrSettingsOrCallback, callback) {
11781
11781
  if (typeof optionsOrSettingsOrCallback === 'function') {
11782
11782
  new async_1$2.default(directory, getSettings()).read(optionsOrSettingsOrCallback);
11783
11783
  return;
11784
11784
  }
11785
11785
  new async_1$2.default(directory, getSettings(optionsOrSettingsOrCallback)).read(callback);
11786
11786
  }
11787
- out$3.walk = walk$4;
11787
+ out$3.walk = walk$3;
11788
11788
  function walkSync(directory, optionsOrSettings) {
11789
11789
  const settings = getSettings(optionsOrSettings);
11790
11790
  const provider = new sync_1$4.default(directory, settings);
@@ -27923,7 +27923,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
27923
27923
  replacer: urlReplacer
27924
27924
  }));
27925
27925
  if (isModule) {
27926
- postcssPlugins.unshift((await Promise.resolve().then(function () { return require('./dep-d89c6c28.js'); }).then(function (n) { return n.index; })).default({
27926
+ postcssPlugins.unshift((await Promise.resolve().then(function () { return require('./dep-b2288281.js'); }).then(function (n) { return n.index; })).default({
27927
27927
  ...modulesOptions,
27928
27928
  getJSON(cssFileName, _modules, outputFileName) {
27929
27929
  modules = _modules;
@@ -28029,7 +28029,7 @@ async function resolvePostcssConfig(config) {
28029
28029
  }
28030
28030
  }
28031
28031
  // https://drafts.csswg.org/css-syntax-3/#identifier-code-point
28032
- const cssUrlRE = /(?:^|[^\w\-\u0080-\uffff])url\(\s*('[^']+'|"[^"]+"|[^'")]+)\s*\)/;
28032
+ const cssUrlRE = /(?<=^|[^\w\-\u0080-\uffff])url\(\s*('[^']+'|"[^"]+"|[^'")]+)\s*\)/;
28033
28033
  const cssImageSetRE = /image-set\(([^)]+)\)/;
28034
28034
  const UrlRewritePostcssPlugin = (opts) => {
28035
28035
  if (!opts) {
@@ -28084,13 +28084,11 @@ async function doUrlReplace(rawUrl, matched, replacer) {
28084
28084
  if (isExternalUrl(rawUrl) || isDataUrl(rawUrl) || rawUrl.startsWith('#')) {
28085
28085
  return matched;
28086
28086
  }
28087
- // #3926
28088
- const initialComma = matched[0] === ',' ? ',' : '';
28089
- return `${initialComma}url(${wrap}${await replacer(rawUrl)}${wrap})`;
28087
+ return `url(${wrap}${await replacer(rawUrl)}${wrap})`;
28090
28088
  }
28091
28089
  let CleanCSS;
28092
28090
  async function minifyCSS(css, config) {
28093
- CleanCSS = CleanCSS || (await Promise.resolve().then(function () { return require('./dep-3136f934.js'); }).then(function (n) { return n.index; })).default;
28091
+ CleanCSS = CleanCSS || (await Promise.resolve().then(function () { return require('./dep-cb9bf5e2.js'); }).then(function (n) { return n.index; })).default;
28094
28092
  const res = new CleanCSS({
28095
28093
  rebase: false,
28096
28094
  ...config.build.cleanCssOptions
@@ -28136,7 +28134,10 @@ function loadPreprocessor(lang, root) {
28136
28134
  return loadedPreprocessors[lang];
28137
28135
  }
28138
28136
  try {
28139
- const resolved = require.resolve(lang, { paths: [root] });
28137
+ // Search for the preprocessor in the root directory first, and fall back
28138
+ // to the default require paths.
28139
+ const fallbackPaths = require.resolve.paths(lang) || [];
28140
+ const resolved = require.resolve(lang, { paths: [root, ...fallbackPaths] });
28140
28141
  return (loadedPreprocessors[lang] = require(resolved));
28141
28142
  }
28142
28143
  catch (e) {
@@ -28613,7 +28614,9 @@ function buildImportAnalysisPlugin(config) {
28613
28614
  str().overwrite(dynamicIndex, dynamicEnd, replacement);
28614
28615
  }
28615
28616
  }
28616
- if (needPreloadHelper && !ssr) {
28617
+ if (needPreloadHelper &&
28618
+ !ssr &&
28619
+ !source.includes(`const ${preloadMethod} =`)) {
28617
28620
  str().prepend(`import { ${preloadMethod} } from "${preloadHelperId}";`);
28618
28621
  }
28619
28622
  if (s) {
@@ -28858,7 +28861,7 @@ const assetAttrsConfig = {
28858
28861
  };
28859
28862
  async function traverseHtml(html, filePath, visitor) {
28860
28863
  // lazy load compiler
28861
- const { parse, transform } = await Promise.resolve().then(function () { return require('./dep-1e79df13.js'); }).then(function (n) { return n.compilerDom_cjs; });
28864
+ const { parse, transform } = await Promise.resolve().then(function () { return require('./dep-7db2a04d.js'); }).then(function (n) { return n.compilerDom_cjs; });
28862
28865
  // @vue/compiler-core doesn't like lowercase doctypes
28863
28866
  html = html.replace(/<!doctype\s/i, '<!DOCTYPE ');
28864
28867
  try {
@@ -29593,7 +29596,7 @@ function manifestPlugin(config) {
29593
29596
  };
29594
29597
  }
29595
29598
 
29596
- function walk$3(ast, { enter, leave }) {
29599
+ function walk$2(ast, { enter, leave }) {
29597
29600
  return visit(ast, null, enter, leave);
29598
29601
  }
29599
29602
 
@@ -29787,7 +29790,7 @@ class Scope$1 {
29787
29790
  }
29788
29791
  const attachScopes = function attachScopes(ast, propertyName = 'scope') {
29789
29792
  let scope = new Scope$1();
29790
- walk$3(ast, {
29793
+ walk$2(ast, {
29791
29794
  enter(n, parent) {
29792
29795
  const node = n;
29793
29796
  // function foo () {...}
@@ -33231,7 +33234,7 @@ Glob.prototype._stat2 = function (f, abs, er, stat, cb) {
33231
33234
  replace: (node: BaseNode) => void;
33232
33235
  }} WalkerContext */
33233
33236
 
33234
- class WalkerBase$1 {
33237
+ class WalkerBase {
33235
33238
  constructor() {
33236
33239
  /** @type {boolean} */
33237
33240
  this.should_skip = false;
@@ -33297,7 +33300,7 @@ class WalkerBase$1 {
33297
33300
  * index: number
33298
33301
  * ) => void} SyncHandler */
33299
33302
 
33300
- class SyncWalker$1 extends WalkerBase$1 {
33303
+ class SyncWalker extends WalkerBase {
33301
33304
  /**
33302
33305
  *
33303
33306
  * @param {SyncHandler} enter
@@ -33417,8 +33420,8 @@ class SyncWalker$1 extends WalkerBase$1 {
33417
33420
  * }} walker
33418
33421
  * @returns {BaseNode}
33419
33422
  */
33420
- function walk$2(ast, { enter, leave }) {
33421
- const instance = new SyncWalker$1(enter, leave);
33423
+ function walk$1(ast, { enter, leave }) {
33424
+ const instance = new SyncWalker(enter, leave);
33422
33425
  return instance.visit(ast, null);
33423
33426
  }
33424
33427
 
@@ -34635,7 +34638,7 @@ function transformCommonjs(
34635
34638
  const topLevelAssignments = new Set();
34636
34639
  const topLevelDefineCompiledEsmExpressions = [];
34637
34640
 
34638
- walk$2(ast, {
34641
+ walk$1(ast, {
34639
34642
  enter(node, parent) {
34640
34643
  if (skippedNodes.has(node)) {
34641
34644
  this.skip();
@@ -36312,7 +36315,7 @@ var dirGlob$1 = {exports: {}};
36312
36315
 
36313
36316
  var pathType$1 = {};
36314
36317
 
36315
- const {promisify: promisify$7} = require$$0__default$3;
36318
+ const {promisify: promisify$6} = require$$0__default$3;
36316
36319
  const fs$e = fs__default;
36317
36320
 
36318
36321
  async function isType(fsStatType, statsMethodName, filePath) {
@@ -36321,7 +36324,7 @@ async function isType(fsStatType, statsMethodName, filePath) {
36321
36324
  }
36322
36325
 
36323
36326
  try {
36324
- const stats = await promisify$7(fs$e[fsStatType])(filePath);
36327
+ const stats = await promisify$6(fs$e[fsStatType])(filePath);
36325
36328
  return stats[statsMethodName]();
36326
36329
  } catch (error) {
36327
36330
  if (error.code === 'ENOENT') {
@@ -37041,7 +37044,7 @@ var slash$1 = path => {
37041
37044
  return path.replace(/\\/g, '/');
37042
37045
  };
37043
37046
 
37044
- const {promisify: promisify$6} = require$$0__default$3;
37047
+ const {promisify: promisify$5} = require$$0__default$3;
37045
37048
  const fs$d = fs__default;
37046
37049
  const path$b = path__default;
37047
37050
  const fastGlob$1 = out;
@@ -37055,7 +37058,7 @@ const DEFAULT_IGNORE = [
37055
37058
  '**/.git'
37056
37059
  ];
37057
37060
 
37058
- const readFileP = promisify$6(fs$d.readFile);
37061
+ const readFileP = promisify$5(fs$d.readFile);
37059
37062
 
37060
37063
  const mapGitIgnorePatternTo = base => ignore => {
37061
37064
  if (ignore.startsWith('!')) {
@@ -37508,7 +37511,7 @@ function dynamicImportVariables({ include, exclude, warnOnError } = {}) {
37508
37511
  let dynamicImportIndex = -1;
37509
37512
  let ms;
37510
37513
 
37511
- walk$2(parsed, {
37514
+ walk$1(parsed, {
37512
37515
  enter: (node) => {
37513
37516
  if (node.type !== 'ImportExpression') {
37514
37517
  return;
@@ -50386,7 +50389,7 @@ const htmlTypesRE = /\.(html|vue|svelte)$/;
50386
50389
  // use Acorn because it's slow. Luckily this doesn't have to be bullet proof
50387
50390
  // since even missed imports can be caught at runtime, and false positives will
50388
50391
  // simply be ignored.
50389
- const importsRE = /\bimport(?!\s+type)(?:[\w*{}\n\r\t, ]+from\s*)?\s*("[^"]+"|'[^']+')/gm;
50392
+ const importsRE = /(?:^|;|\*\/)\s*import(?!\s+type)(?:[\w*{}\n\r\t, ]+from\s*)?\s*("[^"]+"|'[^']+')\s*(?:$|;|\/\/|\/\*)/gm;
50390
50393
  async function scanImports(config) {
50391
50394
  var _a, _b, _c, _d;
50392
50395
  const s = Date.now();
@@ -50431,6 +50434,7 @@ async function scanImports(config) {
50431
50434
  const plugin = esbuildScanPlugin(config, container, deps, missing, entries);
50432
50435
  const { plugins = [], ...esbuildOptions } = (_d = (_c = config.optimizeDeps) === null || _c === void 0 ? void 0 : _c.esbuildOptions) !== null && _d !== void 0 ? _d : {};
50433
50436
  await Promise.all(entries.map((entry) => esbuild.build({
50437
+ absWorkingDir: process.cwd(),
50434
50438
  write: false,
50435
50439
  entryPoints: [entry],
50436
50440
  bundle: true,
@@ -50828,10 +50832,7 @@ function resolveBuildPlugins(config) {
50828
50832
  return {
50829
50833
  pre: [
50830
50834
  buildHtmlPlugin(config),
50831
- commonjs({
50832
- ignoreDynamicRequires: true,
50833
- ...options.commonjsOptions
50834
- }),
50835
+ commonjs(options.commonjsOptions),
50835
50836
  dataURIPlugin(),
50836
50837
  dynamicImportVariables(options.dynamicImportVarsOptions),
50837
50838
  assetImportMetaUrlPlugin(config),
@@ -54641,13 +54642,13 @@ var chokidar = {};
54641
54642
  const fs$b = fs__default;
54642
54643
  const { Readable } = require$$0__default$2;
54643
54644
  const sysPath$3 = path__default;
54644
- const { promisify: promisify$5 } = require$$0__default$3;
54645
+ const { promisify: promisify$4 } = require$$0__default$3;
54645
54646
  const picomatch$1 = picomatch$4;
54646
54647
 
54647
- const readdir$1 = promisify$5(fs$b.readdir);
54648
- const stat$3 = promisify$5(fs$b.stat);
54649
- const lstat$2 = promisify$5(fs$b.lstat);
54650
- const realpath$1 = promisify$5(fs$b.realpath);
54648
+ const readdir$1 = promisify$4(fs$b.readdir);
54649
+ const stat$3 = promisify$4(fs$b.stat);
54650
+ const lstat$2 = promisify$4(fs$b.lstat);
54651
+ const realpath$1 = promisify$4(fs$b.realpath);
54651
54652
 
54652
54653
  /**
54653
54654
  * @typedef {Object} EntryInfo
@@ -55406,7 +55407,7 @@ exports.isIBMi = os.type() === 'OS400';
55406
55407
 
55407
55408
  const fs$a = fs__default;
55408
55409
  const sysPath$2 = path__default;
55409
- const { promisify: promisify$4 } = require$$0__default$3;
55410
+ const { promisify: promisify$3 } = require$$0__default$3;
55410
55411
  const isBinaryPath = isBinaryPath$1;
55411
55412
  const {
55412
55413
  isWindows: isWindows$2,
@@ -55429,11 +55430,11 @@ const {
55429
55430
 
55430
55431
  const THROTTLE_MODE_WATCH = 'watch';
55431
55432
 
55432
- const open$1 = promisify$4(fs$a.open);
55433
- const stat$2 = promisify$4(fs$a.stat);
55434
- const lstat$1 = promisify$4(fs$a.lstat);
55435
- const close = promisify$4(fs$a.close);
55436
- const fsrealpath = promisify$4(fs$a.realpath);
55433
+ const open$1 = promisify$3(fs$a.open);
55434
+ const stat$2 = promisify$3(fs$a.stat);
55435
+ const lstat$1 = promisify$3(fs$a.lstat);
55436
+ const close = promisify$3(fs$a.close);
55437
+ const fsrealpath = promisify$3(fs$a.realpath);
55437
55438
 
55438
55439
  const statMethods$1 = { lstat: lstat$1, stat: stat$2 };
55439
55440
 
@@ -56043,7 +56044,7 @@ var fseventsHandler = {exports: {}};
56043
56044
 
56044
56045
  const fs$9 = fs__default;
56045
56046
  const sysPath$1 = path__default;
56046
- const { promisify: promisify$3 } = require$$0__default$3;
56047
+ const { promisify: promisify$2 } = require$$0__default$3;
56047
56048
 
56048
56049
  let fsevents;
56049
56050
  try {
@@ -56092,9 +56093,9 @@ const {
56092
56093
 
56093
56094
  const Depth = (value) => isNaN(value) ? {} : {depth: value};
56094
56095
 
56095
- const stat$1 = promisify$3(fs$9.stat);
56096
- const lstat = promisify$3(fs$9.lstat);
56097
- const realpath = promisify$3(fs$9.realpath);
56096
+ const stat$1 = promisify$2(fs$9.stat);
56097
+ const lstat = promisify$2(fs$9.lstat);
56098
+ const realpath = promisify$2(fs$9.realpath);
56098
56099
 
56099
56100
  const statMethods = { stat: stat$1, lstat };
56100
56101
 
@@ -56567,7 +56568,7 @@ fseventsHandler.exports.canUse = canUse;
56567
56568
  const { EventEmitter: EventEmitter$2 } = require$$0__default$6;
56568
56569
  const fs$8 = fs__default;
56569
56570
  const sysPath = path__default;
56570
- const { promisify: promisify$2 } = require$$0__default$3;
56571
+ const { promisify: promisify$1 } = require$$0__default$3;
56571
56572
  const readdirp = readdirp_1;
56572
56573
  const anymatch = anymatch$2.exports.default;
56573
56574
  const globParent = globParent$3;
@@ -56616,8 +56617,8 @@ const {
56616
56617
  isIBMi
56617
56618
  } = constants$1;
56618
56619
 
56619
- const stat = promisify$2(fs$8.stat);
56620
- const readdir = promisify$2(fs$8.readdir);
56620
+ const stat = promisify$1(fs$8.stat);
56621
+ const readdir = promisify$1(fs$8.readdir);
56621
56622
 
56622
56623
  /**
56623
56624
  * @typedef {String} Path
@@ -57587,7 +57588,7 @@ function readFileIfExists(value) {
57587
57588
  * https://github.com/webpack/webpack-dev-server/blob/master/LICENSE
57588
57589
  */
57589
57590
  async function createCertificate() {
57590
- const { generate } = await Promise.resolve().then(function () { return require('./dep-e462ce9f.js'); }).then(function (n) { return n.index; });
57591
+ const { generate } = await Promise.resolve().then(function () { return require('./dep-d25c0094.js'); }).then(function (n) { return n.index; });
57591
57592
  const pems = generate(null, {
57592
57593
  algorithm: 'sha256',
57593
57594
  days: 30,
@@ -60119,7 +60120,13 @@ class WebSocket$2 extends EventEmitter$1 {
60119
60120
  }
60120
60121
 
60121
60122
  if (this.readyState === WebSocket$2.CLOSING) {
60122
- if (this._closeFrameSent && this._closeFrameReceived) this._socket.end();
60123
+ if (
60124
+ this._closeFrameSent &&
60125
+ (this._closeFrameReceived || this._receiver._writableState.errorEmitted)
60126
+ ) {
60127
+ this._socket.end();
60128
+ }
60129
+
60123
60130
  return;
60124
60131
  }
60125
60132
 
@@ -60132,7 +60139,13 @@ class WebSocket$2 extends EventEmitter$1 {
60132
60139
  if (err) return;
60133
60140
 
60134
60141
  this._closeFrameSent = true;
60135
- if (this._closeFrameReceived) this._socket.end();
60142
+
60143
+ if (
60144
+ this._closeFrameReceived ||
60145
+ this._receiver._writableState.errorEmitted
60146
+ ) {
60147
+ this._socket.end();
60148
+ }
60136
60149
  });
60137
60150
 
60138
60151
  //
@@ -60542,22 +60555,50 @@ function initAsClient(websocket, address, protocols, options) {
60542
60555
 
60543
60556
  if (serverProt) websocket._protocol = serverProt;
60544
60557
 
60545
- if (perMessageDeflate) {
60558
+ const secWebSocketExtensions = res.headers['sec-websocket-extensions'];
60559
+
60560
+ if (secWebSocketExtensions !== undefined) {
60561
+ if (!perMessageDeflate) {
60562
+ const message =
60563
+ 'Server sent a Sec-WebSocket-Extensions header but no extension ' +
60564
+ 'was requested';
60565
+ abortHandshake$1(websocket, socket, message);
60566
+ return;
60567
+ }
60568
+
60569
+ let extensions;
60570
+
60546
60571
  try {
60547
- const extensions = parse$7(res.headers['sec-websocket-extensions']);
60572
+ extensions = parse$7(secWebSocketExtensions);
60573
+ } catch (err) {
60574
+ const message = 'Invalid Sec-WebSocket-Extensions header';
60575
+ abortHandshake$1(websocket, socket, message);
60576
+ return;
60577
+ }
60578
+
60579
+ const extensionNames = Object.keys(extensions);
60548
60580
 
60549
- if (extensions[PerMessageDeflate$1.extensionName]) {
60581
+ if (extensionNames.length) {
60582
+ if (
60583
+ extensionNames.length !== 1 ||
60584
+ extensionNames[0] !== PerMessageDeflate$1.extensionName
60585
+ ) {
60586
+ const message =
60587
+ 'Server indicated an extension that was not requested';
60588
+ abortHandshake$1(websocket, socket, message);
60589
+ return;
60590
+ }
60591
+
60592
+ try {
60550
60593
  perMessageDeflate.accept(extensions[PerMessageDeflate$1.extensionName]);
60551
- websocket._extensions[PerMessageDeflate$1.extensionName] =
60552
- perMessageDeflate;
60594
+ } catch (err) {
60595
+ const message = 'Invalid Sec-WebSocket-Extensions header';
60596
+ abortHandshake$1(websocket, socket, message);
60597
+ return;
60553
60598
  }
60554
- } catch (err) {
60555
- abortHandshake$1(
60556
- websocket,
60557
- socket,
60558
- 'Invalid Sec-WebSocket-Extensions header'
60559
- );
60560
- return;
60599
+
60600
+ websocket._extensions[PerMessageDeflate$1.extensionName] =
60601
+ perMessageDeflate;
60561
60602
  }
60562
60603
  }
60563
60604
 
@@ -60918,13 +60959,13 @@ function createWebSocketStream(ws, options) {
60918
60959
 
60919
60960
  // Prevent `ws.terminate()` from being called by `duplex._destroy()`.
60920
60961
  //
60921
- // - If the state of the `WebSocket` connection is `CONNECTING`,
60922
- // `ws.terminate()` is a noop as no socket was assigned.
60923
- // - Otherwise, the error was re-emitted from the listener of the `'error'`
60962
+ // - If the `'error'` event is emitted before the `'open'` event, then
60963
+ // `ws.terminate()` is a noop as no socket is assigned.
60964
+ // - Otherwise, the error is re-emitted by the listener of the `'error'`
60924
60965
  // event of the `Receiver` object. The listener already closes the
60925
60966
  // connection by calling `ws.close()`. This allows a close frame to be
60926
60967
  // sent to the other peer. If `ws.terminate()` is called right after this,
60927
- // the close frame might not be sent.
60968
+ // then the close frame might not be sent.
60928
60969
  terminateOnDestroy = false;
60929
60970
  duplex.destroy(err);
60930
60971
  });
@@ -61549,8 +61590,13 @@ function baseMiddleware({ config }) {
61549
61590
  // rewrite url to remove base.. this ensures that other middleware does
61550
61591
  // not need to consider base being prepended or not
61551
61592
  req.url = url.replace(base, '/');
61593
+ return next();
61594
+ }
61595
+ // skip redirect and error fallback on middleware mode, #4057
61596
+ if (config.server.middlewareMode) {
61597
+ return next();
61552
61598
  }
61553
- else if (path === '/' || path === '/index.html') {
61599
+ if (path === '/' || path === '/index.html') {
61554
61600
  // redirect root visit to based url
61555
61601
  res.writeHead(302, {
61556
61602
  Location: base
@@ -65017,206 +65063,6 @@ function extract_identifiers(param, nodes = []) {
65017
65063
  return nodes;
65018
65064
  }
65019
65065
 
65020
- // @ts-check
65021
- /** @typedef { import('estree').BaseNode} BaseNode */
65022
-
65023
- /** @typedef {{
65024
- skip: () => void;
65025
- remove: () => void;
65026
- replace: (node: BaseNode) => void;
65027
- }} WalkerContext */
65028
-
65029
- class WalkerBase {
65030
- constructor() {
65031
- /** @type {boolean} */
65032
- this.should_skip = false;
65033
-
65034
- /** @type {boolean} */
65035
- this.should_remove = false;
65036
-
65037
- /** @type {BaseNode | null} */
65038
- this.replacement = null;
65039
-
65040
- /** @type {WalkerContext} */
65041
- this.context = {
65042
- skip: () => (this.should_skip = true),
65043
- remove: () => (this.should_remove = true),
65044
- replace: (node) => (this.replacement = node)
65045
- };
65046
- }
65047
-
65048
- /**
65049
- *
65050
- * @param {any} parent
65051
- * @param {string} prop
65052
- * @param {number} index
65053
- * @param {BaseNode} node
65054
- */
65055
- replace(parent, prop, index, node) {
65056
- if (parent) {
65057
- if (index !== null) {
65058
- parent[prop][index] = node;
65059
- } else {
65060
- parent[prop] = node;
65061
- }
65062
- }
65063
- }
65064
-
65065
- /**
65066
- *
65067
- * @param {any} parent
65068
- * @param {string} prop
65069
- * @param {number} index
65070
- */
65071
- remove(parent, prop, index) {
65072
- if (parent) {
65073
- if (index !== null) {
65074
- parent[prop].splice(index, 1);
65075
- } else {
65076
- delete parent[prop];
65077
- }
65078
- }
65079
- }
65080
- }
65081
-
65082
- // @ts-check
65083
-
65084
- /** @typedef { import('estree').BaseNode} BaseNode */
65085
- /** @typedef { import('./walker.js').WalkerContext} WalkerContext */
65086
-
65087
- /** @typedef {(
65088
- * this: WalkerContext,
65089
- * node: BaseNode,
65090
- * parent: BaseNode,
65091
- * key: string,
65092
- * index: number
65093
- * ) => void} SyncHandler */
65094
-
65095
- class SyncWalker extends WalkerBase {
65096
- /**
65097
- *
65098
- * @param {SyncHandler} enter
65099
- * @param {SyncHandler} leave
65100
- */
65101
- constructor(enter, leave) {
65102
- super();
65103
-
65104
- /** @type {SyncHandler} */
65105
- this.enter = enter;
65106
-
65107
- /** @type {SyncHandler} */
65108
- this.leave = leave;
65109
- }
65110
-
65111
- /**
65112
- *
65113
- * @param {BaseNode} node
65114
- * @param {BaseNode} parent
65115
- * @param {string} [prop]
65116
- * @param {number} [index]
65117
- * @returns {BaseNode}
65118
- */
65119
- visit(node, parent, prop, index) {
65120
- if (node) {
65121
- if (this.enter) {
65122
- const _should_skip = this.should_skip;
65123
- const _should_remove = this.should_remove;
65124
- const _replacement = this.replacement;
65125
- this.should_skip = false;
65126
- this.should_remove = false;
65127
- this.replacement = null;
65128
-
65129
- this.enter.call(this.context, node, parent, prop, index);
65130
-
65131
- if (this.replacement) {
65132
- node = this.replacement;
65133
- this.replace(parent, prop, index, node);
65134
- }
65135
-
65136
- if (this.should_remove) {
65137
- this.remove(parent, prop, index);
65138
- }
65139
-
65140
- const skipped = this.should_skip;
65141
- const removed = this.should_remove;
65142
-
65143
- this.should_skip = _should_skip;
65144
- this.should_remove = _should_remove;
65145
- this.replacement = _replacement;
65146
-
65147
- if (skipped) return node;
65148
- if (removed) return null;
65149
- }
65150
-
65151
- for (const key in node) {
65152
- const value = node[key];
65153
-
65154
- if (typeof value !== "object") {
65155
- continue;
65156
- } else if (Array.isArray(value)) {
65157
- for (let i = 0; i < value.length; i += 1) {
65158
- if (value[i] !== null && typeof value[i].type === 'string') {
65159
- if (!this.visit(value[i], node, key, i)) {
65160
- // removed
65161
- i--;
65162
- }
65163
- }
65164
- }
65165
- } else if (value !== null && typeof value.type === "string") {
65166
- this.visit(value, node, key, null);
65167
- }
65168
- }
65169
-
65170
- if (this.leave) {
65171
- const _replacement = this.replacement;
65172
- const _should_remove = this.should_remove;
65173
- this.replacement = null;
65174
- this.should_remove = false;
65175
-
65176
- this.leave.call(this.context, node, parent, prop, index);
65177
-
65178
- if (this.replacement) {
65179
- node = this.replacement;
65180
- this.replace(parent, prop, index, node);
65181
- }
65182
-
65183
- if (this.should_remove) {
65184
- this.remove(parent, prop, index);
65185
- }
65186
-
65187
- const removed = this.should_remove;
65188
-
65189
- this.replacement = _replacement;
65190
- this.should_remove = _should_remove;
65191
-
65192
- if (removed) return null;
65193
- }
65194
- }
65195
-
65196
- return node;
65197
- }
65198
- }
65199
-
65200
- // @ts-check
65201
-
65202
- /** @typedef { import('estree').BaseNode} BaseNode */
65203
- /** @typedef { import('./sync.js').SyncHandler} SyncHandler */
65204
- /** @typedef { import('./async.js').AsyncHandler} AsyncHandler */
65205
-
65206
- /**
65207
- *
65208
- * @param {BaseNode} ast
65209
- * @param {{
65210
- * enter?: SyncHandler
65211
- * leave?: SyncHandler
65212
- * }} walker
65213
- * @returns {BaseNode}
65214
- */
65215
- function walk$1(ast, { enter, leave }) {
65216
- const instance = new SyncWalker(enter, leave);
65217
- return instance.visit(ast, null);
65218
- }
65219
-
65220
65066
  const ssrModuleExportsKey = `__vite_ssr_exports__`;
65221
65067
  const ssrImportKey = `__vite_ssr_import__`;
65222
65068
  const ssrDynamicImportKey = `__vite_ssr_dynamic_import__`;
@@ -65306,7 +65152,19 @@ async function ssrTransform(code, inMap, url) {
65306
65152
  }
65307
65153
  // default export
65308
65154
  if (node.type === 'ExportDefaultDeclaration') {
65309
- s.overwrite(node.start, node.start + 14, `${ssrModuleExportsKey}.default =`);
65155
+ if ('id' in node.declaration && node.declaration.id) {
65156
+ // named hoistable/class exports
65157
+ // export default function foo() {}
65158
+ // export default class A {}
65159
+ const { name } = node.declaration.id;
65160
+ s.remove(node.start, node.start + 15 /* 'export default '.length */);
65161
+ s.append(`\nObject.defineProperty(${ssrModuleExportsKey}, "default", ` +
65162
+ `{ enumerable: true, value: ${name} })`);
65163
+ }
65164
+ else {
65165
+ // anonymous default exports
65166
+ s.overwrite(node.start, node.start + 14 /* 'export default'.length */, `${ssrModuleExportsKey}.default =`);
65167
+ }
65310
65168
  }
65311
65169
  // export * from './foo'
65312
65170
  if (node.type === 'ExportAllDeclaration') {
@@ -66822,7 +66680,7 @@ function propagateUpdate(node, timestamp, boundaries, currentChain = [node]) {
66822
66680
  // additionally check for CSS importers, since a PostCSS plugin like
66823
66681
  // Tailwind JIT may register any file as a dependency to a CSS file.
66824
66682
  for (const importer of node.importers) {
66825
- if (isCSSRequest(importer.url) && !currentChain.includes(importer)) {
66683
+ if (cssLangRE.test(importer.url) && !currentChain.includes(importer)) {
66826
66684
  propagateUpdate(importer, timestamp, boundaries, currentChain.concat(importer));
66827
66685
  }
66828
66686
  }
@@ -66834,8 +66692,8 @@ function propagateUpdate(node, timestamp, boundaries, currentChain = [node]) {
66834
66692
  // #3716, #3913
66835
66693
  // For a non-CSS file, if all of its importers are CSS files (registered via
66836
66694
  // PostCSS plugins) it should be considered a dead end and force full reload.
66837
- if (!isCSSRequest(node.url) &&
66838
- [...node.importers].every((i) => isCSSRequest(i.url))) {
66695
+ if (!cssLangRE.test(node.url) &&
66696
+ [...node.importers].every((i) => cssLangRE.test(i.url))) {
66839
66697
  return true;
66840
66698
  }
66841
66699
  for (const importer of node.importers) {
@@ -67129,19 +66987,37 @@ if (process.env.__IS_WSL_TEST__) {
67129
66987
  isWsl$2.exports = isWsl$1();
67130
66988
  }
67131
66989
 
67132
- const {promisify: promisify$1} = require$$0__default$3;
66990
+ var defineLazyProp = (object, propertyName, fn) => {
66991
+ const define = value => Object.defineProperty(object, propertyName, {value, enumerable: true, writable: true});
66992
+
66993
+ Object.defineProperty(object, propertyName, {
66994
+ configurable: true,
66995
+ enumerable: true,
66996
+ get() {
66997
+ const result = fn();
66998
+ define(result);
66999
+ return result;
67000
+ },
67001
+ set(value) {
67002
+ define(value);
67003
+ }
67004
+ });
67005
+
67006
+ return object;
67007
+ };
67008
+
67133
67009
  const path$9 = path__default;
67134
- const childProcess$3 = require$$2__default;
67135
- const fs$5 = fs__default;
67010
+ const childProcess$3 = require$$1__default$3;
67011
+ const {promises: fs$5, constants: fsConstants} = fs__default;
67136
67012
  const isWsl = isWsl$2.exports;
67137
67013
  const isDocker = isDocker_1;
67138
-
67139
- const pAccess = promisify$1(fs$5.access);
67140
- const pReadFile = promisify$1(fs$5.readFile);
67014
+ const defineLazyProperty = defineLazyProp;
67141
67015
 
67142
67016
  // Path to included `xdg-open`.
67143
67017
  const localXdgOpenPath = path$9.join(__dirname, 'xdg-open');
67144
67018
 
67019
+ const {platform, arch} = process;
67020
+
67145
67021
  /**
67146
67022
  Get the mount point for fixed drives in WSL.
67147
67023
 
@@ -67165,29 +67041,43 @@ const getWslDrivesMountPoint = (() => {
67165
67041
 
67166
67042
  let isConfigFileExists = false;
67167
67043
  try {
67168
- await pAccess(configFilePath, fs$5.constants.F_OK);
67044
+ await fs$5.access(configFilePath, fsConstants.F_OK);
67169
67045
  isConfigFileExists = true;
67170
- } catch (_) {}
67046
+ } catch {}
67171
67047
 
67172
67048
  if (!isConfigFileExists) {
67173
67049
  return defaultMountPoint;
67174
67050
  }
67175
67051
 
67176
- const configContent = await pReadFile(configFilePath, {encoding: 'utf8'});
67177
- const configMountPoint = /root\s*=\s*(.*)/g.exec(configContent);
67052
+ const configContent = await fs$5.readFile(configFilePath, {encoding: 'utf8'});
67053
+ const configMountPoint = /(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(configContent);
67178
67054
 
67179
67055
  if (!configMountPoint) {
67180
67056
  return defaultMountPoint;
67181
67057
  }
67182
67058
 
67183
- mountPoint = configMountPoint[1].trim();
67184
- mountPoint = mountPoint.endsWith('/') ? mountPoint : mountPoint + '/';
67059
+ mountPoint = configMountPoint.groups.mountPoint.trim();
67060
+ mountPoint = mountPoint.endsWith('/') ? mountPoint : `${mountPoint}/`;
67185
67061
 
67186
67062
  return mountPoint;
67187
67063
  };
67188
67064
  })();
67189
67065
 
67190
- var open = async (target, options) => {
67066
+ const pTryEach = async (array, mapper) => {
67067
+ let latestError;
67068
+
67069
+ for (const item of array) {
67070
+ try {
67071
+ return await mapper(item); // eslint-disable-line no-await-in-loop
67072
+ } catch (error) {
67073
+ latestError = error;
67074
+ }
67075
+ }
67076
+
67077
+ throw latestError;
67078
+ };
67079
+
67080
+ const open = async (target, options) => {
67191
67081
  if (typeof target !== 'string') {
67192
67082
  throw new TypeError('Expected a `target`');
67193
67083
  }
@@ -67195,22 +67085,36 @@ var open = async (target, options) => {
67195
67085
  options = {
67196
67086
  wait: false,
67197
67087
  background: false,
67088
+ newInstance: false,
67198
67089
  allowNonzeroExitCode: false,
67199
67090
  ...options
67200
67091
  };
67201
67092
 
67202
- let command;
67203
- let {app} = options;
67204
- let appArguments = [];
67205
- const cliArguments = [];
67206
- const childProcessOptions = {};
67093
+ if (Array.isArray(options.app)) {
67094
+ return pTryEach(options.app, singleApp => open(target, {
67095
+ ...options,
67096
+ app: singleApp
67097
+ }));
67098
+ }
67099
+
67100
+ let {name: app, arguments: appArguments = []} = options.app || {};
67101
+ appArguments = [...appArguments];
67207
67102
 
67208
67103
  if (Array.isArray(app)) {
67209
- appArguments = app.slice(1);
67210
- app = app[0];
67104
+ return pTryEach(app, appName => open(target, {
67105
+ ...options,
67106
+ app: {
67107
+ name: appName,
67108
+ arguments: appArguments
67109
+ }
67110
+ }));
67211
67111
  }
67212
67112
 
67213
- if (process.platform === 'darwin') {
67113
+ let command;
67114
+ const cliArguments = [];
67115
+ const childProcessOptions = {};
67116
+
67117
+ if (platform === 'darwin') {
67214
67118
  command = 'open';
67215
67119
 
67216
67120
  if (options.wait) {
@@ -67221,10 +67125,14 @@ var open = async (target, options) => {
67221
67125
  cliArguments.push('--background');
67222
67126
  }
67223
67127
 
67128
+ if (options.newInstance) {
67129
+ cliArguments.push('--new');
67130
+ }
67131
+
67224
67132
  if (app) {
67225
67133
  cliArguments.push('-a', app);
67226
67134
  }
67227
- } else if (process.platform === 'win32' || (isWsl && !isDocker())) {
67135
+ } else if (platform === 'win32' || (isWsl && !isDocker())) {
67228
67136
  const mountPoint = await getWslDrivesMountPoint();
67229
67137
 
67230
67138
  command = isWsl ?
@@ -67275,12 +67183,12 @@ var open = async (target, options) => {
67275
67183
  // Check if local `xdg-open` exists and is executable.
67276
67184
  let exeLocalXdgOpen = false;
67277
67185
  try {
67278
- await pAccess(localXdgOpenPath, fs$5.constants.X_OK);
67186
+ await fs$5.access(localXdgOpenPath, fsConstants.X_OK);
67279
67187
  exeLocalXdgOpen = true;
67280
- } catch (_) {}
67188
+ } catch {}
67281
67189
 
67282
67190
  const useSystemXdgOpen = process.versions.electron ||
67283
- process.platform === 'android' || isBundled || !exeLocalXdgOpen;
67191
+ platform === 'android' || isBundled || !exeLocalXdgOpen;
67284
67192
  command = useSystemXdgOpen ? 'xdg-open' : localXdgOpenPath;
67285
67193
  }
67286
67194
 
@@ -67298,7 +67206,7 @@ var open = async (target, options) => {
67298
67206
 
67299
67207
  cliArguments.push(target);
67300
67208
 
67301
- if (process.platform === 'darwin' && appArguments.length > 0) {
67209
+ if (platform === 'darwin' && appArguments.length > 0) {
67302
67210
  cliArguments.push('--args', ...appArguments);
67303
67211
  }
67304
67212
 
@@ -67324,6 +67232,65 @@ var open = async (target, options) => {
67324
67232
  return subprocess;
67325
67233
  };
67326
67234
 
67235
+ function detectArchBinary(binary) {
67236
+ if (typeof binary === 'string' || Array.isArray(binary)) {
67237
+ return binary;
67238
+ }
67239
+
67240
+ const {[arch]: archBinary} = binary;
67241
+
67242
+ if (!archBinary) {
67243
+ throw new Error(`${arch} is not supported`);
67244
+ }
67245
+
67246
+ return archBinary;
67247
+ }
67248
+
67249
+ function detectPlatformBinary({[platform]: platformBinary}, {wsl}) {
67250
+ if (wsl && isWsl) {
67251
+ return detectArchBinary(wsl);
67252
+ }
67253
+
67254
+ if (!platformBinary) {
67255
+ throw new Error(`${platform} is not supported`);
67256
+ }
67257
+
67258
+ return detectArchBinary(platformBinary);
67259
+ }
67260
+
67261
+ const apps = {};
67262
+
67263
+ defineLazyProperty(apps, 'chrome', () => detectPlatformBinary({
67264
+ darwin: 'google chrome',
67265
+ win32: 'chrome',
67266
+ linux: ['google-chrome', 'google-chrome-stable']
67267
+ }, {
67268
+ wsl: {
67269
+ ia32: '/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe',
67270
+ x64: ['/mnt/c/Program Files/Google/Chrome/Application/chrome.exe', '/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe']
67271
+ }
67272
+ }));
67273
+
67274
+ defineLazyProperty(apps, 'firefox', () => detectPlatformBinary({
67275
+ darwin: 'firefox',
67276
+ win32: 'C:\\Program Files\\Mozilla Firefox\\firefox.exe',
67277
+ linux: 'firefox'
67278
+ }, {
67279
+ wsl: '/mnt/c/Program Files/Mozilla Firefox/firefox.exe'
67280
+ }));
67281
+
67282
+ defineLazyProperty(apps, 'edge', () => detectPlatformBinary({
67283
+ darwin: 'microsoft edge',
67284
+ win32: 'msedge',
67285
+ linux: 'microsoft-edge'
67286
+ }, {
67287
+ wsl: '/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe'
67288
+ }));
67289
+
67290
+ open.apps = apps;
67291
+
67292
+ var open_1 = open;
67293
+
67327
67294
  var execa$2 = {exports: {}};
67328
67295
 
67329
67296
  var crossSpawn$1 = {exports: {}};
@@ -67901,7 +67868,7 @@ var enoent$1 = {
67901
67868
  notFoundError,
67902
67869
  };
67903
67870
 
67904
- const cp = require$$2__default;
67871
+ const cp = require$$1__default$3;
67905
67872
  const parse$2 = parse_1;
67906
67873
  const enoent = enoent$1;
67907
67874
 
@@ -69345,7 +69312,7 @@ var command = {
69345
69312
  };
69346
69313
 
69347
69314
  const path$5 = path__default;
69348
- const childProcess$2 = require$$2__default;
69315
+ const childProcess$2 = require$$1__default$3;
69349
69316
  const crossSpawn = crossSpawn$1.exports;
69350
69317
  const stripFinalNewline = stripFinalNewline$1;
69351
69318
  const npmRunPath = npmRunPath$1.exports;
@@ -69665,8 +69632,8 @@ function startBrowserProcess(browser, url) {
69665
69632
  try {
69666
69633
  // Try our best to reuse existing tab
69667
69634
  // on OS X Google Chrome with AppleScript
69668
- require$$2$1.execSync('ps cax | grep "Google Chrome"');
69669
- require$$2$1.execSync('osascript openChrome.applescript "' + encodeURI(url) + '"', {
69635
+ require$$1$5.execSync('ps cax | grep "Google Chrome"');
69636
+ require$$1$5.execSync('osascript openChrome.applescript "' + encodeURI(url) + '"', {
69670
69637
  cwd: path__default.dirname(require.resolve('vite/bin/openChrome.applescript')),
69671
69638
  stdio: 'ignore'
69672
69639
  });
@@ -69686,8 +69653,8 @@ function startBrowserProcess(browser, url) {
69686
69653
  // Fallback to open
69687
69654
  // (It will always open new tab)
69688
69655
  try {
69689
- const options = { app: browser, url: true };
69690
- open(url, options).catch(() => { }); // Prevent `unhandledRejection` error.
69656
+ const options = browser ? { app: { name: browser } } : {};
69657
+ open_1(url, options).catch(() => { }); // Prevent `unhandledRejection` error.
69691
69658
  return true;
69692
69659
  }
69693
69660
  catch (err) {
@@ -71842,7 +71809,7 @@ var windows = [
71842
71809
 
71843
71810
  const path$4 = path__default;
71844
71811
  const shellQuote = shellQuote$1;
71845
- const childProcess$1 = require$$2__default;
71812
+ const childProcess$1 = require$$1__default$3;
71846
71813
 
71847
71814
  // Map from full process name to binary that starts the process
71848
71815
  // We can't just re-use full process name, because it will spawn a new instance
@@ -71991,7 +71958,7 @@ const fs$1 = fs__default;
71991
71958
  const os$1 = require$$0__default$1;
71992
71959
  const path$2 = path__default;
71993
71960
  const chalk = chalk$1.exports;
71994
- const childProcess = require$$2__default;
71961
+ const childProcess = require$$1__default$3;
71995
71962
 
71996
71963
  const guessEditor = guess;
71997
71964
  const getArgumentsForPosition = getArgs;
@@ -72211,7 +72178,7 @@ function esbuildDepPlugin(qualified, exportsData, config, ssr) {
72211
72178
  namespace: 'dep'
72212
72179
  }
72213
72180
  : {
72214
- path: require.resolve(id, {
72181
+ path: require.resolve(qualified[flatId], {
72215
72182
  paths: [resolveDir]
72216
72183
  })
72217
72184
  };
@@ -72354,6 +72321,9 @@ ssr) {
72354
72321
  else {
72355
72322
  fs__default.mkdirSync(cacheDir, { recursive: true });
72356
72323
  }
72324
+ // a hint for Node.js
72325
+ // all files in the cache directory should be recognized as ES modules
72326
+ writeFile(path__default.resolve(cacheDir, 'package.json'), JSON.stringify({ type: 'module' }));
72357
72327
  let deps, missing;
72358
72328
  if (!newDeps) {
72359
72329
  ({ deps, missing } = await scanImports(config));
@@ -72445,6 +72415,7 @@ ssr) {
72445
72415
  const start = Date.now();
72446
72416
  const { plugins = [], ...esbuildOptions } = (_c = (_b = config.optimizeDeps) === null || _b === void 0 ? void 0 : _b.esbuildOptions) !== null && _c !== void 0 ? _c : {};
72447
72417
  const result = await esbuild.build({
72418
+ absWorkingDir: process.cwd(),
72448
72419
  entryPoints: Object.keys(flatIdDeps),
72449
72420
  bundle: true,
72450
72421
  format: 'esm',
@@ -74741,6 +74712,7 @@ async function loadConfigFromFile(configEnv, configFile, configRoot = process.cw
74741
74712
  }
74742
74713
  async function bundleConfigFile(fileName, mjs = false) {
74743
74714
  const result = await esbuild.build({
74715
+ absWorkingDir: process.cwd(),
74744
74716
  entryPoints: [fileName],
74745
74717
  outfile: 'out.js',
74746
74718
  write: false,
@@ -74884,4 +74856,4 @@ exports.sortUserPlugins = sortUserPlugins;
74884
74856
  exports.source = source;
74885
74857
  exports.sourceMap = sourceMap;
74886
74858
  exports.vary = vary$1;
74887
- //# sourceMappingURL=dep-200de8ae.js.map
74859
+ //# sourceMappingURL=dep-cc49d7be.js.map