vite 4.0.0-alpha.6 → 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.
@@ -119,16 +119,16 @@ function splitVendorChunkPlugin() {
119
119
  build: {
120
120
  rollupOptions: {
121
121
  output: {
122
- manualChunks: createSplitVendorChunk({}, config)
123
- }
124
- }
125
- }
122
+ manualChunks: createSplitVendorChunk({}, config),
123
+ },
124
+ },
125
+ },
126
126
  };
127
127
  }
128
128
  },
129
129
  buildStart() {
130
130
  caches.forEach((cache) => cache.reset());
131
- }
131
+ },
132
132
  };
133
133
  }
134
134
 
@@ -3594,12 +3594,12 @@ function normalizeAlias(o = []) {
3594
3594
  ? o.map(normalizeSingleAlias)
3595
3595
  : Object.keys(o).map((find) => normalizeSingleAlias({
3596
3596
  find,
3597
- replacement: o[find]
3597
+ replacement: o[find],
3598
3598
  }));
3599
3599
  }
3600
3600
  // https://github.com/vitejs/vite/issues/1363
3601
3601
  // work around https://github.com/rollup/plugins/issues/759
3602
- function normalizeSingleAlias({ find, replacement, customResolver }) {
3602
+ function normalizeSingleAlias({ find, replacement, customResolver, }) {
3603
3603
  if (typeof find === 'string' &&
3604
3604
  find.endsWith('/') &&
3605
3605
  replacement.endsWith('/')) {
@@ -3608,7 +3608,7 @@ function normalizeSingleAlias({ find, replacement, customResolver }) {
3608
3608
  }
3609
3609
  const alias = {
3610
3610
  find,
3611
- replacement
3611
+ replacement,
3612
3612
  };
3613
3613
  if (customResolver) {
3614
3614
  alias.customResolver = customResolver;
@@ -3748,7 +3748,7 @@ function stattag (stat) {
3748
3748
 
3749
3749
  const isDebug = !!process.env.DEBUG;
3750
3750
  createDebugger('vite:sourcemap', {
3751
- onlyWhenFocused: true
3751
+ onlyWhenFocused: true,
3752
3752
  });
3753
3753
  function genSourceMapUrl(map) {
3754
3754
  if (typeof map !== 'string') {
@@ -3773,10 +3773,10 @@ const alias = {
3773
3773
  js: 'application/javascript',
3774
3774
  css: 'text/css',
3775
3775
  html: 'text/html',
3776
- json: 'application/json'
3776
+ json: 'application/json',
3777
3777
  };
3778
3778
  function send(req, res, content, type, options) {
3779
- const { etag = etag_1(content, { weak: true }), cacheControl = 'no-cache', headers, map } = options;
3779
+ const { etag = etag_1(content, { weak: true }), cacheControl = 'no-cache', headers, map, } = options;
3780
3780
  if (res.writableEnded) {
3781
3781
  return;
3782
3782
  }
@@ -3809,7 +3809,7 @@ const LogLevels = {
3809
3809
  silent: 0,
3810
3810
  error: 1,
3811
3811
  warn: 2,
3812
- info: 3
3812
+ info: 3,
3813
3813
  };
3814
3814
  let lastType;
3815
3815
  let lastMsg;
@@ -3898,7 +3898,7 @@ function createLogger(level = 'info', options = {}) {
3898
3898
  },
3899
3899
  hasErrorLogged(error) {
3900
3900
  return loggedErrors.has(error);
3901
- }
3901
+ },
3902
3902
  };
3903
3903
  return logger;
3904
3904
  }
@@ -3914,7 +3914,7 @@ const ROOT_FILES = [
3914
3914
  // 'workspace.json',
3915
3915
  // 'nx.json',
3916
3916
  // https://github.com/lerna/lerna#lernajson
3917
- 'lerna.json'
3917
+ 'lerna.json',
3918
3918
  ];
3919
3919
  // npm: https://docs.npmjs.com/cli/v7/using-npm/workspaces#installing-workspaces
3920
3920
  // yarn: https://classic.yarnpkg.com/en/docs/workspaces/#toc-how-to-use-it
@@ -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
  }
@@ -4219,29 +4220,29 @@ function loadEnv(mode, envDir, prefixes = 'VITE_') {
4219
4220
  /** default file */ `.env`,
4220
4221
  /** local file */ `.env.local`,
4221
4222
  /** mode file */ `.env.${mode}`,
4222
- /** mode local file */ `.env.${mode}.local`
4223
+ /** mode local file */ `.env.${mode}.local`,
4223
4224
  ];
4224
4225
  const parsed = Object.fromEntries(envFiles.flatMap((file) => {
4225
4226
  const path = lookupFile(envDir, [file], {
4226
4227
  pathOnly: true,
4227
- rootDir: envDir
4228
+ rootDir: envDir,
4228
4229
  });
4229
4230
  if (!path)
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))) {
@@ -4262,7 +4263,7 @@ function loadEnv(mode, envDir, prefixes = 'VITE_') {
4262
4263
  }
4263
4264
  return env;
4264
4265
  }
4265
- function resolveEnvPrefix({ envPrefix = 'VITE_' }) {
4266
+ function resolveEnvPrefix({ envPrefix = 'VITE_', }) {
4266
4267
  envPrefix = arraify(envPrefix);
4267
4268
  if (envPrefix.some((prefix) => prefix === '')) {
4268
4269
  throw new Error(`envPrefix option contains value '', which could lead unexpected exposure of sensitive information.`);
package/index.cjs CHANGED
@@ -16,7 +16,7 @@ const asyncFunctions = [
16
16
  'optimizeDeps',
17
17
  'formatPostcssSourceMap',
18
18
  'loadConfigFromFile',
19
- 'preprocessCSS'
19
+ 'preprocessCSS',
20
20
  ]
21
21
  asyncFunctions.forEach((name) => {
22
22
  module.exports[name] = (...args) =>
@@ -28,7 +28,7 @@ const unsupportedCJS = ['resolvePackageEntry', 'resolvePackageData']
28
28
  unsupportedCJS.forEach((name) => {
29
29
  module.exports[name] = () => {
30
30
  throw new Error(
31
- `"${name}" is not supported in CJS build of Vite 3.\nPlease use ESM or dynamic imports \`const { ${name} } = await import('vite')\`.`
31
+ `"${name}" is not supported in CJS build of Vite 3.\nPlease use ESM or dynamic imports \`const { ${name} } = await import('vite')\`.`,
32
32
  )
33
33
  }
34
34
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "4.0.0-alpha.6",
3
+ "version": "4.0.0-beta.1",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",
@@ -51,7 +51,7 @@
51
51
  "build-types-pre-patch": "tsx scripts/prePatchTypes.ts",
52
52
  "build-types-roll": "api-extractor run && rimraf temp",
53
53
  "build-types-post-patch": "tsx scripts/postPatchTypes.ts",
54
- "build-types-check": "tsc --project tsconfig.check.json",
54
+ "build-types-check": "tsx scripts/checkBuiltTypes.ts && tsc --project tsconfig.check.json",
55
55
  "lint": "eslint --cache --ext .ts src/**",
56
56
  "format": "prettier --write --cache --parser typescript \"src/**/*.ts\"",
57
57
  "prepublishOnly": "npm run build"
@@ -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.3.0"
64
+ "rollup": "^3.6.0"
65
65
  },
66
66
  "optionalDependencies": {
67
67
  "fsevents": "~2.3.2"
@@ -97,7 +97,7 @@
97
97
  "fast-glob": "^3.2.12",
98
98
  "http-proxy": "^1.18.1",
99
99
  "launch-editor-middleware": "^2.6.0",
100
- "magic-string": "^0.26.7",
100
+ "magic-string": "^0.27.0",
101
101
  "micromatch": "^4.0.5",
102
102
  "mlly": "^0.5.17",
103
103
  "mrmime": "^1.0.1",
@@ -107,7 +107,7 @@
107
107
  "periscopic": "^3.0.4",
108
108
  "picocolors": "^1.0.0",
109
109
  "picomatch": "^2.3.1",
110
- "postcss-import": "^15.0.0",
110
+ "postcss-import": "^15.0.1",
111
111
  "postcss-load-config": "^4.0.1",
112
112
  "postcss-modules": "^6.0.0",
113
113
  "resolve.exports": "^1.1.0",
@@ -2,7 +2,7 @@ import type {
2
2
  ErrorPayload,
3
3
  FullReloadPayload,
4
4
  PrunePayload,
5
- UpdatePayload
5
+ UpdatePayload,
6
6
  } from './hmrPayload'
7
7
 
8
8
  export interface CustomEventMap {
package/types/hot.d.ts CHANGED
@@ -12,22 +12,21 @@ export interface ViteHotContext {
12
12
  accept(dep: string, cb: (mod: ModuleNamespace | undefined) => void): void
13
13
  accept(
14
14
  deps: readonly string[],
15
- cb: (mods: Array<ModuleNamespace | undefined>) => void
15
+ cb: (mods: Array<ModuleNamespace | undefined>) => void,
16
16
  ): void
17
17
 
18
18
  acceptExports(
19
19
  exportNames: string | readonly string[],
20
- cb?: (mod: ModuleNamespace | undefined) => void
20
+ cb?: (mod: ModuleNamespace | undefined) => void,
21
21
  ): void
22
22
 
23
23
  dispose(cb: (data: any) => void): void
24
24
  prune(cb: (data: any) => void): void
25
- decline(): void
26
25
  invalidate(message?: string): void
27
26
 
28
27
  on<T extends string>(
29
28
  event: T,
30
- cb: (payload: InferCustomEventPayload<T>) => void
29
+ cb: (payload: InferCustomEventPayload<T>) => void,
31
30
  ): void
32
31
  send<T extends string>(event: T, data?: InferCustomEventPayload<T>): void
33
32
  }
@@ -1,6 +1,6 @@
1
1
  export interface ImportGlobOptions<
2
2
  Eager extends boolean,
3
- AsType extends string
3
+ AsType extends string,
4
4
  > {
5
5
  /**
6
6
  * Import type for the import url.
@@ -45,10 +45,10 @@ export interface ImportGlobFunction {
45
45
  <
46
46
  Eager extends boolean,
47
47
  As extends string,
48
- T = As extends keyof KnownAsTypeMap ? KnownAsTypeMap[As] : unknown
48
+ T = As extends keyof KnownAsTypeMap ? KnownAsTypeMap[As] : unknown,
49
49
  >(
50
50
  glob: string | string[],
51
- options?: ImportGlobOptions<Eager, As>
51
+ options?: ImportGlobOptions<Eager, As>,
52
52
  ): (Eager extends true ? true : false) extends true
53
53
  ? Record<string, T>
54
54
  : Record<string, () => Promise<T>>
@@ -59,7 +59,7 @@ export interface ImportGlobFunction {
59
59
  */
60
60
  <M>(
61
61
  glob: string | string[],
62
- options?: ImportGlobOptions<false, string>
62
+ options?: ImportGlobOptions<false, string>,
63
63
  ): Record<string, () => Promise<M>>
64
64
  /**
65
65
  * Import a list of files with a glob pattern.
@@ -68,7 +68,7 @@ export interface ImportGlobFunction {
68
68
  */
69
69
  <M>(
70
70
  glob: string | string[],
71
- options: ImportGlobOptions<true, string>
71
+ options: ImportGlobOptions<true, string>,
72
72
  ): Record<string, M>
73
73
  }
74
74
 
@@ -80,10 +80,10 @@ export interface ImportGlobEagerFunction {
80
80
  */
81
81
  <
82
82
  As extends string,
83
- T = As extends keyof KnownAsTypeMap ? KnownAsTypeMap[As] : unknown
83
+ T = As extends keyof KnownAsTypeMap ? KnownAsTypeMap[As] : unknown,
84
84
  >(
85
85
  glob: string | string[],
86
- options?: Omit<ImportGlobOptions<boolean, As>, 'eager'>
86
+ options?: Omit<ImportGlobOptions<boolean, As>, 'eager'>,
87
87
  ): Record<string, T>
88
88
  /**
89
89
  * Eagerly import a list of files with a glob pattern.
@@ -92,6 +92,6 @@ export interface ImportGlobEagerFunction {
92
92
  */
93
93
  <M>(
94
94
  glob: string | string[],
95
- options?: Omit<ImportGlobOptions<boolean, string>, 'eager'>
95
+ options?: Omit<ImportGlobOptions<boolean, string>, 'eager'>,
96
96
  ): Record<string, M>
97
97
  }