vite 3.0.0-alpha.10 → 3.0.0-alpha.13

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.
@@ -1,4 +1,4 @@
1
- import { x as getAugmentedNamespace, y as getDefaultExportFromCjs } from './dep-134b43f1.js';
1
+ import { y as getAugmentedNamespace, z as getDefaultExportFromCjs } from './dep-5d9a8c71.js';
2
2
 
3
3
  import { fileURLToPath as __cjs_fileURLToPath } from 'url';
4
4
  import { dirname as __cjs_dirname } from 'path';
package/dist/node/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { performance } from 'perf_hooks';
2
2
  import { EventEmitter } from 'events';
3
- import { v as colors, j as createLogger, e as resolveConfig } from './chunks/dep-134b43f1.js';
3
+ import { w as colors, k as createLogger, e as resolveConfig } from './chunks/dep-5d9a8c71.js';
4
4
  import { VERSION } from './constants.js';
5
5
  import 'fs';
6
6
  import 'path';
@@ -682,7 +682,7 @@ cli
682
682
  .action(async (root, options) => {
683
683
  // output structure is preserved even after bundling so require()
684
684
  // is ok here
685
- const { createServer } = await import('./chunks/dep-134b43f1.js').then(function (n) { return n.B; });
685
+ const { createServer } = await import('./chunks/dep-5d9a8c71.js').then(function (n) { return n.C; });
686
686
  try {
687
687
  const server = await createServer({
688
688
  root,
@@ -691,6 +691,7 @@ cli
691
691
  configFile: options.config,
692
692
  logLevel: options.logLevel,
693
693
  clearScreen: options.clearScreen,
694
+ optimizeDeps: { force: options.force },
694
695
  server: cleanOptions(options)
695
696
  });
696
697
  if (!server.httpServer) {
@@ -728,7 +729,7 @@ cli
728
729
  .option('--emptyOutDir', `[boolean] force empty outDir when it's outside of root`)
729
730
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
730
731
  .action(async (root, options) => {
731
- const { build } = await import('./chunks/dep-134b43f1.js').then(function (n) { return n.A; });
732
+ const { build } = await import('./chunks/dep-5d9a8c71.js').then(function (n) { return n.B; });
732
733
  const buildOptions = cleanOptions(options);
733
734
  try {
734
735
  await build({
@@ -738,7 +739,7 @@ cli
738
739
  configFile: options.config,
739
740
  logLevel: options.logLevel,
740
741
  clearScreen: options.clearScreen,
741
- force: options.force,
742
+ optimizeDeps: { force: options.force },
742
743
  build: buildOptions
743
744
  });
744
745
  }
@@ -752,7 +753,7 @@ cli
752
753
  .command('optimize [root]', 'pre-bundle dependencies')
753
754
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
754
755
  .action(async (root, options) => {
755
- const { optimizeDeps } = await import('./chunks/dep-134b43f1.js').then(function (n) { return n.z; });
756
+ const { optimizeDeps } = await import('./chunks/dep-5d9a8c71.js').then(function (n) { return n.A; });
756
757
  try {
757
758
  const config = await resolveConfig({
758
759
  root,
@@ -775,7 +776,7 @@ cli
775
776
  .option('--https', `[boolean] use TLS + HTTP/2`)
776
777
  .option('--open [path]', `[boolean | string] open browser on startup`)
777
778
  .action(async (root, options) => {
778
- const { preview } = await import('./chunks/dep-134b43f1.js').then(function (n) { return n.C; });
779
+ const { preview } = await import('./chunks/dep-5d9a8c71.js').then(function (n) { return n.D; });
779
780
  try {
780
781
  const server = await preview({
781
782
  root,
@@ -1,7 +1,7 @@
1
1
  import path, { resolve } from 'path';
2
2
  import { fileURLToPath } from 'url';
3
3
 
4
- var version = "3.0.0-alpha.10";
4
+ var version = "3.0.0-alpha.13";
5
5
 
6
6
  const VERSION = version;
7
7
  const DEFAULT_MAIN_FIELDS = [
@@ -48,11 +48,17 @@ const ENV_ENTRY = resolve(VITE_PACKAGE_DIR, 'dist/client/env.mjs');
48
48
  const CLIENT_DIR = path.dirname(CLIENT_ENTRY);
49
49
  // ** READ THIS ** before editing `KNOWN_ASSET_TYPES`.
50
50
  // 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`.
51
+ // to the TypeScript declaration file `packages/vite/client.d.ts` and
52
+ // add a mime type to the `registerCustomMime` in
53
+ // `packages/vite/src/node/plugin/assets.ts` if mime type cannot be
54
+ // looked up by mrmime.
52
55
  const KNOWN_ASSET_TYPES = [
53
56
  // images
54
57
  'png',
55
58
  'jpe?g',
59
+ 'jfif',
60
+ 'pjpeg',
61
+ 'pjp',
56
62
  'gif',
57
63
  'svg',
58
64
  'ico',
@@ -78,5 +84,16 @@ const KNOWN_ASSET_TYPES = [
78
84
  ];
79
85
  const DEFAULT_ASSETS_RE = new RegExp(`\\.(` + KNOWN_ASSET_TYPES.join('|') + `)(\\?.*)?$`);
80
86
  const DEP_VERSION_RE = /[\?&](v=[\w\.-]+)\b/;
87
+ const loopbackHosts = new Set([
88
+ 'localhost',
89
+ '127.0.0.1',
90
+ '::1',
91
+ '0000:0000:0000:0000:0000:0000:0000:0001'
92
+ ]);
93
+ const wildcardHosts = new Set([
94
+ '0.0.0.0',
95
+ '::',
96
+ '0000:0000:0000:0000:0000:0000:0000:0000'
97
+ ]);
81
98
 
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 };
99
+ 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, loopbackHosts, wildcardHosts };
@@ -75,6 +75,15 @@ export declare type AnymatchFn = (testString: string) => boolean
75
75
 
76
76
  export declare type AnymatchPattern = string | RegExp | AnymatchFn
77
77
 
78
+ /**
79
+ * spa: include SPA fallback middleware and configure sirv with `single: true` in preview
80
+ *
81
+ * mpa: only include non-SPA HTML middlewares
82
+ *
83
+ * custom: don't include HTML middlewares
84
+ */
85
+ export declare type AppType = 'spa' | 'mpa' | 'custom';
86
+
78
87
  export declare interface AwaitWriteFinishOptions {
79
88
  /**
80
89
  * Amount of time in milliseconds for a file size to remain constant before emitting its event.
@@ -437,6 +446,10 @@ export declare interface CorsOptions {
437
446
 
438
447
  export declare type CorsOrigin = boolean | string | RegExp | (string | RegExp)[];
439
448
 
449
+ export declare const createFilter: (include?: FilterPattern | undefined, exclude?: FilterPattern | undefined, options?: {
450
+ resolve?: string | false | null | undefined;
451
+ } | undefined) => (id: string | unknown) => boolean;
452
+
440
453
  export declare function createLogger(level?: LogLevel, options?: LoggerOptions): Logger;
441
454
 
442
455
  export declare function createServer(inlineConfig?: InlineConfig): Promise<ViteDevServer>;
@@ -533,13 +546,6 @@ export declare interface DepOptimizationOptions {
533
546
  * vite project root. This will overwrite default entries inference.
534
547
  */
535
548
  entries?: string | string[];
536
- /**
537
- * Enable esbuild based scan phase, to get back to the optimized deps discovery
538
- * strategy used in Vite v2
539
- * @default false
540
- * @experimental
541
- */
542
- devScan?: boolean;
543
549
  /**
544
550
  * Force optimize listed dependencies (must be resolvable import paths,
545
551
  * cannot be globs).
@@ -586,6 +592,11 @@ export declare interface DepOptimizationOptions {
586
592
  * @experimental
587
593
  */
588
594
  disabled?: boolean | 'build' | 'dev';
595
+ /**
596
+ * Force dep pre-optimization regardless of whether deps have changed.
597
+ * @experimental
598
+ */
599
+ force?: boolean;
589
600
  }
590
601
 
591
602
  export declare interface DepOptimizationProcessing {
@@ -605,9 +616,11 @@ export declare interface DepOptimizationResult {
605
616
  }
606
617
 
607
618
  export declare interface DepsOptimizer {
608
- metadata: DepOptimizationMetadata;
619
+ metadata: (options: {
620
+ ssr: boolean;
621
+ }) => DepOptimizationMetadata;
609
622
  scanProcessing?: Promise<void>;
610
- registerMissingImport: (id: string, resolved: string) => OptimizedDepInfo;
623
+ registerMissingImport: (id: string, resolved: string, ssr?: boolean) => OptimizedDepInfo;
611
624
  run: () => void;
612
625
  isOptimizedDepFile: (id: string) => boolean;
613
626
  isOptimizedDepUrl: (url: string) => boolean;
@@ -693,6 +706,11 @@ export declare interface FileSystemServeOptions {
693
706
  deny?: string[];
694
707
  }
695
708
 
709
+ /**
710
+ * Inlined to keep `@rollup/pluginutils` in devDependencies
711
+ */
712
+ export declare type FilterPattern = ReadonlyArray<string | RegExp> | string | RegExp | null;
713
+
696
714
  export declare function formatPostcssSourceMap(rawMap: ExistingRawSourceMap, file: string): Promise<ExistingRawSourceMap>;
697
715
 
698
716
  export declare class FSWatcher extends EventEmitter implements fs.FSWatcher {
@@ -1193,6 +1211,33 @@ export declare interface KnownAsTypeMap {
1193
1211
  worker: Worker
1194
1212
  }
1195
1213
 
1214
+ export declare interface LegacyOptions {
1215
+ /**
1216
+ * Revert vite dev to the v2.9 strategy. Enable esbuild based deps scanner.
1217
+ *
1218
+ * @experimental
1219
+ * @deprecated
1220
+ * @default false
1221
+ */
1222
+ devDepsScanner?: boolean;
1223
+ /**
1224
+ * Revert vite build to the v2.9 strategy. Disable esbuild deps optimization and adds `@rollup/plugin-commonjs`
1225
+ *
1226
+ * @experimental
1227
+ * @deprecated
1228
+ * @default false
1229
+ */
1230
+ buildRollupPluginCommonjs?: boolean;
1231
+ /**
1232
+ * Revert vite build --ssr to the v2.9 strategy. Use CJS SSR build and v2.9 externalization heuristics
1233
+ *
1234
+ * @experimental
1235
+ * @deprecated
1236
+ * @default false
1237
+ */
1238
+ buildSsrCjsExternalHeuristics?: boolean;
1239
+ }
1240
+
1196
1241
  export declare type LibraryFormats = 'es' | 'cjs' | 'umd' | 'iife';
1197
1242
 
1198
1243
  export declare interface LibraryOptions {
@@ -1512,7 +1557,7 @@ export declare interface PluginContainer {
1512
1557
  close(): Promise<void>;
1513
1558
  }
1514
1559
 
1515
- export declare type PluginOption = Plugin_2 | false | null | undefined | PluginOption[];
1560
+ export declare type PluginOption = Plugin_2 | false | null | undefined | PluginOption[] | Promise<Plugin_2 | false | null | undefined | PluginOption[]>;
1516
1561
 
1517
1562
  /**
1518
1563
  * Starts the Vite server in preview mode, to simulate a production deployment
@@ -1594,7 +1639,7 @@ export declare type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'asse
1594
1639
  optimizeDeps: DepOptimizationOptions;
1595
1640
  /* Excluded from this release type: packageCache */
1596
1641
  worker: ResolveWorkerOptions;
1597
- spa: boolean;
1642
+ appType: AppType;
1598
1643
  }>;
1599
1644
 
1600
1645
  export declare interface ResolvedPreviewOptions extends PreviewOptions {
@@ -1602,6 +1647,7 @@ export declare interface ResolvedPreviewOptions extends PreviewOptions {
1602
1647
 
1603
1648
  export declare interface ResolvedServerOptions extends ServerOptions {
1604
1649
  fs: Required<FileSystemServeOptions>;
1650
+ middlewareMode: boolean;
1605
1651
  }
1606
1652
 
1607
1653
  export declare interface ResolvedSSROptions extends SSROptions {
@@ -2213,11 +2259,6 @@ export declare interface UserConfig {
2213
2259
  * Preview specific options, e.g. host, port, https...
2214
2260
  */
2215
2261
  preview?: PreviewOptions;
2216
- /**
2217
- * Force dep pre-optimization regardless of whether deps have changed.
2218
- * @experimental
2219
- */
2220
- force?: boolean;
2221
2262
  /**
2222
2263
  * Dep optimization options
2223
2264
  */
@@ -2229,11 +2270,18 @@ export declare interface UserConfig {
2229
2270
  /**
2230
2271
  * Experimental features
2231
2272
  *
2232
- * Features under this field are addressed to be changed that might NOT follow semver.
2273
+ * Features under this field could change in the future and might NOT follow semver.
2233
2274
  * Please be careful and always pin Vite's version when using them.
2234
2275
  * @experimental
2235
2276
  */
2236
2277
  experimental?: ExperimentalOptions;
2278
+ /**
2279
+ * Legacy options
2280
+ *
2281
+ * Features under this field only follow semver for patches, they could be removed in a
2282
+ * future minor version. Please always pin Vite's version to a minor when using them.
2283
+ */
2284
+ legacy?: LegacyOptions;
2237
2285
  /**
2238
2286
  * Log level.
2239
2287
  * Default: 'info'
@@ -2277,11 +2325,12 @@ export declare interface UserConfig {
2277
2325
  rollupOptions?: Omit<RollupOptions, 'plugins' | 'input' | 'onwarn' | 'preserveEntrySignatures'>;
2278
2326
  };
2279
2327
  /**
2280
- * Whether your application is a Single Page Application (SPA). Set to `false`
2281
- * for other kinds of apps like MPAs.
2282
- * @default true
2328
+ * Whether your application is a Single Page Application (SPA),
2329
+ * a Multi-Page Application (MPA), or Custom Application (SSR
2330
+ * and frameworks with custom HTML handling)
2331
+ * @default 'spa'
2283
2332
  */
2284
- spa?: boolean;
2333
+ appType?: AppType;
2285
2334
  }
2286
2335
 
2287
2336
  export declare type UserConfigExport = UserConfig | Promise<UserConfig> | UserConfigFn;
@@ -1,4 +1,4 @@
1
- export { b as build, j as createLogger, c as createServer, d as defineConfig, f as formatPostcssSourceMap, i as isDepsOptimizerEnabled, l as loadConfigFromFile, q as loadEnv, g as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, p as preview, e as resolveConfig, u as resolveEnvPrefix, a as resolvePackageData, r as resolvePackageEntry, k as searchForWorkspaceRoot, h as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-134b43f1.js';
1
+ export { b as build, h as createFilter, k as createLogger, c as createServer, d as defineConfig, f as formatPostcssSourceMap, i as isDepsOptimizerEnabled, l as loadConfigFromFile, u as loadEnv, g as mergeAlias, m as mergeConfig, n as normalizePath, o as optimizeDeps, p as preview, e as resolveConfig, v as resolveEnvPrefix, a as resolvePackageData, r as resolvePackageEntry, q as searchForWorkspaceRoot, j as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-5d9a8c71.js';
2
2
  export { VERSION as version } from './constants.js';
3
3
  import 'fs';
4
4
  import 'path';