vite 3.0.0-beta.2 → 3.0.0-beta.5

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,6 +1,6 @@
1
1
  import { performance } from 'node:perf_hooks';
2
2
  import { EventEmitter } from 'events';
3
- import { x as colors, q as createLogger, e as resolveConfig } from './chunks/dep-7c996900.js';
3
+ import { x as picocolors, q as createLogger, e as resolveConfig } from './chunks/dep-332aa27f.js';
4
4
  import { VERSION } from './constants.js';
5
5
  import 'node:fs';
6
6
  import 'node:path';
@@ -11,7 +11,6 @@ import 'esbuild';
11
11
  import 'path';
12
12
  import 'fs';
13
13
  import 'assert';
14
- import 'resolve';
15
14
  import 'util';
16
15
  import 'net';
17
16
  import 'url';
@@ -23,9 +22,9 @@ import 'node:os';
23
22
  import 'node:crypto';
24
23
  import 'node:util';
25
24
  import 'node:dns';
25
+ import 'resolve';
26
26
  import 'crypto';
27
27
  import 'buffer';
28
- import 'querystring';
29
28
  import 'module';
30
29
  import 'zlib';
31
30
  import 'https';
@@ -33,6 +32,7 @@ import 'tls';
33
32
  import 'node:http';
34
33
  import 'node:https';
35
34
  import 'worker_threads';
35
+ import 'querystring';
36
36
  import 'readline';
37
37
  import 'node:child_process';
38
38
  import 'node:zlib';
