vite 4.4.8 → 5.0.0-beta.0

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
@@ -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 { C as colors, D as bindShortcuts, x as createLogger, h as resolveConfig } from './chunks/dep-75f53616.js';
5
+ import { C as colors, D as bindShortcuts, x as createLogger, h as resolveConfig } from './chunks/dep-4033fb3a.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -714,6 +714,15 @@ function cleanOptions(options) {
714
714
  }
715
715
  return ret;
716
716
  }
717
+ /**
718
+ * host may be a number (like 0), should convert to string
719
+ */
720
+ const convertHost = (v) => {
721
+ if (typeof v === 'number') {
722
+ return String(v);
723
+ }
724
+ return v;
725
+ };
717
726
  cli
718
727
  .option('-c, --config <file>', `[string] use specified config file`)
719
728
  .option('--base <path>', `[string] public base path (default: /)`)
@@ -727,7 +736,7 @@ cli
727
736
  .command('[root]', 'start dev server') // default command
728
737
  .alias('serve') // the command is called 'serve' in Vite's API
729
738
  .alias('dev') // alias to align with the script name
730
- .option('--host [host]', `[string] specify hostname`)
739
+ .option('--host [host]', `[string] specify hostname`, { type: [convertHost] })
731
740
  .option('--port <port>', `[number] specify port`)
732
741
  .option('--https', `[boolean] use TLS + HTTP/2`)
733
742
  .option('--open [path]', `[boolean | string] open browser on startup`)
@@ -738,7 +747,7 @@ cli
738
747
  filterDuplicateOptions(options);
739
748
  // output structure is preserved even after bundling so require()
740
749
  // is ok here
