vite 2.7.12 → 2.8.0-beta.3

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.

Files changed (83) hide show
  1. package/CHANGELOG.md +2738 -0
  2. package/LICENSE.md +16 -778
  3. package/bin/vite.js +3 -1
  4. package/client.d.ts +4 -0
  5. package/dist/node/chunks/{dep-2d8e2cb1.js → dep-0ebab0df.js} +1 -2
  6. package/dist/node/chunks/{dep-ac1b4bf9.js → dep-2056ae8a.js} +20 -4
  7. package/dist/node/chunks/{dep-d7204208.js → dep-6f0b746c.js} +1 -2
  8. package/dist/node/chunks/{dep-73d734ac.js → dep-84e12b4e.js} +470 -4367
  9. package/dist/node/chunks/{dep-374a3cfd.js → dep-885d4c21.js} +12139 -21842
  10. package/dist/node/chunks/{dep-0351185a.js → dep-a5ab6d86.js} +49117 -52190
  11. package/dist/node/cli.js +13 -13
  12. package/dist/node/index.d.ts +46 -8
  13. package/dist/node/index.js +2 -3
  14. package/package.json +14 -12
  15. package/types/importMeta.d.ts +17 -2
  16. package/dist/node/build.d.ts +0 -200
  17. package/dist/node/chunks/dep-0351185a.js.map +0 -1
  18. package/dist/node/chunks/dep-2d8e2cb1.js.map +0 -1
  19. package/dist/node/chunks/dep-374a3cfd.js.map +0 -1
  20. package/dist/node/chunks/dep-73d734ac.js.map +0 -1
  21. package/dist/node/chunks/dep-ac1b4bf9.js.map +0 -1
  22. package/dist/node/chunks/dep-d7204208.js.map +0 -1
  23. package/dist/node/cli.d.ts +0 -1
  24. package/dist/node/cli.js.map +0 -1
  25. package/dist/node/config.d.ts +0 -202
  26. package/dist/node/constants.d.ts +0 -33
  27. package/dist/node/http.d.ts +0 -84
  28. package/dist/node/importGlob.d.ts +0 -9
  29. package/dist/node/index.js.map +0 -1
  30. package/dist/node/logger.d.ts +0 -35
  31. package/dist/node/optimizer/esbuildDepPlugin.d.ts +0 -4
  32. package/dist/node/optimizer/index.d.ts +0 -66
  33. package/dist/node/optimizer/registerMissing.d.ts +0 -2
  34. package/dist/node/optimizer/scan.d.ts +0 -9
  35. package/dist/node/packages.d.ts +0 -25
  36. package/dist/node/plugin.d.ts +0 -115
  37. package/dist/node/plugins/asset.d.ts +0 -40
  38. package/dist/node/plugins/assetImportMetaUrl.d.ts +0 -13
  39. package/dist/node/plugins/clientInjections.d.ts +0 -7
  40. package/dist/node/plugins/css.d.ts +0 -70
  41. package/dist/node/plugins/dataUri.d.ts +0 -5
  42. package/dist/node/plugins/define.d.ts +0 -3
  43. package/dist/node/plugins/esbuild.d.ts +0 -15
  44. package/dist/node/plugins/html.d.ts +0 -102
  45. package/dist/node/plugins/importAnalysis.d.ts +0 -46
  46. package/dist/node/plugins/importAnalysisBuild.d.ts +0 -15
  47. package/dist/node/plugins/index.d.ts +0 -3
  48. package/dist/node/plugins/json.d.ts +0 -22
  49. package/dist/node/plugins/loadFallback.d.ts +0 -5
  50. package/dist/node/plugins/manifest.d.ts +0 -14
  51. package/dist/node/plugins/modulePreloadPolyfill.d.ts +0 -4
  52. package/dist/node/plugins/preAlias.d.ts +0 -5
  53. package/dist/node/plugins/reporter.d.ts +0 -3
  54. package/dist/node/plugins/resolve.d.ts +0 -38
  55. package/dist/node/plugins/ssrRequireHook.d.ts +0 -12
  56. package/dist/node/plugins/terser.d.ts +0 -3
  57. package/dist/node/plugins/wasm.d.ts +0 -3
  58. package/dist/node/plugins/worker.d.ts +0 -3
  59. package/dist/node/preview.d.ts +0 -31
  60. package/dist/node/server/hmr.d.ts +0 -37
  61. package/dist/node/server/index.d.ts +0 -222
  62. package/dist/node/server/middlewares/base.d.ts +0 -3
  63. package/dist/node/server/middlewares/error.d.ts +0 -8
  64. package/dist/node/server/middlewares/indexHtml.d.ts +0 -4
  65. package/dist/node/server/middlewares/proxy.d.ts +0 -20
  66. package/dist/node/server/middlewares/spaFallback.d.ts +0 -2
  67. package/dist/node/server/middlewares/static.d.ts +0 -6
  68. package/dist/node/server/middlewares/time.d.ts +0 -2
  69. package/dist/node/server/middlewares/transform.d.ts +0 -3
  70. package/dist/node/server/moduleGraph.d.ts +0 -53
  71. package/dist/node/server/openBrowser.d.ts +0 -15
  72. package/dist/node/server/pluginContainer.d.ts +0 -37
  73. package/dist/node/server/searchRoot.d.ts +0 -8
  74. package/dist/node/server/send.d.ts +0 -4
  75. package/dist/node/server/sourcemap.d.ts +0 -8
  76. package/dist/node/server/transformRequest.d.ts +0 -14
  77. package/dist/node/server/ws.d.ts +0 -14
  78. package/dist/node/ssr/ssrExternal.d.ts +0 -7
  79. package/dist/node/ssr/ssrManifestPlugin.d.ts +0 -3
  80. package/dist/node/ssr/ssrModuleLoader.d.ts +0 -7
  81. package/dist/node/ssr/ssrStacktrace.d.ts +0 -3
  82. package/dist/node/ssr/ssrTransform.d.ts +0 -8
  83. package/dist/node/utils.d.ts +0 -114