@@ -694,7 +694,7 @@ cli
694
694
  .action(async (root, options) => {
695
695
  // output structure is preserved even after bundling so require()
696
696
  // is ok here
697
- const { createServer } = await import('./chunks/dep-7c996900.js').then(function (n) { return n.D; });
697
+ const { createServer } = await import('./chunks/dep-332aa27f.js').then(function (n) { return n.D; });
698
698
  try {
699
699
  const server = await createServer({
700
700
  root,
@@ -714,13 +714,13 @@ cli
714
714
  // @ts-ignore
715
715
  const viteStartTime = global.__vite_start_time ?? false;
716
716
  const startupDurationString = viteStartTime
717
- ? 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`)
718
718
  : '';
719
- 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 });
720
720
  server.printUrls();
721
721
  }
722
722
  catch (e) {
723
- 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 });
724
724
  process.exit(1);
725
725
  }
726
726
  });
@@ -741,7 +741,7 @@ cli
741
741
  .option('--emptyOutDir', `[boolean] force empty outDir when it's outside of root`)
742
742
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
743
743
  .action(async (root, options) => {
744
- const { build } = await import('./chunks/dep-7c996900.js').then(function (n) { return n.C; });
744
+ const { build } = await import('./chunks/dep-332aa27f.js').then(function (n) { return n.C; });
745
745
  const buildOptions = cleanOptions(options);
746
746
  try {
747
747
  await build({
@@ -756,7 +756,7 @@ cli
756
756
  });
757
757
  }
758
758
  catch (e) {
759
- 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 });
760
760
  process.exit(1);
761
761
  }
762
762
  });
@@ -765,7 +765,7 @@ cli
765
765
  .command('optimize [root]', 'pre-bundle dependencies')
766
766
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
767
767
  .action(async (root, options) => {
768
- const { optimizeDeps } = await import('./chunks/dep-7c996900.js').then(function (n) { return n.B; });
768
+ const { optimizeDeps } = await import('./chunks/dep-332aa27f.js').then(function (n) { return n.B; });
769
769
  try {
770
770
  const config = await resolveConfig({
771
771
  root,
@@ -776,7 +776,7 @@ cli
776
776
  await optimizeDeps(config, options.force, true);
777
777
  }
778
778
  catch (e) {
779
- 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 });
780
780
  process.exit(1);
781
781
  }
782
782
  });
@@ -788,7 +788,7 @@ cli
788
788
  .option('--https', `[boolean] use TLS + HTTP/2`)
789
789
  .option('--open [path]', `[boolean | string] open browser on startup`)
790
790
  .action(async (root, options) => {
791
- const { preview } = await import('./chunks/dep-7c996900.js').then(function (n) { return n.E; });
791
+ const { preview } = await import('./chunks/dep-332aa27f.js').then(function (n) { return n.E; });
792
792
  try {
793
793
  const server = await preview({
794
794
  root,
@@ -807,7 +807,7 @@ cli
807
807
  server.printUrls();
808
808
  }
809
809
  catch (e) {
810
- 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 });
811
811
  process.exit(1);
812
812
  }
813
813
  });
@@ -1,7 +1,7 @@
1
1
  import path, { resolve } from 'node:path';
2
2
  import { fileURLToPath } from 'node:url';
3
3
 
4
- var version = "3.0.0-beta.2";
4
+ var version = "3.0.0-beta.5";
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',
@@ -50,7 +59,9 @@ const VALID_ID_PREFIX = `/@id/`;
50
59
  const NULL_BYTE_PLACEHOLDER = `__x00__`;
51
60
  const CLIENT_PUBLIC_PATH = `/@vite/client`;
52
61
  const ENV_PUBLIC_PATH = `/@vite/env`;
53
- 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), '../../..');
54
65
  const CLIENT_ENTRY = resolve(VITE_PACKAGE_DIR, 'dist/client/client.mjs');
55
66
  const ENV_ENTRY = resolve(VITE_PACKAGE_DIR, 'dist/client/env.mjs');
56
67
  const CLIENT_DIR = path.dirname(CLIENT_ENTRY);
@@ -104,4 +115,4 @@ const wildcardHosts = new Set([
104
115
  '0000:0000:0000:0000:0000:0000:0000:0000'
105
116
  ]);
106
117
 
107
- 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, 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 };
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 };
@@ -104,26 +104,6 @@ export declare interface AwaitWriteFinishOptions {
104
104
  */
105
105
  export declare function build(inlineConfig?: InlineConfig): Promise<RollupOutput | RollupOutput[] | RollupWatcher>;
106
106
 
107
- export declare type BuildAdvancedBaseConfig = BuildAdvancedBaseOptions & {
108
- /**
109
- * Base for assets and public files in case they should be different
110
- */
111
- assets?: string | BuildAdvancedBaseOptions;
112
- public?: string | BuildAdvancedBaseOptions;
113
- };
114
-
115
- export declare interface BuildAdvancedBaseOptions {
116
- /**
117
- * Relative base. If true, every generated URL is relative and the dist folder
118
- * can be deployed to any base or subdomain. Use this option when the base
119
- * is unkown at build time
120
- * @default false
121
- */
122
- relative?: boolean;
123
- url?: string;
124
- runtime?: (filename: string) => string;
125
- }
126
-
127
107
  export declare interface BuildOptions {
128
108
  /**
129
109
  * Compatibility transform target. The transform is performed with esbuild
@@ -650,6 +630,7 @@ export declare interface DepsOptimizer {
650
630
  delayDepsOptimizerUntil: (id: string, done: () => Promise<any>) => void;
651
631
  registerWorkersSource: (id: string) => void;
652
632
  resetRegisteredIds: () => void;
633
+ ensureFirstRun: () => void;
653
634
  options: DepOptimizationOptions;
654
635
  }
655
636
 
@@ -675,6 +656,10 @@ export declare interface ESBuildOptions extends EsbuildTransformOptions {
675
656
  include?: string | RegExp | string[] | RegExp[];
676
657
  exclude?: string | RegExp | string[] | RegExp[];
677
658
  jsxInject?: string;
659
+ /**
660
+ * This option is not respected. Use `build.minify` instead.
661
+ */
662
+ minify?: never;
678
663
  }
679
664
 
680
665
  export { EsbuildTransformOptions }
@@ -694,11 +679,11 @@ export declare interface ExperimentalOptions {
694
679
  */
695
680
  importGlobRestoreExtension?: boolean;
696
681
  /**
697
- * Build advanced base options. Allow finegrain contol over assets and public files base
682
+ * Allow finegrain contol over assets and public files paths
698
683
  *
699
684
  * @experimental
700
685
  */
701
- buildAdvancedBaseOptions?: BuildAdvancedBaseConfig;
686
+ renderBuiltUrl?: RenderBuiltAssetUrl;
702
687
  /**
703
688
  * Enables support of HMR partial accept via `import.meta.hot.acceptExports`.
704
689
  *
@@ -1648,19 +1633,24 @@ export declare interface PrunePayload {
1648
1633
  paths: string[]
1649
1634
  }
1650
1635
 
1636
+ export declare type RenderBuiltAssetUrl = (filename: string, type: {
1637
+ type: 'asset' | 'public';
1638
+ hostId: string;
1639
+ hostType: 'js' | 'css' | 'html';
1640
+ ssr: boolean;
1641
+ }) => string | {
1642
+ relative?: boolean;
1643
+ runtime?: string;
1644
+ } | undefined;
1645
+
1651
1646
  /**
1652
1647
  * Resolve base url. Note that some users use Vite to build for non-web targets like
1653
1648
  * electron or expects to deploy
1654
1649
  */
1655
- export declare function resolveBaseUrl(base: string | undefined, isBuild: boolean, logger: Logger, optionName: string): string;
1650
+ export declare function resolveBaseUrl(base: string | undefined, isBuild: boolean, logger: Logger): string;
1656
1651
 
1657
1652
  export declare function resolveConfig(inlineConfig: InlineConfig, command: 'build' | 'serve', defaultMode?: string): Promise<ResolvedConfig>;
1658
1653
 
1659
- export declare type ResolvedBuildAdvancedBaseConfig = BuildAdvancedBaseOptions & {
1660
- assets: BuildAdvancedBaseOptions;
1661
- public: BuildAdvancedBaseOptions;
1662
- };
1663
-
1664
1654
  export declare type ResolvedBuildOptions = Required<BuildOptions>;
1665
1655
 
1666
1656
  export declare type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'assetsInclude' | 'optimizeDeps' | 'worker'> & {
@@ -1692,13 +1682,9 @@ export declare type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'asse
1692
1682
  /* Excluded from this release type: packageCache */
1693
1683
  worker: ResolveWorkerOptions;
1694
1684
  appType: AppType;
1695
- experimental: ResolvedExperimentalOptions;
1685
+ experimental: ExperimentalOptions;
1696
1686
  }>;
1697
1687
 
1698
- export declare type ResolvedExperimentalOptions = Required<ExperimentalOptions> & {
1699
- buildAdvancedBaseOptions: ResolvedBuildAdvancedBaseConfig;
1700
- };
1701
-
1702
1688
  export declare interface ResolvedPreviewOptions extends PreviewOptions {
1703
1689
  }
1704
1690
 
@@ -1,4 +1,4 @@
1
- export { b as build, j as createFilter, q as createLogger, c as createServer, d as defineConfig, f as formatPostcssSourceMap, i as isDepsOptimizerEnabled, l as loadConfigFromFile, v as loadEnv, h as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, p as preview, g as resolveBaseUrl, e as resolveConfig, w as resolveEnvPrefix, a as resolvePackageData, r as resolvePackageEntry, u as searchForWorkspaceRoot, k as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-7c996900.js';
1
+ export { b as build, j as createFilter, q as createLogger, c as createServer, d as defineConfig, f as formatPostcssSourceMap, i as isDepsOptimizerEnabled, l as loadConfigFromFile, v as loadEnv, h as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, p as preview, g as resolveBaseUrl, e as resolveConfig, w as resolveEnvPrefix, a as resolvePackageData, r as resolvePackageEntry, u as searchForWorkspaceRoot, k as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-332aa27f.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';
@@ -12,7 +12,6 @@ import 'path';
12
12
  import 'fs';
13
13
  import 'events';
14
14
  import 'assert';
15
- import 'resolve';
16
15
  import 'util';
17
16
  import 'net';
18
17
  import 'url';
@@ -24,9 +23,9 @@ import 'node:os';
24
23
  import 'node:crypto';
25
24
  import 'node:util';
26
25
  import 'node:dns';
26
+ import 'resolve';
27
27
  import 'crypto';
28
28
  import 'buffer';
29
- import 'querystring';
30
29
  import 'module';
31
30
  import 'zlib';
32
31
  import 'https';
@@ -34,6 +33,7 @@ import 'tls';
34
33
  import 'node:http';
35
34
  import 'node:https';
36
35
  import 'worker_threads';
36
+ import 'querystring';
37
37
  import 'readline';
38
38
  import 'node:child_process';
39
39
  import 'node:zlib';