vite 4.0.0 → 4.0.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.

Potentially problematic release.


This version of vite might be problematic. Click here for more details.

@@ -249,9 +249,32 @@ readCache$1.exports.clear = function () {
249
249
  cache = Object.create(null);
250
250
  };
251
251
 
252
+ const dataURLRegexp = /^data:text\/css;base64,/i;
253
+
254
+ function isValid(url) {
255
+ return dataURLRegexp.test(url)
256
+ }
257
+
258
+ function contents(url) {
259
+ // "data:text/css;base64,".length === 21
260
+ return Buffer.from(url.slice(21), "base64").toString()
261
+ }
262
+
263
+ var dataUrl = {
264
+ isValid,
265
+ contents,
266
+ };
267
+
252
268
  const readCache = readCache$1.exports;
269
+ const dataURL$1 = dataUrl;
253
270
 
254
- var loadContent$1 = filename => readCache(filename, "utf-8");
271
+ var loadContent$1 = filename => {
272
+ if (dataURL$1.isValid(filename)) {
273
+ return dataURL$1.contents(filename)
274
+ }
275
+
276
+ return readCache(filename, "utf-8")
277
+ };
255
278
 
256
279
  // builtin tooling
257
280
  const path$1 = require$$0;
@@ -509,6 +532,7 @@ const loadContent = loadContent$1;
509
532
  const processContent = processContent$1;
510
533
  const parseStatements = parseStatements$1;
511
534
  const assignLayerNames = assignLayerNames$1;
535
+ const dataURL = dataUrl;
512
536
 
