vite 3.0.0-alpha.9 → 3.0.0-beta.10

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.
package/dist/node/cli.js CHANGED
@@ -1,29 +1,41 @@
1
- import { performance } from 'perf_hooks';
1
+ import { performance } from 'node:perf_hooks';
2
2
  import { EventEmitter } from 'events';
3
- import { v as colors, j as createLogger, e as resolveConfig } from './chunks/dep-8df7bfd6.js';
3
+ import { y as picocolors, u as createLogger, e as resolveConfig } from './chunks/dep-7c75cb17.js';
4
4
  import { VERSION } from './constants.js';
5
- import 'fs';
6
- import 'path';
7
- import 'url';
8
- import 'module';
5
+ import 'node:fs';
6
+ import 'node:path';
7
+ import 'node:url';
8
+ import 'node:module';
9
9
  import 'tty';
10
10
  import 'esbuild';
11
+ import 'path';
12
+ import 'fs';
11
13
  import 'assert';
12
- import 'resolve';
13
14
  import 'util';
14
15
  import 'net';
16
+ import 'url';
15
17
  import 'http';
16
18
  import 'stream';
17
19
  import 'os';
18
20
  import 'child_process';
21
+ import 'node:os';
22
+ import 'node:crypto';
23
+ import 'node:util';
24
+ import 'node:dns';
25
+ import 'resolve';
19
26
  import 'crypto';
20
27
  import 'buffer';
21
- import 'querystring';
28
+ import 'module';
22
29
  import 'zlib';
23
30
  import 'https';
24
31
  import 'tls';
32
+ import 'node:http';
33
+ import 'node:https';
25
34
  import 'worker_threads';
35
+ import 'querystring';
26
36
  import 'readline';
37
+ import 'node:child_process';
38
+ import 'node:zlib';
27
39
 
