vite 4.1.3 → 4.1.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.

@@ -40398,15 +40398,23 @@ function definePlugin(config) {
40398
40398
  __vite_process_env_NODE_ENV: JSON.stringify(nodeEnv),
40399
40399
  });
40400
40400
  }
40401
- const env = { ...config.env };
40402
40401
  const userDefine = {};
40402
+ const userDefineEnv = {};
40403
40403
  for (const key in config.define) {
40404
40404
  const val = config.define[key];
40405
40405
  userDefine[key] = typeof val === 'string' ? val : JSON.stringify(val);
40406
40406
  // make sure `import.meta.env` object has user define properties
40407
- const match = key.match(metaEnvRe);
40408
- if (match) {
40409
- env[match[1]] = val;
40407
+ if (isBuild) {
40408
+ const match = key.match(metaEnvRe);
40409
+ if (match) {
40410
+ userDefineEnv[match[1]] =
40411
+ // test if value is raw identifier to wrap with __vite__ so when
40412
+ // stringified for `import.meta.env`, we can remove the quotes and
40413
+ // retain being an identifier
40414
+ typeof val === 'string' && /^[\p{L}_$]/u.test(val.trim())
40415
+ ? `__vite__${val}__vite__`
40416
+ : val;
40417
+ }
40410
40418
  }
40411
40419
  }
40412
40420
  // during dev, import.meta properties are handled by importAnalysis plugin.
@@ -40414,7 +40422,10 @@ function definePlugin(config) {
40414
40422
  const importMetaKeys = {};
40415
40423
  const importMetaFallbackKeys = {};
40416
40424
  if (isBuild) {
40417
- env.SSR = !!config.build.ssr;
40425
+ const env = {
40426
+ ...config.env,
40427
+ SSR: !!config.build.ssr,
40428
+ };
40418
40429
  // set here to allow override with config.define
40419
40430
  importMetaKeys['import.meta.hot'] = `undefined`;
40420
40431
  for (const key in env) {
@@ -40422,7 +40433,7 @@ function definePlugin(config) {
40422
40433
  }
40423
40434
  Object.assign(importMetaFallbackKeys, {
40424
40435
  'import.meta.env.': `({}).`,
40425
- 'import.meta.env': JSON.stringify(env),
40436
+ 'import.meta.env': JSON.stringify({ ...env, ...userDefineEnv }).replace(/"__vite__(.+?)__vite__"/g, (_, val) => val),
40426
40437
  });
40427
40438
  }
40428
40439
  function generatePattern(ssr) {
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 { A as picocolorsExports, B as bindShortcuts, w as createLogger, h as resolveConfig } from './chunks/dep-ae3fae1b.js';
5
+ import { A as picocolorsExports, B as bindShortcuts, w as createLogger, h as resolveConfig } from './chunks/dep-ca21228b.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:url';
8
8
  import 'node:module';
@@ -729,7 +729,7 @@ cli
729
729
  filterDuplicateOptions(options);
730
730
  // output structure is preserved even after bundling so require()
731
731
  // is ok here
732
- const { createServer } = await import('./chunks/dep-ae3fae1b.js').then(function (n) { return n.E; });
732
+ const { createServer } = await import('./chunks/dep-ca21228b.js').then(function (n) { return n.E; });
733
733
  try {
734
734
  const server = await createServer({
735
735
  root,
@@ -807,7 +807,7 @@ cli
807
807
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
808
808
  .action(async (root, options) => {
809
809
  filterDuplicateOptions(options);
810
- const { build } = await import('./chunks/dep-ae3fae1b.js').then(function (n) { return n.D; });
810
+ const { build } = await import('./chunks/dep-ca21228b.js').then(function (n) { return n.D; });
811
811
  const buildOptions = cleanOptions(options);
812
812
  try {
813
813
  await build({
@@ -835,7 +835,7 @@ cli
835
835
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
836
836
  .action(async (root, options) => {
837
837
  filterDuplicateOptions(options);
838
- const { optimizeDeps } = await import('./chunks/dep-ae3fae1b.js').then(function (n) { return n.C; });
838
+ const { optimizeDeps } = await import('./chunks/dep-ca21228b.js').then(function (n) { return n.C; });
839
839
  try {
840
840
  const config = await resolveConfig({
841
841
  root,
@@ -860,7 +860,7 @@ cli
860
860
  .option('--outDir <dir>', `[string] output directory (default: dist)`)
861
861
  .action(async (root, options) => {
862
862
  filterDuplicateOptions(options);
863
- const { preview } = await import('./chunks/dep-ae3fae1b.js').then(function (n) { return n.F; });
863
+ const { preview } = await import('./chunks/dep-ca21228b.js').then(function (n) { return n.F; });
864
864
  try {
865
865
  const server = await preview({
866
866
  root,
@@ -1,4 +1,4 @@
1
- export { b as build, e as buildErrorMessage, u as createFilter, w as createLogger, c as createServer, g as defineConfig, f as formatPostcssSourceMap, j as getDepOptimizationConfig, k as isDepsOptimizerEnabled, l as loadConfigFromFile, y as loadEnv, q as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, i as resolveBaseUrl, h as resolveConfig, z as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, x as searchForWorkspaceRoot, v as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-ae3fae1b.js';
1
+ export { b as build, e as buildErrorMessage, u as createFilter, w as createLogger, c as createServer, g as defineConfig, f as formatPostcssSourceMap, j as getDepOptimizationConfig, k as isDepsOptimizerEnabled, l as loadConfigFromFile, y as loadEnv, q as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, i as resolveBaseUrl, h as resolveConfig, z as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, x as searchForWorkspaceRoot, v as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-ca21228b.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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "4.1.3",
3
+ "version": "4.1.4",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",