513
537
  function AtImport(options) {
514
538
  options = {
@@ -789,6 +813,14 @@ function AtImport(options) {
789
813
  }
790
814
 
791
815
  function resolveImportId(result, stmt, options, state) {
816
+ if (dataURL.isValid(stmt.uri)) {
817
+ return loadImportContent(result, stmt, stmt.uri, options, state).then(
818
+ result => {
819
+ stmt.children = result;
820
+ }
821
+ )
822
+ }
823
+
792
824
  const atRule = stmt.node;
793
825
  let sourceFile;
794
826
  if (atRule.source?.input?.file) {
@@ -1,6 +1,6 @@
1
1
  import require$$0__default from 'fs';
2
2
  import require$$0 from 'postcss';
3
- import { C as commonjsGlobal } from './dep-ed9cb113.js';
3
+ import { C as commonjsGlobal } from './dep-6305614c.js';
4
4
  import require$$0$1 from 'path';
5
5
  import require$$5 from 'crypto';
6
6
  import require$$0$2 from 'util';
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 picocolors, B as bindShortcuts, w as createLogger, h as resolveConfig } from './chunks/dep-ed9cb113.js';
5
+ import { A as picocolors, B as bindShortcuts, w as createLogger, h as resolveConfig } from './chunks/dep-6305614c.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:url';
8
8
  import 'node:module';
@@ -652,7 +652,6 @@ class CAC extends EventEmitter {
652
652
  const cac = (name = "") => new CAC(name);
653
653
 
654
654
  const cli = cac('vite');
655
- // @ts-ignore
656
655
  let profileSession = global.__vite_profile_session;
657
656
  let profileCount = 0;
658
657
  const stopProfiler = (log) => {
@@ -725,7 +724,7 @@ cli
725
724
  filterDuplicateOptions(options);
726
725
  // output structure is preserved even after bundling so require()
727
726
  // is ok here
728
- const { createServer } = await import('./chunks/dep-ed9cb113.js').then(function (n) { return n.F; });
727
+ const { createServer } = await import('./chunks/dep-6305614c.js').then(function (n) { return n.F; });
729
728
  try {
730
729
  const server = await createServer({
731
730
  root,
@@ -742,7 +741,6 @@ cli
742
741
  }
743
742
  await server.listen();
744
743
  const info = server.config.logger.info;
745
- // @ts-ignore
746
744
  const viteStartTime = global.__vite_start_time ?? false;
747
745
  const startupDurationString = viteStartTime
748
746
  ? picocolors.exports.dim(`ready in ${picocolors.exports.reset(picocolors.exports.bold(Math.ceil(performance.now() - viteStartTime)))} ms`)
@@ -804,7 +802,7 @@ cli
804
802
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
805
803
  .action(async (root, options) => {
806
804
  filterDuplicateOptions(options);
807
- const { build } = await import('./chunks/dep-ed9cb113.js').then(function (n) { return n.E; });
805
+ const { build } = await import('./chunks/dep-6305614c.js').then(function (n) { return n.E; });
808
806
  const buildOptions = cleanOptions(options);
809
807
  try {
810
808
  await build({
@@ -832,14 +830,14 @@ cli
832
830
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
833
831
  .action(async (root, options) => {
834
832
  filterDuplicateOptions(options);
835
- const { optimizeDeps } = await import('./chunks/dep-ed9cb113.js').then(function (n) { return n.D; });
833
+ const { optimizeDeps } = await import('./chunks/dep-6305614c.js').then(function (n) { return n.D; });
836
834
  try {
837
835
  const config = await resolveConfig({
838
836
  root,
839
837
  base: options.base,
840
838
  configFile: options.config,
841
839
  logLevel: options.logLevel,
842
- }, 'build');
840
+ }, 'serve');
843
841
  await optimizeDeps(config, options.force, true);
844
842
  }
845
843
  catch (e) {
@@ -857,7 +855,7 @@ cli
857
855
  .option('--outDir <dir>', `[string] output directory (default: dist)`)
858
856
  .action(async (root, options) => {
859
857
  filterDuplicateOptions(options);
860
- const { preview } = await import('./chunks/dep-ed9cb113.js').then(function (n) { return n.G; });
858
+ const { preview } = await import('./chunks/dep-6305614c.js').then(function (n) { return n.G; });
861
859
  try {
862
860
  const server = await preview({
863
861
  root,
@@ -1852,17 +1852,17 @@ export declare interface RollupCommonJSOptions {
1852
1852
  * they should be left unconverted as it requires an optional dependency
1853
1853
  * that may or may not be installed beside the rolled up package.
1854
1854
  * Due to the conversion of `require` to a static `import` - the call is
1855
- * hoisted to the top of the file, outside of the `try-catch` clause.
1855
+ * hoisted to the top of the file, outside the `try-catch` clause.
1856
1856
  *
1857
- * - `true`: All `require` calls inside a `try` will be left unconverted.
1857
+ * - `true`: Default. All `require` calls inside a `try` will be left unconverted.
1858
1858
  * - `false`: All `require` calls inside a `try` will be converted as if the
1859
1859
  * `try-catch` clause is not there.
1860
1860
  * - `remove`: Remove all `require` calls from inside any `try` block.
1861
1861
  * - `string[]`: Pass an array containing the IDs to left unconverted.
1862
- * - `((id: string) => boolean|'remove')`: Pass a function that control
1862
+ * - `((id: string) => boolean|'remove')`: Pass a function that controls
1863
1863
  * individual IDs.
1864
1864
  *
1865
- * @default false
1865
+ * @default true
1866
1866
  */
1867
1867
  ignoreTryCatch?:
1868
1868
  | boolean
@@ -1876,14 +1876,14 @@ export declare interface RollupCommonJSOptions {
1876
1876
  * NodeJS where ES modules can only import a default export from a CommonJS
1877
1877
  * dependency.
1878
1878
  *
1879
- * If you set `esmExternals` to `true`, this plugins assumes that all
1879
+ * If you set `esmExternals` to `true`, this plugin assumes that all
1880
1880
  * external dependencies are ES modules and respect the
1881
1881
  * `requireReturnsDefault` option. If that option is not set, they will be
1882
1882
  * rendered as namespace imports.
1883
1883
  *
1884
1884
  * You can also supply an array of ids to be treated as ES modules, or a
1885
- * function that will be passed each external id to determine if it is an ES
1886
- * module.
1885
+ * function that will be passed each external id to determine whether it is
1886
+ * an ES module.
1887
1887
  * @default false
1888
1888
  */
1889
1889
  esmExternals?: boolean | ReadonlyArray<string> | ((id: string) => boolean)
@@ -1901,7 +1901,7 @@ export declare interface RollupCommonJSOptions {
1901
1901
  * import * as foo from 'foo';
1902
1902
  * ```
1903
1903
  *
1904
- * However there are some situations where this may not be desired.
1904
+ * However, there are some situations where this may not be desired.
1905
1905
  * For these situations, you can change Rollup's behaviour either globally or
1906
1906
  * per module. To change it globally, set the `requireReturnsDefault` option
1907
1907
  * to one of the following values:
@@ -1952,7 +1952,7 @@ export declare interface RollupCommonJSOptions {
1952
1952
  * Some modules contain dynamic `require` calls, or require modules that
1953
1953
  * contain circular dependencies, which are not handled well by static
1954
1954
  * imports. Including those modules as `dynamicRequireTargets` will simulate a
1955
- * CommonJS (NodeJS-like) environment for them with support for dynamic
1955
+ * CommonJS (NodeJS-like) environment for them with support for dynamic
1956
1956
  * dependencies. It also enables `strictRequires` for those modules.
1957
1957
  *
1958
1958
  * Note: In extreme cases, this feature may result in some paths being
@@ -1966,7 +1966,7 @@ export declare interface RollupCommonJSOptions {
1966
1966
  * To avoid long paths when using the `dynamicRequireTargets` option, you can use this option to specify a directory
1967
1967
  * that is a common parent for all files that use dynamic require statements. Using a directory higher up such as `/`
1968
1968
  * may lead to unnecessarily long paths in the generated code and may expose directory names on your machine like your
1969
- * home directory name. By default it uses the current working directory.
1969
+ * home directory name. By default, it uses the current working directory.
1970
1970
  */
1971
1971
  dynamicRequireRoot?: string
1972
1972
  }
@@ -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-ed9cb113.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-6305614c.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';
@@ -3464,7 +3464,7 @@ isWindows ? node_util.promisify(gracefulRename) : fs$1.renameSync;
3464
3464
  function arraify(target) {
3465
3465
  return Array.isArray(target) ? target : [target];
3466
3466
  }
3467
- // @ts-expect-error
3467
+ // @ts-expect-error jest only exists when running Jest
3468
3468
  const usingDynamicImport = typeof jest === 'undefined';
3469
3469
  /**
3470
3470
  * Dynamically import files. It will make sure it's not being compiled away by TS/Rollup.
@@ -4231,6 +4231,10 @@ function loadEnv(mode, envDir, prefixes = 'VITE_') {
4231
4231
  return [];
4232
4232
  return Object.entries(parse_1(fs$1.readFileSync(path)));
4233
4233
  }));
4234
+ // test NODE_ENV override before expand as otherwise process.env.NODE_ENV would override this
4235
+ if (parsed.NODE_ENV && process.env.VITE_USER_NODE_ENV === undefined) {
4236
+ process.env.VITE_USER_NODE_ENV = parsed.NODE_ENV;
4237
+ }
4234
4238
  try {
4235
4239
  // let environment variables use each other
4236
4240
  expand_1({ parsed });
@@ -4248,11 +4252,6 @@ function loadEnv(mode, envDir, prefixes = 'VITE_') {
4248
4252
  if (prefixes.some((prefix) => key.startsWith(prefix))) {
4249
4253
  env[key] = value;
4250
4254
  }
4251
- else if (key === 'NODE_ENV' &&
4252
- process.env.VITE_USER_NODE_ENV === undefined) {
4253
- // NODE_ENV override in .env file
4254
- process.env.VITE_USER_NODE_ENV = value;
4255
- }
4256
4255
  }
4257
4256
  // check if there are actual env variables starting with VITE_*
4258
4257
  // these are typically provided inline and should be prioritized
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",
@@ -52,6 +52,7 @@
52
52
  "build-types-roll": "api-extractor run && rimraf temp",
53
53
  "build-types-post-patch": "tsx scripts/postPatchTypes.ts",
54
54
  "build-types-check": "tsx scripts/checkBuiltTypes.ts && tsc --project tsconfig.check.json",
55
+ "typecheck": "tsc --noEmit",
55
56
  "lint": "eslint --cache --ext .ts src/**",
56
57
  "format": "prettier --write --cache --parser typescript \"src/**/*.ts\"",
57
58
  "prepublishOnly": "npm run build"
@@ -59,7 +60,7 @@
59
60
  "//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!",
60
61
  "dependencies": {
61
62
  "esbuild": "^0.16.3",
62
- "postcss": "^8.4.19",
63
+ "postcss": "^8.4.20",
63
64
  "resolve": "^1.22.1",
64
65
  "rollup": "^3.7.0"
65
66
  },
@@ -72,7 +73,7 @@
72
73
  "@babel/types": "^7.20.5",
73
74
  "@jridgewell/trace-mapping": "^0.3.17",
74
75
  "@rollup/plugin-alias": "^4.0.2",
75
- "@rollup/plugin-commonjs": "^23.0.3",
76
+ "@rollup/plugin-commonjs": "^23.0.4",
76
77
  "@rollup/plugin-dynamic-import-vars": "^2.0.1",
77
78
  "@rollup/plugin-json": "^5.0.2",
78
79
  "@rollup/plugin-node-resolve": "15.0.1",
@@ -84,7 +85,7 @@
84
85
  "chokidar": "^3.5.3",
85
86
  "connect": "^3.7.0",
86
87
  "connect-history-api-fallback": "^2.0.0",
87
- "convert-source-map": "^1.9.0",
88
+ "convert-source-map": "^2.0.0",
88
89
  "cors": "^2.8.5",
89
90
  "cross-spawn": "^7.0.3",
90
91
  "debug": "^4.3.4",
@@ -99,7 +100,7 @@
99
100
  "launch-editor-middleware": "^2.6.0",
100
101
  "magic-string": "^0.27.0",
101
102
  "micromatch": "^4.0.5",
102
- "mlly": "^0.5.17",
103
+ "mlly": "^1.0.0",
103
104
  "mrmime": "^1.0.1",
104
105
  "okie": "^1.0.1",
105
106
  "open": "^8.4.0",
@@ -107,10 +108,11 @@
107
108
  "periscopic": "^3.0.4",
108
109
  "picocolors": "^1.0.0",
109
110
  "picomatch": "^2.3.1",
110
- "postcss-import": "^15.0.1",
111
+ "postcss-import": "^15.1.0",
111
112
  "postcss-load-config": "^4.0.1",
112
113
  "postcss-modules": "^6.0.0",
113
114
  "resolve.exports": "^1.1.0",
115
+ "rollup-plugin-license": "^3.0.1",
114
116
  "sirv": "^2.0.2",
115
117
  "source-map-js": "^1.0.2",
116
118
  "source-map-support": "^0.5.21",
@@ -119,7 +121,7 @@
119
121
  "tsconfck": "^2.0.1",
120
122
  "tslib": "^2.4.1",
121
123
  "types": "link:./types",
122
- "ufo": "^0.8.6",
124
+ "ufo": "^1.0.1",
123
125
  "ws": "^8.11.0"
124
126
  },
125
127
  "peerDependencies": {