vite 4.0.0-beta.0 → 4.0.0-beta.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.
@@ -1,6 +1,6 @@
1
1
  import require$$0__default from 'fs';
2
2
  import require$$0 from 'postcss';
3
- import { A as commonjsGlobal } from './dep-a5101d9f.js';
3
+ import { A as commonjsGlobal } from './dep-86149127.js';
4
4
  import require$$0$1 from 'path';
5
5
  import require$$5 from 'crypto';
6
6
  import require$$0$2 from 'util';
@@ -21955,7 +21955,22 @@ function saveEmitWorkerAsset(config, asset) {
21955
21955
  const workerMap = workerCache.get(config.mainConfig || config);
21956
21956
  workerMap.assets.set(fileName, asset);
21957
21957
  }
21958
+ // Ensure that only one rollup build is called at the same time to avoid
21959
+ // leaking state in plugins between worker builds.
21960
+ // TODO: Review if we can parallelize the bundling of workers.
21961
+ const workerConfigSemaphore = new WeakMap();
21958
21962
  async function bundleWorkerEntry(config, id, query) {
21963
+ const processing = workerConfigSemaphore.get(config);
21964
+ if (processing) {
21965
+ await processing;
21966
+ return bundleWorkerEntry(config, id, query);
21967
+ }
21968
+ const promise = serialBundleWorkerEntry(config, id, query);
21969
+ workerConfigSemaphore.set(config, promise);
21970
+ promise.then(() => workerConfigSemaphore.delete(config));
21971
+ return promise;
21972
+ }
21973
+ async function serialBundleWorkerEntry(config, id, query) {
21959
21974
  // bundle the file as entry to support imports
21960
21975
  const { rollup } = await import('rollup');
21961
21976
  const { plugins, rollupOptions, format } = config.worker;
@@ -37572,7 +37587,7 @@ async function compileCSS(id, code, config, urlReplacer) {
37572
37587
  }));
37573
37588
  }