28
40
  function toArr(any) {
29
41
  return any == null ? [] : Array.isArray(any) ? any : [any];
@@ -682,7 +694,7 @@ cli
682
694
  .action(async (root, options) => {
683
695
  // output structure is preserved even after bundling so require()
684
696
  // is ok here
685
- const { createServer } = await import('./chunks/dep-8df7bfd6.js').then(function (n) { return n.B; });
697
+ const { createServer } = await import('./chunks/dep-7c75cb17.js').then(function (n) { return n.E; });
686
698
  try {
687
699
  const server = await createServer({
688
700
  root,
@@ -691,6 +703,7 @@ cli
691
703
  configFile: options.config,
692
704
  logLevel: options.logLevel,
693
705
  clearScreen: options.clearScreen,
706
+ optimizeDeps: { force: options.force },
694
707
  server: cleanOptions(options)
695
708
  });
696
709
  if (!server.httpServer) {
@@ -701,13 +714,13 @@ cli
701
714
  // @ts-ignore
702
715
  const viteStartTime = global.__vite_start_time ?? false;
703
716
  const startupDurationString = viteStartTime
704
- ? colors.dim(`ready in ${colors.white(colors.bold(Math.ceil(performance.now() - viteStartTime)))} ms`)
717
+ ? picocolors.exports.dim(`ready in ${picocolors.exports.white(picocolors.exports.bold(Math.ceil(performance.now() - viteStartTime)))} ms`)
705
718
  : '';
706
- info(`\n ${colors.green(`${colors.bold('VITE')} v${VERSION}`)} ${startupDurationString}\n`, { clear: !server.config.logger.hasWarned });
719
+ info(`\n ${picocolors.exports.green(`${picocolors.exports.bold('VITE')} v${VERSION}`)} ${startupDurationString}\n`, { clear: !server.config.logger.hasWarned });
707
720
  server.printUrls();
708
721
  }
709
722
  catch (e) {
710
- createLogger(options.logLevel).error(colors.red(`error when starting dev server:\n${e.stack}`), { error: e });
723
+ createLogger(options.logLevel).error(picocolors.exports.red(`error when starting dev server:\n${e.stack}`), { error: e });
711
724
  process.exit(1);
712
725
  }
713
726
  });
@@ -728,7 +741,7 @@ cli
728
741
  .option('--emptyOutDir', `[boolean] force empty outDir when it's outside of root`)
729
742
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
730
743
  .action(async (root, options) => {
731
- const { build } = await import('./chunks/dep-8df7bfd6.js').then(function (n) { return n.A; });
744
+ const { build } = await import('./chunks/dep-7c75cb17.js').then(function (n) { return n.D; });
732
745
  const buildOptions = cleanOptions(options);
733
746
  try {
734
747
  await build({
@@ -738,12 +751,12 @@ cli
738
751
  configFile: options.config,
739
752
  logLevel: options.logLevel,
740
753
  clearScreen: options.clearScreen,
741
- force: options.force,
754
+ optimizeDeps: { force: options.force },
742
755
  build: buildOptions
743
756
  });
744
757
  }
745
758
  catch (e) {
746
- createLogger(options.logLevel).error(colors.red(`error during build:\n${e.stack}`), { error: e });
759
+ createLogger(options.logLevel).error(picocolors.exports.red(`error during build:\n${e.stack}`), { error: e });
747
760
  process.exit(1);
748
761
  }
749
762
  });
@@ -752,7 +765,7 @@ cli
752
765
  .command('optimize [root]', 'pre-bundle dependencies')
753
766
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
754
767
  .action(async (root, options) => {
755
- const { optimizeDeps } = await import('./chunks/dep-8df7bfd6.js').then(function (n) { return n.z; });
768
+ const { optimizeDeps } = await import('./chunks/dep-7c75cb17.js').then(function (n) { return n.C; });
756
769
  try {
757
770
  const config = await resolveConfig({
758
771
  root,
@@ -763,7 +776,7 @@ cli
763
776
  await optimizeDeps(config, options.force, true);
764
777
  }
765
778
  catch (e) {
766
- createLogger(options.logLevel).error(colors.red(`error when optimizing deps:\n${e.stack}`), { error: e });
779
+ createLogger(options.logLevel).error(picocolors.exports.red(`error when optimizing deps:\n${e.stack}`), { error: e });
767
780
  process.exit(1);
768
781
  }
769
782
  });
@@ -775,7 +788,7 @@ cli
775
788
  .option('--https', `[boolean] use TLS + HTTP/2`)
776
789
  .option('--open [path]', `[boolean | string] open browser on startup`)
777
790
  .action(async (root, options) => {
778
- const { preview } = await import('./chunks/dep-8df7bfd6.js').then(function (n) { return n.C; });
791
+ const { preview } = await import('./chunks/dep-7c75cb17.js').then(function (n) { return n.F; });
779
792
  try {
780
793
  const server = await preview({
781
794
  root,
@@ -794,7 +807,7 @@ cli
794
807
  server.printUrls();
795
808
  }
796
809
  catch (e) {
797
- createLogger(options.logLevel).error(colors.red(`error when starting preview server:\n${e.stack}`), { error: e });
810
+ createLogger(options.logLevel).error(picocolors.exports.red(`error when starting preview server:\n${e.stack}`), { error: e });
798
811
  process.exit(1);
799
812
  }
800
813
  });
@@ -1,7 +1,7 @@
1
- import path, { resolve } from 'path';
2
- import { fileURLToPath } from 'url';
1
+ import path, { resolve } from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
3
 
4
- var version = "3.0.0-alpha.9";
4
+ var version = "3.0.0-beta.10";
5
5
 
6
6
  const VERSION = version;
7
7
  const DEFAULT_MAIN_FIELDS = [
@@ -9,6 +9,15 @@ const DEFAULT_MAIN_FIELDS = [
9
9
  'jsnext:main',
10
10
  'jsnext'
11
11
  ];
12
+ // Support browserslist
13
+ // "defaults and supports es6-module and supports es6-module-dynamic-import",
14
+ const ESBUILD_MODULES_TARGET = [
15
+ 'es2020',
16
+ 'edge88',
17
+ 'firefox78',
18
+ 'chrome87',
19
+ 'safari13' // transpile nullish coalescing
20
+ ];
12
21
  const DEFAULT_EXTENSIONS = [
13
22
  '.mjs',
14
23
  '.js',
@@ -17,8 +26,16 @@ const DEFAULT_EXTENSIONS = [
17
26
  '.tsx',
18
27
  '.json'
19
28
  ];
29
+ const DEFAULT_CONFIG_FILES = [
30
+ 'vite.config.js',
31
+ 'vite.config.mjs',
32
+ 'vite.config.ts',
33
+ 'vite.config.cjs',
34
+ 'vite.config.mts',
35
+ 'vite.config.cts'
36
+ ];
20
37
  const JS_TYPES_RE = /\.(?:j|t)sx?$|\.mjs$/;
21
- const OPTIMIZABLE_ENTRY_RE = /\.(?:m?js|ts)$/;
38
+ const OPTIMIZABLE_ENTRY_RE = /\.(?:(m|c)?js|ts)$/;
22
39
  const SPECIAL_QUERY_RE = /[\?&](?:worker|sharedworker|raw|url)\b/;
23
40
  /**
24
41
  * Prefix for resolved fs paths, since windows paths may not be valid as URLs.
@@ -42,17 +59,25 @@ const VALID_ID_PREFIX = `/@id/`;
42
59
  const NULL_BYTE_PLACEHOLDER = `__x00__`;
43
60
  const CLIENT_PUBLIC_PATH = `/@vite/client`;
44
61
  const ENV_PUBLIC_PATH = `/@vite/env`;
45
- const VITE_PACKAGE_DIR = resolve(fileURLToPath(import.meta.url), '../../..');
62
+ const VITE_PACKAGE_DIR = resolve(
63
+ // import.meta.url is `dist/node/constants.js` after bundle
64
+ fileURLToPath(import.meta.url), '../../..');
46
65
  const CLIENT_ENTRY = resolve(VITE_PACKAGE_DIR, 'dist/client/client.mjs');
47
66
  const ENV_ENTRY = resolve(VITE_PACKAGE_DIR, 'dist/client/env.mjs');
48
67
  const CLIENT_DIR = path.dirname(CLIENT_ENTRY);
49
68
  // ** READ THIS ** before editing `KNOWN_ASSET_TYPES`.
50
69
  // If you add an asset to `KNOWN_ASSET_TYPES`, make sure to also add it
51
- // to the TypeScript declaration file `packages/vite/client.d.ts`.
70
+ // to the TypeScript declaration file `packages/vite/client.d.ts` and
71
+ // add a mime type to the `registerCustomMime` in
72
+ // `packages/vite/src/node/plugin/assets.ts` if mime type cannot be
73
+ // looked up by mrmime.
52
74
  const KNOWN_ASSET_TYPES = [
53
75
  // images
54
76
  'png',
55
77
  'jpe?g',
78
+ 'jfif',
79
+ 'pjpeg',
80
+ 'pjp',
56
81
  'gif',
57
82
  'svg',
58
83
  'ico',
@@ -78,5 +103,16 @@ const KNOWN_ASSET_TYPES = [
78
103
  ];
79
104
  const DEFAULT_ASSETS_RE = new RegExp(`\\.(` + KNOWN_ASSET_TYPES.join('|') + `)(\\?.*)?$`);
80
105
  const DEP_VERSION_RE = /[\?&](v=[\w\.-]+)\b/;
106
+ const loopbackHosts = new Set([
107
+ 'localhost',
108
+ '127.0.0.1',
109
+ '::1',
110
+ '0000:0000:0000:0000:0000:0000:0000:0001'
111
+ ]);
112
+ const wildcardHosts = new Set([
113
+ '0.0.0.0',
114
+ '::',
115
+ '0000:0000:0000:0000:0000:0000:0000:0000'
116
+ ]);
81
117
 
82
- export { CLIENT_DIR, CLIENT_ENTRY, CLIENT_PUBLIC_PATH, DEFAULT_ASSETS_RE, DEFAULT_EXTENSIONS, DEFAULT_MAIN_FIELDS, DEP_VERSION_RE, ENV_ENTRY, ENV_PUBLIC_PATH, FS_PREFIX, JS_TYPES_RE, KNOWN_ASSET_TYPES, NULL_BYTE_PLACEHOLDER, OPTIMIZABLE_ENTRY_RE, SPECIAL_QUERY_RE, VALID_ID_PREFIX, VERSION, VITE_PACKAGE_DIR };
118
+ export { CLIENT_DIR, CLIENT_ENTRY, CLIENT_PUBLIC_PATH, DEFAULT_ASSETS_RE, DEFAULT_CONFIG_FILES, DEFAULT_EXTENSIONS, DEFAULT_MAIN_FIELDS, DEP_VERSION_RE, ENV_ENTRY, ENV_PUBLIC_PATH, ESBUILD_MODULES_TARGET, FS_PREFIX, JS_TYPES_RE, KNOWN_ASSET_TYPES, NULL_BYTE_PLACEHOLDER, OPTIMIZABLE_ENTRY_RE, SPECIAL_QUERY_RE, VALID_ID_PREFIX, VERSION, VITE_PACKAGE_DIR, loopbackHosts, wildcardHosts };