741
- const { createServer } = await import('./chunks/dep-75f53616.js').then(function (n) { return n.I; });
750
+ const { createServer } = await import('./chunks/dep-4033fb3a.js').then(function (n) { return n.I; });
742
751
  try {
743
752
  const server = await createServer({
744
753
  root,
@@ -816,7 +825,7 @@ cli
816
825
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
817
826
  .action(async (root, options) => {
818
827
  filterDuplicateOptions(options);
819
- const { build } = await import('./chunks/dep-75f53616.js').then(function (n) { return n.H; });
828
+ const { build } = await import('./chunks/dep-4033fb3a.js').then(function (n) { return n.H; });
820
829
  const buildOptions = cleanOptions(options);
821
830
  try {
822
831
  await build({
@@ -844,7 +853,7 @@ cli
844
853
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
845
854
  .action(async (root, options) => {
846
855
  filterDuplicateOptions(options);
847
- const { optimizeDeps } = await import('./chunks/dep-75f53616.js').then(function (n) { return n.G; });
856
+ const { optimizeDeps } = await import('./chunks/dep-4033fb3a.js').then(function (n) { return n.G; });
848
857
  try {
849
858
  const config = await resolveConfig({
850
859
  root,
@@ -863,7 +872,7 @@ cli
863
872
  // preview
864
873
  cli
865
874
  .command('preview [root]', 'locally preview production build')
866
- .option('--host [host]', `[string] specify hostname`)
875
+ .option('--host [host]', `[string] specify hostname`, { type: [convertHost] })
867
876
  .option('--port <port>', `[number] specify port`)
868
877
  .option('--strictPort', `[boolean] exit if specified port is already in use`)
869
878
  .option('--https', `[boolean] use TLS + HTTP/2`)
@@ -871,7 +880,7 @@ cli
871
880
  .option('--outDir <dir>', `[string] output directory (default: dist)`)
872
881
  .action(async (root, options) => {
873
882
  filterDuplicateOptions(options);
874
- const { preview } = await import('./chunks/dep-75f53616.js').then(function (n) { return n.J; });
883
+ const { preview } = await import('./chunks/dep-4033fb3a.js').then(function (n) { return n.J; });
875
884
  try {
876
885
  const server = await preview({
877
886
  root,
@@ -2,10 +2,12 @@
2
2
 
3
3
  import type { Agent } from 'node:http';
4
4
  import type { BuildOptions as BuildOptions_2 } from 'esbuild';
5
+ import type { BundleAsyncOptions } from 'lightningcss';
5
6
  import { ChunkMetadata } from "../../types/metadata.js";
6
7
  import type { ClientRequest } from 'node:http';
7
8
  import type { ClientRequestArgs } from 'node:http';
8
9
  import { ConnectedPayload } from "../../types/hmrPayload.js";
10
+ import type { CustomAtRules } from 'lightningcss';
9
11
  import { CustomEventMap } from "../../types/customEvent.js";
10
12
  import { CustomPayload } from "../../types/hmrPayload.js";
11
13
  import type { CustomPluginOptions } from 'rollup';
@@ -23,7 +25,6 @@ import { GeneralImportGlobOptions } from "../../types/importGlob.js";
23
25
  import type { GetManualChunk } from 'rollup';
24
26
  import { HMRPayload } from "../../types/hmrPayload.js";
25
27
  import * as http from 'node:http';
26
- import { ImportGlobEagerFunction } from "../../types/importGlob.js";
27
28
  import { ImportGlobFunction } from "../../types/importGlob.js";
28
29
  import { ImportGlobOptions } from "../../types/importGlob.js";
29
30
  import type { IncomingMessage } from 'node:http';
@@ -174,7 +175,7 @@ export declare interface BuildOptions {
174
175
  assetsDir?: string;
175
176
  /**
176
177
  * Static asset files smaller than this number (in bytes) will be inlined as
177
- * base64 strings. Default limit is `4096` (4kb). Set to `0` to disable.
178
+ * base64 strings. Default limit is `4096` (4 KiB). Set to `0` to disable.
178
179
  * @default 4096
179
180
  */
180
181
  assetsInlineLimit?: number;
@@ -246,7 +247,6 @@ export declare interface BuildOptions {
246
247
  /**
247
248
  * Copy the public directory to outDir on write.
248
249
  * @default true
249
- * @experimental
250
250
  */
251
251
  copyPublicDir?: boolean;
252
252
  /**
@@ -301,7 +301,7 @@ export declare interface BuildOptions {
301
301
  */
302
302
  reportCompressedSize?: boolean;
303
303
  /**
304
- * Adjust chunk size warning limit (in kbs).
304
+ * Adjust chunk size warning limit (in kB).
305
305
  * @default 500
306
306
  */
307
307
  chunkSizeWarningLimit?: number;
@@ -511,13 +511,6 @@ export declare function createLogger(level?: LogLevel, options?: LoggerOptions):
511
511
 
512
512
  export declare function createServer(inlineConfig?: InlineConfig): Promise<ViteDevServer>;
513
513
 
514
- declare interface CSSModulesConfig {
515
- /** The pattern to use when renaming class names and other identifiers. Default is `[hash]_[local]`. */
516
- pattern?: string,
517
- /** Whether to rename dashed identifiers, e.g. custom properties. */
518
- dashedIdents?: boolean
519
- }
520
-
521
514
  export declare interface CSSModulesOptions {
522
515
  getJSON?: (cssFileName: string, json: Record<string, string>, outputFileName: string) => void;
523
516
  scopeBehaviour?: 'global' | 'local';
@@ -716,13 +709,6 @@ export declare interface DepsOptimizer {
716
709
  options: DepOptimizationOptions;
717
710
  }
718
711
 
719
- declare interface Drafts {
720
- /** Whether to enable CSS nesting. */
721
- nesting?: boolean,
722
- /** Whether to enable @custom-media rules. */
723
- customMedia?: boolean
724
- }
725
-
726
712
  export { ErrorPayload }
727
713
 
728
714
  export declare interface ESBuildOptions extends EsbuildTransformOptions {
@@ -780,32 +766,6 @@ export declare type ExportsData = {
780
766
  jsxLoader?: boolean;
781
767
  };
782
768
 
783
- declare const enum Features {
784
- Nesting = 1,
785
- NotSelectorList = 2,
786
- DirSelector = 4,
787
- LangSelectorList = 8,
788
- IsSelector = 16,
789
- TextDecorationThicknessPercent = 32,
790
- MediaIntervalSyntax = 64,
791
- MediaRangeSyntax = 128,
792
- CustomMediaQueries = 256,
793
- ClampFunction = 512,
794
- ColorFunction = 1024,
795
- OklabColors = 2048,
796
- LabColors = 4096,
797
- P3Colors = 8192,
798
- HexAlphaColors = 16384,
799
- SpaceSeparatedColorNotation = 32768,
800
- FontFamilySystemUi = 65536,
801
- DoublePositionGradients = 131072,
802
- VendorPrefixes = 262144,
803
- LogicalProperties = 524288,
804
- Selectors = 31,
805
- MediaQueries = 448,
806
- Colors = 64512,
807
- }
808
-
809
769
  export declare interface FileSystemServeOptions {
810
770
  /**
811
771
  * Strictly restrict file accessing outside of allowing paths.
@@ -1181,8 +1141,6 @@ export declare namespace HttpProxy {
1181
1141
  }
1182
1142
  }
1183
1143
 
1184
- export { ImportGlobEagerFunction }
1185
-
1186
1144
  export { ImportGlobFunction }
1187
1145
 
1188
1146
  export { ImportGlobOptions }
@@ -1323,20 +1281,7 @@ export declare interface LibraryOptions {
1323
1281
  fileName?: string | ((format: ModuleFormat, entryName: string) => string);
1324
1282
  }
1325
1283
 
1326
- /**
1327
- * Options are spread, so you can also use options that are not typed here like
1328
- * visitor (not exposed because it would impact too much the bundle size)
1329
- */
1330
- export declare type LightningCSSOptions = {
1331
- targets?: Targets
1332
- include?: Features
1333
- exclude?: Features
1334
- drafts?: Drafts
1335
- nonStandard?: NonStandard
1336
- pseudoClasses?: PseudoClasses
1337
- unusedSymbols?: string[]
1338
- cssModules?: CSSModulesConfig
1339
- }
1284
+ export declare type LightningCSSOptions = Omit<BundleAsyncOptions<CustomAtRules>, 'filename' | 'resolver' | 'minify' | 'sourceMap' | 'analyzeDependencies'>;
1340
1285
 
1341
1286
  export declare function loadConfigFromFile(configEnv: ConfigEnv, configFile?: string, configRoot?: string, logLevel?: LogLevel): Promise<{
1342
1287
  path: string;
@@ -1473,11 +1418,6 @@ export declare interface ModulePreloadOptions {
1473
1418
  resolveDependencies?: ResolveModulePreloadDependenciesFn;
1474
1419
  }
1475
1420
 
1476
- declare interface NonStandard {
1477
- /** Whether to enable the non-standard >>> and /deep/ selector combinators used by Angular and Vue. */
1478
- deepSelectorCombinator?: boolean
1479
- }
1480
-
1481
1421
  export declare function normalizePath(id: string): string;
1482
1422
 
1483
1423
  export declare interface OptimizedDepInfo {
@@ -1592,7 +1532,7 @@ declare interface Plugin_2 extends Plugin_3 {
1592
1532
  */
1593
1533
  configureServer?: ObjectHook<ServerHook>;
1594
1534
  /**
1595
- * Configure the preview server. The hook receives the {@link PreviewServerForHook}
1535
+ * Configure the preview server. The hook receives the {@link PreviewServer}
1596
1536
  * instance. This can also be used to store a reference to the server
1597
1537
  * for use in other hooks.
1598
1538
  *
@@ -1669,7 +1609,9 @@ export declare interface PluginContainer {
1669
1609
  ssr?: boolean;
1670
1610
  }): Promise<{
1671
1611
  code: string;
1672
- map: SourceMap | null;
1612
+ map: SourceMap | {
1613
+ mappings: '';
1614
+ } | null;
1673
1615
  }>;
1674
1616
  load(id: string, options?: {
1675
1617
  ssr?: boolean;
@@ -1704,11 +1646,7 @@ export declare function preview(inlineConfig?: InlineConfig): Promise<PreviewSer
1704
1646
  export declare interface PreviewOptions extends CommonServerOptions {
1705
1647
  }
1706
1648
 
1707
- export declare interface PreviewServer extends PreviewServerForHook {
1708
- resolvedUrls: ResolvedServerUrls;
1709
- }
1710
-
1711
- export declare interface PreviewServerForHook {
1649
+ export declare interface PreviewServer {
1712
1650
  /**
1713
1651
  * The resolved vite config object
1714
1652
  */
@@ -1727,7 +1665,8 @@ export declare interface PreviewServerForHook {
1727
1665
  */
1728
1666
  httpServer: http.Server;
1729
1667
  /**
1730
- * The resolved urls Vite prints on the CLI
1668
+ * The resolved urls Vite prints on the CLI.
1669
+ * null before server is listening.
1731
1670
  */
1732
1671
  resolvedUrls: ResolvedServerUrls | null;
1733
1672
  /**
@@ -1736,7 +1675,7 @@ export declare interface PreviewServerForHook {
1736
1675
  printUrls(): void;
1737
1676
  }
1738
1677
 
1739
- export declare type PreviewServerHook = (this: void, server: PreviewServerForHook) => (() => void) | void | Promise<(() => void) | void>;
1678
+ export declare type PreviewServerHook = (this: void, server: PreviewServer) => (() => void) | void | Promise<(() => void) | void>;
1740
1679
 
1741
1680
  export declare interface ProxyOptions extends HttpProxy.ServerOptions {
1742
1681
  /**
@@ -1755,14 +1694,6 @@ export declare interface ProxyOptions extends HttpProxy.ServerOptions {
1755
1694
 
1756
1695
  export { PrunePayload }
1757
1696
 
1758
- declare interface PseudoClasses {
1759
- hover?: string,
1760
- active?: string,
1761
- focus?: string,
1762
- focusVisible?: string,
1763
- focusWithin?: string
1764
- }
1765
-
1766
1697
  export declare type RenderBuiltAssetUrl = (filename: string, type: {
1767
1698
  type: 'asset' | 'public';
1768
1699
  hostId: string;
@@ -2170,7 +2101,9 @@ export declare interface SendOptions {
2170
2101
  etag?: string;
2171
2102
  cacheControl?: string;
2172
2103
  headers?: OutgoingHttpHeaders;
2173
- map?: SourceMap | null;
2104
+ map?: SourceMap | {
2105
+ mappings: '';
2106
+ } | null;
2174
2107
  }
2175
2108
 
2176
2109
  export declare type ServerHook = (this: void, server: ViteDevServer) => (() => void) | void | Promise<(() => void) | void>;
@@ -2273,18 +2206,6 @@ export declare interface SSROptions {
2273
2206
 
2274
2207
  export declare type SSRTarget = 'node' | 'webworker';
2275
2208
 
2276
- declare interface Targets {
2277
- android?: number,
2278
- chrome?: number,
2279
- edge?: number,
2280
- firefox?: number,
2281
- ie?: number,
2282
- ios_saf?: number,
2283
- opera?: number,
2284
- safari?: number,
2285
- samsung?: number
2286
- }
2287
-
2288
2209
  export declare namespace Terser {
2289
2210
  export type ECMA = 5 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020
2290
2211
 
@@ -2507,7 +2428,9 @@ export declare interface TransformOptions {
2507
2428
 
2508
2429
  export declare interface TransformResult {
2509
2430
  code: string;
2510
- map: SourceMap | null;
2431
+ map: SourceMap | {
2432
+ mappings: '';
2433
+ } | null;
2511
2434
  etag?: string;
2512
2435
  deps?: string[];
2513
2436
  dynamicDeps?: string[];
@@ -2737,7 +2660,9 @@ export declare interface ViteDevServer {
2737
2660
  /**
2738
2661
  * Transform module code into SSR format.
2739
2662
  */
2740
- ssrTransform(code: string, inMap: SourceMap | null, url: string, originalCode?: string): Promise<TransformResult | null>;
2663
+ ssrTransform(code: string, inMap: SourceMap | {
2664
+ mappings: '';
2665
+ } | null, url: string, originalCode?: string): Promise<TransformResult | null>;
2741
2666
  /**
2742
2667
  * Load a given URL as an instantiated module for SSR.
2743
2668
  */
@@ -1,5 +1,5 @@
1
- import { i as isInNodeModules } from './chunks/dep-75f53616.js';
2
- export { b as build, e as buildErrorMessage, v as createFilter, x as createLogger, c as createServer, g as defineConfig, f as formatPostcssSourceMap, k as getDepOptimizationConfig, m as isDepsOptimizerEnabled, z as isFileServingAllowed, l as loadConfigFromFile, A as loadEnv, u as mergeAlias, q as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, j as resolveBaseUrl, h as resolveConfig, B as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, y as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-75f53616.js';
1
+ import { i as isInNodeModules } from './chunks/dep-4033fb3a.js';
2
+ export { b as build, e as buildErrorMessage, v as createFilter, x as createLogger, c as createServer, g as defineConfig, f as formatPostcssSourceMap, k as getDepOptimizationConfig, m as isDepsOptimizerEnabled, z as isFileServingAllowed, l as loadConfigFromFile, A as loadEnv, u as mergeAlias, q as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, j as resolveBaseUrl, h as resolveConfig, B as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, y as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-4033fb3a.js';
3
3
  export { VERSION as version } from './constants.js';
4
4
  export { version as esbuildVersion } from 'esbuild';
5
5
  export { VERSION as rollupVersion } from 'rollup';
@@ -57,6 +57,7 @@ const isCSSRequest = (request) => CSS_LANGS_RE.test(request);
57
57
  // The cache needs to be reset on buildStart for watch mode to work correctly
58
58
  // Don't use this manualChunks strategy for ssr, lib mode, and 'umd' or 'iife'
59
59
  class SplitVendorChunkCache {
60
+ cache;
60
61
  constructor() {
61
62
  this.cache = new Map();
62
63
  }