37574
37589
  if (isModule) {
37575
- postcssPlugins.unshift((await import('./dep-753720be.js').then(function (n) { return n.i; })).default({
37590
+ postcssPlugins.unshift((await import('./dep-2ee6aff6.js').then(function (n) { return n.i; })).default({
37576
37591
  ...modulesOptions,
37577
37592
  localsConvention: modulesOptions?.localsConvention,
37578
37593
  getJSON(cssFileName, _modules, outputFileName) {
@@ -45169,9 +45184,10 @@ function expand (config) {
45169
45184
  config.parsed[configKey] = _interpolate(value, environment, config);
45170
45185
  }
45171
45186
 
45172
- for (const processKey in config.parsed) {
45173
- environment[processKey] = config.parsed[processKey];
45174
- }
45187
+ // PATCH: don't write to process.env
45188
+ // for (const processKey in config.parsed) {
45189
+ // environment[processKey] = config.parsed[processKey]
45190
+ // }
45175
45191
 
45176
45192
  return config
45177
45193
  }
@@ -45200,18 +45216,18 @@ function loadEnv(mode, envDir, prefixes = 'VITE_') {
45200
45216
  return [];
45201
45217
  return Object.entries(parse_1$1(fs$l.readFileSync(path)));
45202
45218
  }));
45203
- // let environment variables use each other
45204
- const expandParsed = expand_1({
45205
- parsed: {
45206
- ...process.env,
45207
- ...parsed,
45208
- },
45209
- // prevent process.env mutation
45210
- ignoreProcessEnv: true,
45211
- }).parsed;
45212
- Object.keys(parsed).forEach((key) => {
45213
- parsed[key] = expandParsed[key];
45214
- });
45219
+ try {
45220
+ // let environment variables use each other
45221
+ expand_1({ parsed });
45222
+ }
45223
+ catch (e) {
45224
+ // custom error handling until https://github.com/motdotla/dotenv-expand/issues/65 is fixed upstream
45225
+ // check for message "TypeError: Cannot read properties of undefined (reading 'split')"
45226
+ if (e.message.includes('split')) {
45227
+ throw new Error('dotenv-expand failed to expand env vars. Maybe you need to escape `$`?');
45228
+ }
45229
+ throw e;
45230
+ }
45215
45231
  // only keys that start with prefix are exposed to client
45216
45232
  for (const [key, value] of Object.entries(parsed)) {
45217
45233
  if (prefixes.some((prefix) => key.startsWith(prefix))) {
@@ -58590,7 +58606,7 @@ var debug_1 = function () {
58590
58606
  if (!debug$3) {
58591
58607
  try {
58592
58608
  /* eslint global-require: off */
58593
- debug$3 = require("debug")("follow-redirects");
58609
+ debug$3 = src$2.exports("follow-redirects");
58594
58610
  }
58595
58611
  catch (error) { /* */ }
58596
58612
  if (typeof debug$3 !== "function") {
@@ -62869,7 +62885,6 @@ async function bundleConfigFile(fileName, isESM) {
62869
62885
  root: path$o.dirname(fileName),
62870
62886
  isBuild: true,
62871
62887
  isProduction: true,
62872
- isRequire: !isESM,
62873
62888
  preferRelative: false,
62874
62889
  tryIndex: true,
62875
62890
  mainFields: [],
@@ -62891,8 +62906,9 @@ async function bundleConfigFile(fileName, isESM) {
62891
62906
  if (id.startsWith('npm:')) {
62892
62907
  return { external: true };
62893
62908
  }
62894
- let idFsPath = tryNodeResolve(id, importer, options, false)?.id;
62895
- if (idFsPath && (isESM || kind === 'dynamic-import')) {
62909
+ const isIdESM = isESM || kind === 'dynamic-import';
62910
+ let idFsPath = tryNodeResolve(id, importer, { ...options, isRequire: !isIdESM }, false)?.id;
62911
+ if (idFsPath && isIdESM) {
62896
62912
  idFsPath = pathToFileURL(idFsPath).href;
62897
62913
  }
62898
62914
  return {
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 { z as picocolors, v as createLogger, g as resolveConfig } from './chunks/dep-a5101d9f.js';
5
+ import { z as picocolors, v as createLogger, g as resolveConfig } from './chunks/dep-86149127.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:url';
8
8
  import 'node:module';
@@ -720,7 +720,7 @@ cli
720
720
  filterDuplicateOptions(options);
721
721
  // output structure is preserved even after bundling so require()
722
722
  // is ok here
723
- const { createServer } = await import('./chunks/dep-a5101d9f.js').then(function (n) { return n.D; });
723
+ const { createServer } = await import('./chunks/dep-86149127.js').then(function (n) { return n.D; });
724
724
  try {
725
725
  const server = await createServer({
726
726
  root,
@@ -773,7 +773,7 @@ cli
773
773
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
774
774
  .action(async (root, options) => {
775
775
  filterDuplicateOptions(options);
776
- const { build } = await import('./chunks/dep-a5101d9f.js').then(function (n) { return n.C; });
776
+ const { build } = await import('./chunks/dep-86149127.js').then(function (n) { return n.C; });
777
777
  const buildOptions = cleanOptions(options);
778
778
  try {
779
779
  await build({
@@ -801,7 +801,7 @@ cli
801
801
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
802
802
  .action(async (root, options) => {
803
803
  filterDuplicateOptions(options);
804
- const { optimizeDeps } = await import('./chunks/dep-a5101d9f.js').then(function (n) { return n.B; });
804
+ const { optimizeDeps } = await import('./chunks/dep-86149127.js').then(function (n) { return n.B; });
805
805
  try {
806
806
  const config = await resolveConfig({
807
807
  root,
@@ -826,7 +826,7 @@ cli
826
826
  .option('--outDir <dir>', `[string] output directory (default: dist)`)
827
827
  .action(async (root, options) => {
828
828
  filterDuplicateOptions(options);
829
- const { preview } = await import('./chunks/dep-a5101d9f.js').then(function (n) { return n.E; });
829
+ const { preview } = await import('./chunks/dep-86149127.js').then(function (n) { return n.E; });
830
830
  try {
831
831
  const server = await preview({
832
832
  root,
@@ -1,4 +1,4 @@
1
- export { b as build, q as createFilter, v as createLogger, c as createServer, e as defineConfig, f as formatPostcssSourceMap, i as getDepOptimizationConfig, j as isDepsOptimizerEnabled, l as loadConfigFromFile, x as loadEnv, k as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, h as resolveBaseUrl, g as resolveConfig, y as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, w as searchForWorkspaceRoot, u as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-a5101d9f.js';
1
+ export { b as build, q as createFilter, v as createLogger, c as createServer, e as defineConfig, f as formatPostcssSourceMap, i as getDepOptimizationConfig, j as isDepsOptimizerEnabled, l as loadConfigFromFile, x as loadEnv, k as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, h as resolveBaseUrl, g as resolveConfig, y as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, w as searchForWorkspaceRoot, u as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-86149127.js';
2
2
  export { VERSION as version } from './constants.js';
3
3
  export { version as esbuildVersion } from 'esbuild';
4
4
  export { VERSION as rollupVersion } from 'rollup';
@@ -4199,9 +4199,10 @@ function expand (config) {
4199
4199
  config.parsed[configKey] = _interpolate(value, environment, config);
4200
4200
  }
4201
4201
 
4202
- for (const processKey in config.parsed) {
4203
- environment[processKey] = config.parsed[processKey];
4204
- }
4202
+ // PATCH: don't write to process.env
4203
+ // for (const processKey in config.parsed) {
4204
+ // environment[processKey] = config.parsed[processKey]
4205
+ // }
4205
4206
 
4206
4207
  return config
4207
4208
  }
@@ -4230,18 +4231,18 @@ function loadEnv(mode, envDir, prefixes = 'VITE_') {
4230
4231
  return [];
4231
4232
  return Object.entries(parse_1(fs$1.readFileSync(path)));
4232
4233
  }));
4233
- // let environment variables use each other
4234
- const expandParsed = expand_1({
4235
- parsed: {
4236
- ...process.env,
4237
- ...parsed,
4238
- },
4239
- // prevent process.env mutation
4240
- ignoreProcessEnv: true,
4241
- }).parsed;
4242
- Object.keys(parsed).forEach((key) => {
4243
- parsed[key] = expandParsed[key];
4244
- });
4234
+ try {
4235
+ // let environment variables use each other
4236
+ expand_1({ parsed });
4237
+ }
4238
+ catch (e) {
4239
+ // custom error handling until https://github.com/motdotla/dotenv-expand/issues/65 is fixed upstream
4240
+ // check for message "TypeError: Cannot read properties of undefined (reading 'split')"
4241
+ if (e.message.includes('split')) {
4242
+ throw new Error('dotenv-expand failed to expand env vars. Maybe you need to escape `$`?');
4243
+ }
4244
+ throw e;
4245
+ }
4245
4246
  // only keys that start with prefix are exposed to client
4246
4247
  for (const [key, value] of Object.entries(parsed)) {
4247
4248
  if (prefixes.some((prefix) => key.startsWith(prefix))) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "4.0.0-beta.0",
3
+ "version": "4.0.0-beta.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",
@@ -61,7 +61,7 @@
61
61
  "esbuild": "^0.15.9",
62
62
  "postcss": "^8.4.19",
63
63
  "resolve": "^1.22.1",
64
- "rollup": "~3.5.1"
64
+ "rollup": "^3.6.0"
65
65
  },
66
66
  "optionalDependencies": {
67
67
  "fsevents": "~2.3.2"