package/dist/node/cli.js CHANGED
@@ -1,17 +1,17 @@
1
1
  'use strict';
2
2
 
3
3
  var require$$0 = require('events');
4
- var build = require('./chunks/dep-0351185a.js');
4
+ var build = require('./chunks/dep-a5ab6d86.js');
5
5
  var perf_hooks = require('perf_hooks');
6
6
  require('fs');
7
7
  require('path');
8
- require('os');
9
8
  require('tty');
10
9
  require('util');
11
10
  require('net');
12
11
  require('url');
13
12
  require('http');
14
13
  require('stream');
14
+ require('os');
15
15
  require('resolve');
16
16
  require('module');
17
17
  require('https');
@@ -683,7 +683,7 @@ cli
683
683
  .action(async (root, options) => {
684
684
  // output structure is preserved even after bundling so require()
685
685
  // is ok here
686
- const { createServer } = await Promise.resolve().then(function () { return require('./chunks/dep-0351185a.js'); }).then(function (n) { return n.index$1; });
686
+ const { createServer } = await Promise.resolve().then(function () { return require('./chunks/dep-a5ab6d86.js'); }).then(function (n) { return n.index$1; });
687
687
  try {
688
688
  const server = await createServer({
689
689
  root,
@@ -699,8 +699,8 @@ cli
699
699
  }
700
700
  await server.listen();
701
701
  const info = server.config.logger.info;
702
- info(build.source.cyan(`\n vite v${require('vite/package.json').version}`) +
703
- build.source.green(` dev server running at:\n`), {
702
+ info(build.colors.cyan(`\n vite v${require('vite/package.json').version}`) +
703
+ build.colors.green(` dev server running at:\n`), {
704
704
  clear: !server.config.logger.hasWarned
705
705
  });
706
706
  server.printUrls();
@@ -708,11 +708,11 @@ cli
708
708
  if (global.__vite_start_time) {
709
709
  // @ts-ignore
710
710
  const startupDuration = perf_hooks.performance.now() - global.__vite_start_time;
711
- info(`\n ${build.source.cyan(`ready in ${Math.ceil(startupDuration)}ms.`)}\n`);
711
+ info(`\n ${build.colors.cyan(`ready in ${Math.ceil(startupDuration)}ms.`)}\n`);
712
712
  }
713
713
  }
714
714
  catch (e) {
715
- build.createLogger(options.logLevel).error(build.source.red(`error when starting dev server:\n${e.stack}`), { error: e });
715
+ build.createLogger(options.logLevel).error(build.colors.red(`error when starting dev server:\n${e.stack}`), { error: e });
716
716
  process.exit(1);
717
717
  }
718
718
  });
@@ -732,7 +732,7 @@ cli
732
732
  .option('--emptyOutDir', `[boolean] force empty outDir when it's outside of root`)
733
733
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
734
734
  .action(async (root, options) => {
735
- const { build: build$1 } = await Promise.resolve().then(function () { return require('./chunks/dep-0351185a.js'); }).then(function (n) { return n.build$1; });
735
+ const { build: build$1 } = await Promise.resolve().then(function () { return require('./chunks/dep-a5ab6d86.js'); }).then(function (n) { return n.build$1; });
736
736
  const buildOptions = cleanOptions(options);
737
737
  try {
738
738
  await build$1({
@@ -746,7 +746,7 @@ cli
746
746
  });
747
747
  }
748
748
  catch (e) {
749
- build.createLogger(options.logLevel).error(build.source.red(`error during build:\n${e.stack}`), { error: e });
749
+ build.createLogger(options.logLevel).error(build.colors.red(`error during build:\n${e.stack}`), { error: e });
750
750
  process.exit(1);
751
751
  }
752
752
  });
@@ -755,7 +755,7 @@ cli
755
755
  .command('optimize [root]')
756
756
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
757
757
  .action(async (root, options) => {
758
- const { optimizeDeps } = await Promise.resolve().then(function () { return require('./chunks/dep-0351185a.js'); }).then(function (n) { return n.index; });
758
+ const { optimizeDeps } = await Promise.resolve().then(function () { return require('./chunks/dep-a5ab6d86.js'); }).then(function (n) { return n.index; });
759
759
  try {
760
760
  const config = await build.resolveConfig({
761
761
  root,
@@ -766,7 +766,7 @@ cli
766
766
  await optimizeDeps(config, options.force, true);
767
767
  }
768
768
  catch (e) {
769
- build.createLogger(options.logLevel).error(build.source.red(`error when optimizing deps:\n${e.stack}`), { error: e });
769
+ build.createLogger(options.logLevel).error(build.colors.red(`error when optimizing deps:\n${e.stack}`), { error: e });
770
770
  process.exit(1);
771
771
  }
772
772
  });
@@ -784,6 +784,7 @@ cli
784
784
  base: options.base,
785
785
  configFile: options.config,
786
786
  logLevel: options.logLevel,
787
+ mode: options.mode,
787
788
  preview: {
788
789
  port: options.port,
789
790
  strictPort: options.strictPort,
@@ -795,11 +796,10 @@ cli
795
796
  server.printUrls();
796
797
  }
797
798
  catch (e) {
798
- build.createLogger(options.logLevel).error(build.source.red(`error when starting preview server:\n${e.stack}`), { error: e });
799
+ build.createLogger(options.logLevel).error(build.colors.red(`error when starting preview server:\n${e.stack}`), { error: e });
799
800
  process.exit(1);
800
801
  }
801
802
  });
802
803
  cli.help();
803
804
  cli.version(require('../../package.json').version);
804
805
  cli.parse();
805
- //# sourceMappingURL=cli.js.map
@@ -310,6 +310,10 @@ export declare interface CommonServerOptions {
310
310
  * using an object.
311
311
  */
312
312
  cors?: CorsOptions | boolean;
313
+ /**
314
+ * Specify server response headers.
315
+ */
316
+ headers?: OutgoingHttpHeaders;
313
317
  }
314
318
 
315
319
  export declare interface ConfigEnv {
@@ -1070,8 +1074,8 @@ export declare class ModuleGraph {
1070
1074
  idToModuleMap: Map<string, ModuleNode>;
1071
1075
  fileToModulesMap: Map<string, Set<ModuleNode>>;
1072
1076
  safeModulesPath: Set<string>;
1073
- constructor(resolveId: (url: string) => Promise<PartialResolvedId | null>);
1074
- getModuleByUrl(rawUrl: string): Promise<ModuleNode | undefined>;
1077
+ constructor(resolveId: (url: string, ssr: boolean) => Promise<PartialResolvedId | null>);
1078
+ getModuleByUrl(rawUrl: string, ssr?: boolean): Promise<ModuleNode | undefined>;
1075
1079
  getModuleById(id: string): ModuleNode | undefined;
1076
1080
  getModulesByFile(file: string): Set<ModuleNode> | undefined;
1077
1081
  onFileChange(file: string): void;
@@ -1082,10 +1086,10 @@ export declare class ModuleGraph {
1082
1086
  * If there are dependencies that no longer have any importers, they are
1083
1087
  * returned as a Set.
1084
1088
  */
1085
- updateModuleInfo(mod: ModuleNode, importedModules: Set<string | ModuleNode>, acceptedModules: Set<string | ModuleNode>, isSelfAccepting: boolean): Promise<Set<ModuleNode> | undefined>;
1086
- ensureEntryFromUrl(rawUrl: string): Promise<ModuleNode>;
1089
+ updateModuleInfo(mod: ModuleNode, importedModules: Set<string | ModuleNode>, acceptedModules: Set<string | ModuleNode>, isSelfAccepting: boolean, ssr?: boolean): Promise<Set<ModuleNode> | undefined>;
1090
+ ensureEntryFromUrl(rawUrl: string, ssr?: boolean): Promise<ModuleNode>;
1087
1091
  createFileOnlyEntry(file: string): ModuleNode;
1088
- resolveUrl(url: string): Promise<ResolvedUrl>;
1092
+ resolveUrl(url: string, ssr?: boolean): Promise<ResolvedUrl>;
1089
1093
  }
1090
1094
 
1091
1095
  export declare class ModuleNode {
@@ -1322,13 +1326,14 @@ export declare function resolveConfig(inlineConfig: InlineConfig, command: 'buil
1322
1326
 
1323
1327
  export declare type ResolvedBuildOptions = Required<Omit<BuildOptions, 'base' | 'cleanCssOptions' | 'polyfillDynamicImport' | 'brotliSize'>>;
1324
1328
 
1325
- export declare type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'alias' | 'dedupe' | 'assetsInclude' | 'optimizeDeps'> & {
1329
+ export declare type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'alias' | 'dedupe' | 'assetsInclude' | 'optimizeDeps' | 'worker'> & {
1326
1330
  configFile: string | undefined;
1327
1331
  configFileDependencies: string[];
1328
1332
  inlineConfig: InlineConfig;
1329
1333
  root: string;
1330
1334
  base: string;
1331
1335
  publicDir: string;
1336
+ cacheDir: string;
1332
1337
  command: 'build' | 'serve';
1333
1338
  mode: string;
1334
1339
  isProduction: boolean;
@@ -1345,6 +1350,7 @@ export declare type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'alia
1345
1350
  createResolver: (options?: Partial<InternalResolveOptions>) => ResolveFn;
1346
1351
  optimizeDeps: Omit<DepOptimizationOptions, 'keepNames'>;
1347
1352
  /* Excluded from this release type: packageCache */
1353
+ worker: ResolveWorkerOptions;
1348
1354
  }>;
1349
1355
 
1350
1356
  export declare interface ResolvedPreviewOptions extends PreviewOptions {
@@ -1383,6 +1389,12 @@ export declare interface ResolverObject {
1383
1389
  resolveId: ResolverFunction
1384
1390
  }
1385
1391
 
1392
+ export declare interface ResolveWorkerOptions {
1393
+ format: 'es' | 'iife';
1394
+ plugins: Plugin[];
1395
+ rollupOptions: RollupOptions;
1396
+ }
1397
+
1386
1398
  /**
1387
1399
  * https://github.com/rollup/plugins/blob/master/packages/commonjs/types/index.d.ts
1388
1400
  *
@@ -1589,7 +1601,14 @@ export declare interface RollupDynamicImportVarsOptions {
1589
1601
  */
1590
1602
  export declare function searchForWorkspaceRoot(current: string, root?: string): string;
1591
1603
 
1592
- export declare function send(req: IncomingMessage, res: ServerResponse, content: string | Buffer, type: string, etag?: string, cacheControl?: string, map?: SourceMap | null): void;
1604
+ export declare function send(req: IncomingMessage, res: ServerResponse, content: string | Buffer, type: string, options: SendOptions): void;
1605
+
1606
+ export declare interface SendOptions {
1607
+ etag?: string;
1608
+ cacheControl?: string;
1609
+ headers?: OutgoingHttpHeaders;
1610
+ map?: SourceMap | null;
1611
+ }
1593
1612
 
1594
1613
  export declare type ServerHook = (server: ViteDevServer) => (() => void) | void | Promise<(() => void) | void>;
1595
1614
 
@@ -1627,7 +1646,7 @@ export declare interface ServerOptions extends CommonServerOptions {
1627
1646
  /**
1628
1647
  * Pre-transform known direct imports
1629
1648
  *
1630
- * @expiremental this options is expiremental and might be changed in the future
1649
+ * @experimental this option is experimental and might be changed in the future
1631
1650
  * @default true
1632
1651
  */
1633
1652
  preTransformRequests?: boolean;
@@ -1876,6 +1895,7 @@ export declare interface UserConfig {
1876
1895
  * the performance. You can use `--force` flag or manually delete the directory
1877
1896
  * to regenerate the cache files. The value can be either an absolute file
1878
1897
  * system path or a path relative to <root>.
1898
+ * Default to `.vite` when no package.json is detected.
1879
1899
  * @default 'node_modules/.vite'
1880
1900
  */
1881
1901
  cacheDir?: string;
@@ -1968,6 +1988,24 @@ export declare interface UserConfig {
1968
1988
  * @deprecated use `resolve.dedupe` instead
1969
1989
  */
1970
1990
  dedupe?: string[];
1991
+ /**
1992
+ * Worker bundle options
1993
+ */
1994
+ worker?: {
1995
+ /**
1996
+ * Output format for worker bundle
1997
+ * @default 'iife'
1998
+ */
1999
+ format?: 'es' | 'iife';
2000
+ /**
2001
+ * Vite plugins that apply to worker bundle
2002
+ */
2003
+ plugins?: (PluginOption | PluginOption[])[];
2004
+ /**
2005
+ * Rollup options to build worker bundle
2006
+ */
2007
+ rollupOptions?: Omit<RollupOptions, 'plugins' | 'input' | 'onwarn' | 'preserveEntrySignatures'>;
2008
+ };
1971
2009
  }
1972
2010
 
1973
2011
  export declare type UserConfigExport = UserConfig | Promise<UserConfig> | UserConfigFn;
@@ -2,10 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var build = require('./chunks/dep-0351185a.js');
5
+ var build = require('./chunks/dep-a5ab6d86.js');
6
6
  require('fs');
7
7
  require('path');
8
- require('os');
9
8
  require('tty');
10
9
  require('util');
11
10
  require('net');
@@ -13,6 +12,7 @@ require('events');
13
12
  require('url');
14
13
  require('http');
15
14
  require('stream');
15
+ require('os');
16
16
  require('resolve');
17
17
  require('module');
18
18
  require('perf_hooks');
@@ -49,4 +49,3 @@ exports.searchForWorkspaceRoot = build.searchForWorkspaceRoot;
49
49
  exports.send = build.send;
50
50
  exports.sortUserPlugins = build.sortUserPlugins;
51
51
  exports.transformWithEsbuild = build.transformWithEsbuild;
52
- //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "2.7.12",
3
+ "version": "2.8.0-beta.3",
4
4
  "license": "MIT",
5
5
  "author": "Evan You",
6
6
  "description": "Native-ESM powered web dev build tool",
@@ -44,7 +44,7 @@
44
44
  },
45
45
  "//": "READ CONTRIBUTING.md to understand what to put under deps vs. devDeps!",
46
46
  "dependencies": {
47
- "esbuild": "^0.13.12",
47
+ "esbuild": "0.14.3",
48
48
  "postcss": "^8.4.5",
49
49
  "resolve": "^1.20.0",
50
50
  "rollup": "^2.59.0"
@@ -58,19 +58,20 @@
58
58
  "@babel/types": "^7.16.0",
59
59
  "@rollup/plugin-alias": "^3.1.8",
60
60
  "@rollup/plugin-commonjs": "^21.0.1",
61
- "@rollup/plugin-dynamic-import-vars": "^1.4.1",
61
+ "@rollup/plugin-dynamic-import-vars": "^1.4.2",
62
62
  "@rollup/plugin-json": "^4.1.0",
63
63
  "@rollup/plugin-node-resolve": "13.1.1",
64
64
  "@rollup/plugin-typescript": "^8.3.0",
65
65
  "@rollup/pluginutils": "^4.1.2",
66
66
  "@types/convert-source-map": "^1.5.2",
67
+ "@types/cross-spawn": "^6.0.2",
67
68
  "@types/debug": "^4.1.7",
68
69
  "@types/estree": "^0.0.50",
69
70
  "@types/etag": "^1.8.1",
70
71
  "@types/less": "^3.0.3",
71
72
  "@types/micromatch": "^4.0.2",
72
73
  "@types/mime": "^2.0.3",
73
- "@types/node": "^16.11.14",
74
+ "@types/node": "^16.11.17",
74
75
  "@types/resolve": "^1.20.1",
75
76
  "@types/sass": "~1.43.1",
76
77
  "@types/stylus": "^0.48.36",
@@ -78,36 +79,37 @@
78
79
  "@vue/compiler-dom": "^3.2.26",
79
80
  "acorn": "^8.7.0",
80
81
  "cac": "6.7.9",
81
- "chalk": "^4.1.2",
82
82
  "chokidar": "^3.5.2",
83
83
  "compression": "^1.7.4",
84
84
  "connect": "^3.7.0",
85
85
  "connect-history-api-fallback": "^1.6.0",
86
86
  "convert-source-map": "^1.8.0",
87
87
  "cors": "^2.8.5",
88
+ "cross-spawn": "^7.0.3",
88
89
  "debug": "^4.3.3",
89
90
  "dotenv": "^10.0.0",
90
91
  "dotenv-expand": "^5.1.0",
91
92
  "es-module-lexer": "^0.9.3",
92
93
  "estree-walker": "^2.0.2",
93
94
  "etag": "^1.8.1",
94
- "execa": "^5.1.1",
95
95
  "fast-glob": "^3.2.7",
96
96
  "http-proxy": "^1.18.1",
97
+ "json5": "^2.2.0",
97
98
  "launch-editor-middleware": "^2.3.0",
98
99
  "magic-string": "^0.25.7",
99
100
  "micromatch": "^4.0.4",
100
- "mime": "^3.0.0",
101
+ "mrmime": "^1.0.0",
102
+ "node-forge": "^1.2.0",
101
103
  "okie": "^1.0.1",
102
104
  "open": "^8.4.0",
103
105
  "periscopic": "^2.0.3",
106
+ "picocolors": "^1.0.0",
104
107
  "postcss-import": "^14.0.2",
105
- "postcss-load-config": "^3.1.0",
106
- "postcss-modules": "^4.2.2",
108
+ "postcss-load-config": "^3.1.1",
109
+ "postcss-modules": "^4.3.0",
107
110
  "resolve.exports": "^1.1.0",
108
111
  "rollup-plugin-license": "^2.6.0",
109
- "selfsigned": "^1.10.11",
110
- "sirv": "^1.0.19",
112
+ "sirv": "^2.0.0",
111
113
  "source-map": "^0.6.1",
112
114
  "source-map-support": "^0.5.21",
113
115
  "strip-ansi": "^6.0.1",
@@ -115,7 +117,7 @@
115
117
  "tsconfck": "1.1.1",
116
118
  "tslib": "^2.3.1",
117
119
  "types": "link:./types",
118
- "ws": "^8.3.0"
120
+ "ws": "^8.4.0"
119
121
  },
120
122
  "peerDependencies": {
121
123
  "less": "*",
@@ -4,6 +4,15 @@
4
4
 
5
5
  /* eslint-disable @typescript-eslint/consistent-type-imports */
6
6
 
7
+ // Duplicate import('../src/node/importGlob').AssertOptions
8
+ // Avoid breaking the production client type because this file is referenced
9
+ // in vite/client.d.ts and in production src/node/importGlob.ts doesn't exist
10
+ interface AssertOptions {
11
+ assert?: {
12
+ type: string
13
+ }
14
+ }
15
+
7
16
  interface ImportMeta {
8
17
  url: string
9
18
 
@@ -50,14 +59,20 @@ interface ImportMeta {
50
59
 
51
60
  readonly env: ImportMetaEnv
52
61
 
53
- glob(pattern: string): Record<
62
+ glob(
63
+ pattern: string,
64
+ options?: AssertOptions
65
+ ): Record<
54
66
  string,
55
67
  () => Promise<{
56
68
  [key: string]: any
57
69
  }>
58
70
  >
59
71
 
60
- globEager(pattern: string): Record<
72
+ globEager(
73
+ pattern: string,
74
+ options?: AssertOptions
75
+ ): Record<
61
76
  string,
62
77
  {
63
78
  [key: string]: any
@@ -1,200 +0,0 @@
1
- import type { InlineConfig, ResolvedConfig } from './config';
2
- import type { Plugin, RollupOptions, RollupWarning, WarningHandler, RollupOutput, WatcherOptions, RollupWatcher, ModuleFormat } from 'rollup';
3
- import type { Terser } from 'types/terser';
4
- import type { RollupCommonJSOptions } from 'types/commonjs';
5
- import type { RollupDynamicImportVarsOptions } from 'types/dynamicImportVars';
6
- import type { TransformOptions } from 'esbuild';
7
- export interface BuildOptions {
8
- /**
9
- * Base public path when served in production.
10
- * @deprecated `base` is now a root-level config option.
11
- */
12
- base?: string;
13
- /**
14
- * Compatibility transform target. The transform is performed with esbuild
15
- * and the lowest supported target is es2015/es6. Note this only handles
16
- * syntax transformation and does not cover polyfills (except for dynamic
17
- * import)
18
- *
19
- * Default: 'modules' - Similar to `@babel/preset-env`'s targets.esmodules,
20
- * transpile targeting browsers that natively support dynamic es module imports.
21
- * https://caniuse.com/es6-module-dynamic-import
22
- *
23
- * Another special value is 'esnext' - which only performs minimal transpiling
24
- * (for minification compat) and assumes native dynamic imports support.
25
- *
26
- * For custom targets, see https://esbuild.github.io/api/#target and
27
- * https://esbuild.github.io/content-types/#javascript for more details.
28
- */
29
- target?: 'modules' | TransformOptions['target'] | false;
30
- /**
31
- * whether to inject module preload polyfill.
32
- * Note: does not apply to library mode.
33
- * @default true
34
- */
35
- polyfillModulePreload?: boolean;
36
- /**
37
- * whether to inject dynamic import polyfill.
38
- * Note: does not apply to library mode.
39
- * @default false
40
- * @deprecated use plugin-legacy for browsers that don't support dynamic import
41
- */
42
- polyfillDynamicImport?: boolean;
43
- /**
44
- * Directory relative from `root` where build output will be placed. If the
45
- * directory exists, it will be removed before the build.
46
- * @default 'dist'
47
- */
48
- outDir?: string;
49
- /**
50
- * Directory relative from `outDir` where the built js/css/image assets will
51
- * be placed.
52
- * @default 'assets'
53
- */
54
- assetsDir?: string;
55
- /**
56
- * Static asset files smaller than this number (in bytes) will be inlined as
57
- * base64 strings. Default limit is `4096` (4kb). Set to `0` to disable.
58
- * @default 4096
59
- */
60
- assetsInlineLimit?: number;
61
- /**
62
- * Whether to code-split CSS. When enabled, CSS in async chunks will be
63
- * inlined as strings in the chunk and inserted via dynamically created
64
- * style tags when the chunk is loaded.
65
- * @default true
66
- */
67
- cssCodeSplit?: boolean;
68
- /**
69
- * An optional separate target for CSS minification.
70
- * As esbuild only supports configuring targets to mainstream
71
- * browsers, users may need this option when they are targeting
72
- * a niche browser that comes with most modern JavaScript features
73
- * but has poor CSS support, e.g. Android WeChat WebView, which
74
- * doesn't support the #RGBA syntax.
75
- */
76
- cssTarget?: TransformOptions['target'] | false;
77
- /**
78
- * If `true`, a separate sourcemap file will be created. If 'inline', the
79
- * sourcemap will be appended to the resulting output file as data URI.
80
- * 'hidden' works like `true` except that the corresponding sourcemap
81
- * comments in the bundled files are suppressed.
82
- * @default false
83
- */
84
- sourcemap?: boolean | 'inline' | 'hidden';
85
- /**
86
- * Set to `false` to disable minification, or specify the minifier to use.
87
- * Available options are 'terser' or 'esbuild'.
88
- * @default 'esbuild'
89
- */
90
- minify?: boolean | 'terser' | 'esbuild';
91
- /**
92
- * Options for terser
93
- * https://terser.org/docs/api-reference#minify-options
94
- */
95
- terserOptions?: Terser.MinifyOptions;
96
- /**
97
- * @deprecated Vite now uses esbuild for CSS minification.
98
- */
99
- cleanCssOptions?: any;
100
- /**
101
- * Will be merged with internal rollup options.
102
- * https://rollupjs.org/guide/en/#big-list-of-options
103
- */
104
- rollupOptions?: RollupOptions;
105
- /**
106
- * Options to pass on to `@rollup/plugin-commonjs`
107
- */
108
- commonjsOptions?: RollupCommonJSOptions;
109
- /**
110
- * Options to pass on to `@rollup/plugin-dynamic-import-vars`
111
- */
112
- dynamicImportVarsOptions?: RollupDynamicImportVarsOptions;
113
- /**
114
- * Whether to write bundle to disk
115
- * @default true
116
- */
117
- write?: boolean;
118
- /**
119
- * Empty outDir on write.
120
- * @default true when outDir is a sub directory of project root
121
- */
122
- emptyOutDir?: boolean | null;
123
- /**
124
- * Whether to emit a manifest.json under assets dir to map hash-less filenames
125
- * to their hashed versions. Useful when you want to generate your own HTML
126
- * instead of using the one generated by Vite.
127
- *
128
- * Example:
129
- *
130
- * ```json
131
- * {
132
- * "main.js": {
133
- * "file": "main.68fe3fad.js",
134
- * "css": "main.e6b63442.css",
135
- * "imports": [...],
136
- * "dynamicImports": [...]
137
- * }
138
- * }
139
- * ```
140
- * @default false
141
- */
142
- manifest?: boolean;
143
- /**
144
- * Build in library mode. The value should be the global name of the lib in
145
- * UMD mode. This will produce esm + cjs + umd bundle formats with default
146
- * configurations that are suitable for distributing libraries.
147
- */
148
- lib?: LibraryOptions | false;
149
- /**
150
- * Produce SSR oriented build. Note this requires specifying SSR entry via
151
- * `rollupOptions.input`.
152
- */
153
- ssr?: boolean | string;
154
- /**
155
- * Generate SSR manifest for determining style links and asset preload
156
- * directives in production.
157
- */
158
- ssrManifest?: boolean;
159
- /**
160
- * Set to false to disable reporting compressed chunk sizes.
161
- * Can slightly improve build speed.
162
- */
163
- reportCompressedSize?: boolean;
164
- /**
165
- * Set to false to disable brotli compressed size reporting for build.
166
- * Can slightly improve build speed.
167
- * @deprecated use `build.reportCompressedSize` instead.
168
- */
169
- brotliSize?: boolean;
170
- /**
171
- * Adjust chunk size warning limit (in kbs).
172
- * @default 500
173
- */
174
- chunkSizeWarningLimit?: number;
175
- /**
176
- * Rollup watch options
177
- * https://rollupjs.org/guide/en/#watchoptions
178
- */
179
- watch?: WatcherOptions | null;
180
- }
181
- export interface LibraryOptions {
182
- entry: string;
183
- name?: string;
184
- formats?: LibraryFormats[];
185
- fileName?: string | ((format: ModuleFormat) => string);
186
- }
187
- export declare type LibraryFormats = 'es' | 'cjs' | 'umd' | 'iife';
188
- export declare type ResolvedBuildOptions = Required<Omit<BuildOptions, 'base' | 'cleanCssOptions' | 'polyfillDynamicImport' | 'brotliSize'>>;
189
- export declare function resolveBuildOptions(root: string, raw?: BuildOptions, isBuild?: boolean): ResolvedBuildOptions;
190
- export declare function resolveBuildPlugins(config: ResolvedConfig): {
191
- pre: Plugin[];
192
- post: Plugin[];
193
- };
194
- /**
195
- * Bundles the app for production.
196
- * Returns a Promise containing the build result.
197
- */
198
- export declare function build(inlineConfig?: InlineConfig): Promise<RollupOutput | RollupOutput[] | RollupWatcher>;
199
- export declare function resolveLibFilename(libOptions: LibraryOptions, format: ModuleFormat, root: string): string;
200
- export declare function onRollupWarning(warning: RollupWarning, warn: WarningHandler, config: ResolvedConfig): void;