vite 2.7.0-beta.8 → 2.7.2

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 (77) hide show
  1. package/CHANGELOG.md +106 -29
  2. package/LICENSE.md +0 -17
  3. package/dist/node/build.d.ts +200 -0
  4. package/dist/node/chunks/{dep-03d6dbab.js → dep-453486e7.js} +2 -2
  5. package/dist/node/chunks/{dep-03d6dbab.js.map → dep-453486e7.js.map} +1 -1
  6. package/dist/node/chunks/{dep-d87be5e9.js → dep-7817f5b4.js} +1557 -1382
  7. package/dist/node/chunks/dep-7817f5b4.js.map +1 -0
  8. package/dist/node/chunks/{dep-8fdf8f48.js → dep-93096c54.js} +2 -2
  9. package/dist/node/chunks/{dep-8fdf8f48.js.map → dep-93096c54.js.map} +1 -1
  10. package/dist/node/chunks/{dep-b192ffe4.js → dep-fffc0487.js} +2 -2
  11. package/dist/node/chunks/{dep-b192ffe4.js.map → dep-fffc0487.js.map} +1 -1
  12. package/dist/node/cli.d.ts +1 -0
  13. package/dist/node/cli.js +4 -4
  14. package/dist/node/cli.js.map +1 -1
  15. package/dist/node/config.d.ts +202 -0
  16. package/dist/node/constants.d.ts +33 -0
  17. package/dist/node/http.d.ts +84 -0
  18. package/dist/node/importGlob.d.ts +9 -0
  19. package/dist/node/index.d.ts +280 -280
  20. package/dist/node/index.js +1 -1
  21. package/dist/node/logger.d.ts +35 -0
  22. package/dist/node/optimizer/esbuildDepPlugin.d.ts +4 -0
  23. package/dist/node/optimizer/index.d.ts +66 -0
  24. package/dist/node/optimizer/registerMissing.d.ts +2 -0
  25. package/dist/node/optimizer/scan.d.ts +9 -0
  26. package/dist/node/packages.d.ts +25 -0
  27. package/dist/node/plugin.d.ts +115 -0
  28. package/dist/node/plugins/asset.d.ts +40 -0
  29. package/dist/node/plugins/assetImportMetaUrl.d.ts +13 -0
  30. package/dist/node/plugins/clientInjections.d.ts +7 -0
  31. package/dist/node/plugins/css.d.ts +72 -0
  32. package/dist/node/plugins/dataUri.d.ts +5 -0
  33. package/dist/node/plugins/define.d.ts +3 -0
  34. package/dist/node/plugins/esbuild.d.ts +15 -0
  35. package/dist/node/plugins/html.d.ts +102 -0
  36. package/dist/node/plugins/importAnalysis.d.ts +46 -0
  37. package/dist/node/plugins/importAnalysisBuild.d.ts +15 -0
  38. package/dist/node/plugins/index.d.ts +3 -0
  39. package/dist/node/plugins/json.d.ts +22 -0
  40. package/dist/node/plugins/loadFallback.d.ts +5 -0
  41. package/dist/node/plugins/manifest.d.ts +14 -0
  42. package/dist/node/plugins/modulePreloadPolyfill.d.ts +4 -0
  43. package/dist/node/plugins/preAlias.d.ts +5 -0
  44. package/dist/node/plugins/reporter.d.ts +3 -0
  45. package/dist/node/plugins/resolve.d.ts +38 -0
  46. package/dist/node/plugins/ssrRequireHook.d.ts +12 -0
  47. package/dist/node/plugins/terser.d.ts +3 -0
  48. package/dist/node/plugins/wasm.d.ts +3 -0
  49. package/dist/node/plugins/worker.d.ts +3 -0
  50. package/dist/node/preview.d.ts +31 -0
  51. package/dist/node/server/hmr.d.ts +37 -0
  52. package/dist/node/server/index.d.ts +214 -0
  53. package/dist/node/server/middlewares/base.d.ts +3 -0
  54. package/dist/node/server/middlewares/error.d.ts +8 -0
  55. package/dist/node/server/middlewares/indexHtml.d.ts +4 -0
  56. package/dist/node/server/middlewares/proxy.d.ts +20 -0
  57. package/dist/node/server/middlewares/spaFallback.d.ts +2 -0
  58. package/dist/node/server/middlewares/static.d.ts +6 -0
  59. package/dist/node/server/middlewares/time.d.ts +2 -0
  60. package/dist/node/server/middlewares/transform.d.ts +3 -0
  61. package/dist/node/server/moduleGraph.d.ts +53 -0
  62. package/dist/node/server/openBrowser.d.ts +15 -0
  63. package/dist/node/server/pluginContainer.d.ts +37 -0
  64. package/dist/node/server/searchRoot.d.ts +8 -0
  65. package/dist/node/server/send.d.ts +4 -0
  66. package/dist/node/server/sourcemap.d.ts +8 -0
  67. package/dist/node/server/transformRequest.d.ts +14 -0
  68. package/dist/node/server/ws.d.ts +14 -0
  69. package/dist/node/ssr/ssrExternal.d.ts +7 -0
  70. package/dist/node/ssr/ssrManifestPlugin.d.ts +3 -0
  71. package/dist/node/ssr/ssrModuleLoader.d.ts +7 -0
  72. package/dist/node/ssr/ssrStacktrace.d.ts +3 -0
  73. package/dist/node/ssr/ssrTransform.d.ts +8 -0
  74. package/dist/node/utils.d.ts +114 -0
  75. package/package.json +9 -10
  76. package/types/ws.d.ts +277 -281
  77. package/dist/node/chunks/dep-d87be5e9.js.map +0 -1
@@ -0,0 +1,35 @@
1
+ /// <reference types="node" />
2
+ import { Server } from 'net';
3
+ import { RollupError } from 'rollup';
4
+ import { ResolvedConfig } from '.';
5
+ import { CommonServerOptions } from './http';
6
+ export declare type LogType = 'error' | 'warn' | 'info';
7
+ export declare type LogLevel = LogType | 'silent';
8
+ export interface Logger {
9
+ info(msg: string, options?: LogOptions): void;
10
+ warn(msg: string, options?: LogOptions): void;
11
+ warnOnce(msg: string, options?: LogOptions): void;
12
+ error(msg: string, options?: LogErrorOptions): void;
13
+ clearScreen(type: LogType): void;
14
+ hasErrorLogged(error: Error | RollupError): boolean;
15
+ hasWarned: boolean;
16
+ }
17
+ export interface LogOptions {
18
+ clear?: boolean;
19
+ timestamp?: boolean;
20
+ }
21
+ export interface LogErrorOptions extends LogOptions {
22
+ error?: Error | RollupError | null;
23
+ }
24
+ export declare const LogLevels: Record<LogLevel, number>;
25
+ export interface LoggerOptions {
26
+ prefix?: string;
27
+ allowClearScreen?: boolean;
28
+ customLogger?: Logger;
29
+ }
30
+ export declare function createLogger(level?: LogLevel, options?: LoggerOptions): Logger;
31
+ /**
32
+ * @deprecated Use `server.printUrls()` instead
33
+ */
34
+ export declare function printHttpServerUrls(server: Server, config: ResolvedConfig): void;
35
+ export declare function printCommonServerUrls(server: Server, options: CommonServerOptions, config: ResolvedConfig): void;
@@ -0,0 +1,4 @@
1
+ import { Plugin } from 'esbuild';
2
+ import { ResolvedConfig } from '..';
3
+ import { ExportsData } from '.';
4
+ export declare function esbuildDepPlugin(qualified: Record<string, string>, exportsData: Record<string, ExportsData>, config: ResolvedConfig, ssr?: boolean): Plugin;
@@ -0,0 +1,66 @@
1
+ import { BuildOptions as EsbuildBuildOptions } from 'esbuild';
2
+ import { ResolvedConfig } from '../config';
3
+ import { parse } from 'es-module-lexer';
4
+ export declare type ExportsData = ReturnType<typeof parse> & {
5
+ hasReExports?: true;
6
+ };
7
+ export interface DepOptimizationOptions {
8
+ /**
9
+ * By default, Vite will crawl your index.html to detect dependencies that
10
+ * need to be pre-bundled. If build.rollupOptions.input is specified, Vite
11
+ * will crawl those entry points instead.
12
+ *
13
+ * If neither of these fit your needs, you can specify custom entries using
14
+ * this option - the value should be a fast-glob pattern or array of patterns
15
+ * (https://github.com/mrmlnc/fast-glob#basic-syntax) that are relative from
16
+ * vite project root. This will overwrite default entries inference.
17
+ */
18
+ entries?: string | string[];
19
+ /**
20
+ * Force optimize listed dependencies (must be resolvable import paths,
21
+ * cannot be globs).
22
+ */
23
+ include?: string[];
24
+ /**
25
+ * Do not optimize these dependencies (must be resolvable import paths,
26
+ * cannot be globs).
27
+ */
28
+ exclude?: string[];
29
+ /**
30
+ * Options to pass to esbuild during the dep scanning and optimization
31
+ *
32
+ * Certain options are omitted since changing them would not be compatible
33
+ * with Vite's dep optimization.
34
+ *
35
+ * - `external` is also omitted, use Vite's `optimizeDeps.exclude` option
36
+ * - `plugins` are merged with Vite's dep plugin
37
+ * - `keepNames` takes precedence over the deprecated `optimizeDeps.keepNames`
38
+ *
39
+ * https://esbuild.github.io/api
40
+ */
41
+ esbuildOptions?: Omit<EsbuildBuildOptions, 'bundle' | 'entryPoints' | 'external' | 'write' | 'watch' | 'outdir' | 'outfile' | 'outbase' | 'outExtension' | 'metafile'>;
42
+ /**
43
+ * @deprecated use `esbuildOptions.keepNames`
44
+ */
45
+ keepNames?: boolean;
46
+ }
47
+ export interface DepOptimizationMetadata {
48
+ /**
49
+ * The main hash is determined by user config and dependency lockfiles.
50
+ * This is checked on server startup to avoid unnecessary re-bundles.
51
+ */
52
+ hash: string;
53
+ /**
54
+ * The browser hash is determined by the main hash plus additional dependencies
55
+ * discovered at runtime. This is used to invalidate browser requests to
56
+ * optimized deps.
57
+ */
58
+ browserHash: string;
59
+ optimized: Record<string, {
60
+ file: string;
61
+ src: string;
62
+ needsInterop: boolean;
63
+ }>;
64
+ }
65
+ export declare function optimizeDeps(config: ResolvedConfig, force?: boolean | undefined, asCommand?: boolean, newDeps?: Record<string, string>, // missing imports encountered after server has started
66
+ ssr?: boolean): Promise<DepOptimizationMetadata | null>;
@@ -0,0 +1,2 @@
1
+ import { ViteDevServer } from '..';
2
+ export declare function createMissingImporterRegisterFn(server: ViteDevServer): (id: string, resolved: string, ssr?: boolean) => void;
@@ -0,0 +1,9 @@
1
+ import { ResolvedConfig } from '..';
2
+ export declare const importsRE: RegExp;
3
+ export declare function scanImports(config: ResolvedConfig): Promise<{
4
+ deps: Record<string, string>;
5
+ missing: Record<string, string>;
6
+ }>;
7
+ export declare const scriptRE: RegExp;
8
+ export declare const commentRE: RegExp;
9
+ export declare function shouldExternalizeDep(resolvedId: string, rawId: string): boolean;
@@ -0,0 +1,25 @@
1
+ import { ResolvedConfig } from './config';
2
+ import { Plugin } from './plugin';
3
+ /** Cache for package.json resolution and package.json contents */
4
+ export declare type PackageCache = Map<string, PackageData>;
5
+ export interface PackageData {
6
+ dir: string;
7
+ hasSideEffects: (id: string) => boolean | 'no-treeshake';
8
+ webResolvedImports: Record<string, string | undefined>;
9
+ nodeResolvedImports: Record<string, string | undefined>;
10
+ setResolvedCache: (key: string, entry: string, targetWeb: boolean) => void;
11
+ getResolvedCache: (key: string, targetWeb: boolean) => string | undefined;
12
+ data: {
13
+ [field: string]: any;
14
+ version: string;
15
+ main: string;
16
+ module: string;
17
+ browser: string | Record<string, string | false>;
18
+ exports: string | Record<string, any> | string[];
19
+ dependencies: Record<string, string>;
20
+ };
21
+ }
22
+ export declare function invalidatePackageData(packageCache: PackageCache, pkgPath: string): void;
23
+ export declare function resolvePackageData(id: string, basedir: string, preserveSymlinks?: boolean, packageCache?: PackageCache): PackageData | null;
24
+ export declare function loadPackageData(pkgPath: string, preserveSymlinks?: boolean, packageCache?: PackageCache): PackageData;
25
+ export declare function watchPackageDataPlugin(config: ResolvedConfig): Plugin;
@@ -0,0 +1,115 @@
1
+ import { UserConfig } from './config';
2
+ import { CustomPluginOptions, LoadResult, Plugin as RollupPlugin, PluginContext, ResolveIdResult, TransformPluginContext, TransformResult } from 'rollup';
3
+ import { ServerHook } from './server';
4
+ import { IndexHtmlTransform } from './plugins/html';
5
+ import { ModuleNode } from './server/moduleGraph';
6
+ import { ConfigEnv, ResolvedConfig } from './';
7
+ import { HmrContext } from './server/hmr';
8
+ /**
9
+ * Vite plugins extends the Rollup plugin interface with a few extra
10
+ * vite-specific options. A valid vite plugin is also a valid Rollup plugin.
11
+ * On the contrary, a Rollup plugin may or may NOT be a valid vite universal
12
+ * plugin, since some Rollup features do not make sense in an unbundled
13
+ * dev server context. That said, as long as a rollup plugin doesn't have strong
14
+ * coupling between its bundle phase and output phase hooks then it should
15
+ * just work (that means, most of them).
16
+ *
17
+ * By default, the plugins are run during both serve and build. When a plugin
18
+ * is applied during serve, it will only run **non output plugin hooks** (see
19
+ * rollup type definition of {@link rollup#PluginHooks}). You can think of the
20
+ * dev server as only running `const bundle = rollup.rollup()` but never calling
21
+ * `bundle.generate()`.
22
+ *
23
+ * A plugin that expects to have different behavior depending on serve/build can
24
+ * export a factory function that receives the command being run via options.
25
+ *
26
+ * If a plugin should be applied only for server or build, a function format
27
+ * config file can be used to conditional determine the plugins to use.
28
+ */
29
+ export interface Plugin extends RollupPlugin {
30
+ /**
31
+ * Enforce plugin invocation tier similar to webpack loaders.
32
+ *
33
+ * Plugin invocation order:
34
+ * - alias resolution
35
+ * - `enforce: 'pre'` plugins
36
+ * - vite core plugins
37
+ * - normal plugins
38
+ * - vite build plugins
39
+ * - `enforce: 'post'` plugins
40
+ * - vite build post plugins
41
+ */
42
+ enforce?: 'pre' | 'post';
43
+ /**
44
+ * Apply the plugin only for serve or build, or on certain conditions.
45
+ */
46
+ apply?: 'serve' | 'build' | ((config: UserConfig, env: ConfigEnv) => boolean);
47
+ /**
48
+ * Modify vite config before it's resolved. The hook can either mutate the
49
+ * passed-in config directly, or return a partial config object that will be
50
+ * deeply merged into existing config.
51
+ *
52
+ * Note: User plugins are resolved before running this hook so injecting other
53
+ * plugins inside the `config` hook will have no effect.
54
+ */
55
+ config?: (config: UserConfig, env: ConfigEnv) => UserConfig | null | void | Promise<UserConfig | null | void>;
56
+ /**
57
+ * Use this hook to read and store the final resolved vite config.
58
+ */
59
+ configResolved?: (config: ResolvedConfig) => void | Promise<void>;
60
+ /**
61
+ * Configure the vite server. The hook receives the {@link ViteDevServer}
62
+ * instance. This can also be used to store a reference to the server
63
+ * for use in other hooks.
64
+ *
65
+ * The hooks will be called before internal middlewares are applied. A hook
66
+ * can return a post hook that will be called after internal middlewares
67
+ * are applied. Hook can be async functions and will be called in series.
68
+ */
69
+ configureServer?: ServerHook;
70
+ /**
71
+ * Transform index.html.
72
+ * The hook receives the following arguments:
73
+ *
74
+ * - html: string
75
+ * - ctx?: vite.ServerContext (only present during serve)
76
+ * - bundle?: rollup.OutputBundle (only present during build)
77
+ *
78
+ * It can either return a transformed string, or a list of html tag
79
+ * descriptors that will be injected into the <head> or <body>.
80
+ *
81
+ * By default the transform is applied **after** vite's internal html
82
+ * transform. If you need to apply the transform before vite, use an object:
83
+ * `{ enforce: 'pre', transform: hook }`
84
+ */
85
+ transformIndexHtml?: IndexHtmlTransform;
86
+ /**
87
+ * Perform custom handling of HMR updates.
88
+ * The handler receives a context containing changed filename, timestamp, a
89
+ * list of modules affected by the file change, and the dev server instance.
90
+ *
91
+ * - The hook can return a filtered list of modules to narrow down the update.
92
+ * e.g. for a Vue SFC, we can narrow down the part to update by comparing
93
+ * the descriptors.
94
+ *
95
+ * - The hook can also return an empty array and then perform custom updates
96
+ * by sending a custom hmr payload via server.ws.send().
97
+ *
98
+ * - If the hook doesn't return a value, the hmr update will be performed as
99
+ * normal.
100
+ */
101
+ handleHotUpdate?(ctx: HmrContext): Array<ModuleNode> | void | Promise<Array<ModuleNode> | void>;
102
+ /**
103
+ * extend hooks with ssr flag
104
+ */
105
+ resolveId?(this: PluginContext, source: string, importer: string | undefined, options: {
106
+ custom?: CustomPluginOptions;
107
+ ssr?: boolean;
108
+ }): Promise<ResolveIdResult> | ResolveIdResult;
109
+ load?(this: PluginContext, id: string, options?: {
110
+ ssr?: boolean;
111
+ }): Promise<LoadResult> | LoadResult;
112
+ transform?(this: TransformPluginContext, code: string, id: string, options?: {
113
+ ssr?: boolean;
114
+ }): Promise<TransformResult> | TransformResult;
115
+ }
@@ -0,0 +1,40 @@
1
+ /// <reference types="node" />
2
+ import { Plugin } from '../plugin';
3
+ import { ResolvedConfig } from '../config';
4
+ import { OutputOptions, PluginContext, RenderedChunk } from 'rollup';
5
+ export declare const assetUrlRE: RegExp;
6
+ export declare const chunkToEmittedAssetsMap: WeakMap<RenderedChunk, Set<string>>;
7
+ /**
8
+ * Also supports loading plain strings with import text from './foo.txt?raw'
9
+ */
10
+ export declare function assetPlugin(config: ResolvedConfig): Plugin;
11
+ export declare function registerAssetToChunk(chunk: RenderedChunk, file: string): void;
12
+ export declare function checkPublicFile(url: string, { publicDir }: ResolvedConfig): string | undefined;
13
+ export declare function fileToUrl(id: string, config: ResolvedConfig, ctx: PluginContext): string | Promise<string>;
14
+ export declare function getAssetFilename(hash: string, config: ResolvedConfig): string | undefined;
15
+ /**
16
+ * converts the source filepath of the asset to the output filename based on the assetFileNames option. \
17
+ * this function imitates the behavior of rollup.js. \
18
+ * https://rollupjs.org/guide/en/#outputassetfilenames
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * const content = Buffer.from('text');
23
+ * const fileName = assetFileNamesToFileName(
24
+ * 'assets/[name].[hash][extname]',
25
+ * '/path/to/file.txt',
26
+ * getAssetHash(content),
27
+ * content
28
+ * )
29
+ * // fileName: 'assets/file.982d9e3e.txt'
30
+ * ```
31
+ *
32
+ * @param assetFileNames filename pattern. e.g. `'assets/[name].[hash][extname]'`
33
+ * @param file filepath of the asset
34
+ * @param contentHash hash of the asset. used for `'[hash]'` placeholder
35
+ * @param content content of the asset. passed to `assetFileNames` if `assetFileNames` is a function
36
+ * @returns output filename
37
+ */
38
+ export declare function assetFileNamesToFileName(assetFileNames: Exclude<OutputOptions['assetFileNames'], undefined>, file: string, contentHash: string, content: string | Buffer): string;
39
+ export declare function getAssetHash(content: Buffer): string;
40
+ export declare function urlToBuiltUrl(url: string, importer: string, config: ResolvedConfig, pluginContext: PluginContext): Promise<string>;
@@ -0,0 +1,13 @@
1
+ import { Plugin } from '../plugin';
2
+ import { ResolvedConfig } from '../config';
3
+ /**
4
+ * Convert `new URL('./foo.png', import.meta.url)` to its resolved built URL
5
+ *
6
+ * Supports template string with dynamic segments:
7
+ * ```
8
+ * new URL(`./dir/${name}.png`, import.meta.url)
9
+ * // transformed to
10
+ * import.meta.globEager('./dir/**.png')[`./dir/${name}.png`].default
11
+ * ```
12
+ */
13
+ export declare function assetImportMetaUrlPlugin(config: ResolvedConfig): Plugin;
@@ -0,0 +1,7 @@
1
+ import { Plugin } from '../plugin';
2
+ import { ResolvedConfig } from '../config';
3
+ /**
4
+ * some values used by the client needs to be dynamically injected by the server
5
+ * @server-only
6
+ */
7
+ export declare function clientInjectionsPlugin(config: ResolvedConfig): Plugin;
@@ -0,0 +1,72 @@
1
+ import { Plugin } from '../plugin';
2
+ import { ResolvedConfig } from '../config';
3
+ import { RenderedChunk, RollupError } from 'rollup';
4
+ import { ResolveFn } from '../';
5
+ import * as Postcss from 'postcss';
6
+ import { Alias } from 'types/alias';
7
+ export interface CSSOptions {
8
+ /**
9
+ * https://github.com/css-modules/postcss-modules
10
+ */
11
+ modules?: CSSModulesOptions | false;
12
+ preprocessorOptions?: Record<string, any>;
13
+ postcss?: string | (Postcss.ProcessOptions & {
14
+ plugins?: Postcss.Plugin[];
15
+ });
16
+ }
17
+ export interface CSSModulesOptions {
18
+ getJSON?: (cssFileName: string, json: Record<string, string>, outputFileName: string) => void;
19
+ scopeBehaviour?: 'global' | 'local';
20
+ globalModulePaths?: RegExp[];
21
+ generateScopedName?: string | ((name: string, filename: string, css: string) => string);
22
+ hashPrefix?: string;
23
+ /**
24
+ * default: null
25
+ */
26
+ localsConvention?: 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly' | null;
27
+ }
28
+ export declare const isCSSRequest: (request: string) => boolean;
29
+ export declare const isDirectCSSRequest: (request: string) => boolean;
30
+ export declare const isDirectRequest: (request: string) => boolean;
31
+ export declare const chunkToEmittedCssFileMap: WeakMap<RenderedChunk, Set<string>>;
32
+ export declare const removedPureCssFilesCache: WeakMap<Readonly<Omit<import("../config").UserConfig, "plugins" | "alias" | "dedupe" | "assetsInclude" | "optimizeDeps"> & {
33
+ configFile: string | undefined;
34
+ configFileDependencies: string[];
35
+ inlineConfig: import("../config").InlineConfig;
36
+ root: string;
37
+ base: string;
38
+ publicDir: string;
39
+ command: "build" | "serve";
40
+ mode: string;
41
+ isProduction: boolean;
42
+ env: Record<string, any>;
43
+ resolve: import("./resolve").ResolveOptions & {
44
+ alias: Alias[];
45
+ };
46
+ plugins: readonly Plugin[];
47
+ server: import("../server").ResolvedServerOptions;
48
+ build: Required<Omit<import("../build").BuildOptions, "base" | "cleanCssOptions" | "polyfillDynamicImport" | "brotliSize">>;
49
+ preview: import("../preview").ResolvedPreviewOptions;
50
+ assetsInclude: (file: string) => boolean; /**
51
+ * Plugin applied after user plugins
52
+ */
53
+ logger: import("../logger").Logger;
54
+ createResolver: (options?: Partial<import("./resolve").InternalResolveOptions> | undefined) => ResolveFn;
55
+ optimizeDeps: Omit<import("../optimizer").DepOptimizationOptions, "keepNames">;
56
+ packageCache: import("../packages").PackageCache;
57
+ }>, Map<string, RenderedChunk>>;
58
+ /**
59
+ * Plugin applied before user plugins
60
+ */
61
+ export declare function cssPlugin(config: ResolvedConfig): Plugin;
62
+ /**
63
+ * Plugin applied after user plugins
64
+ */
65
+ export declare function cssPostPlugin(config: ResolvedConfig): Plugin;
66
+ export declare const cssUrlRE: RegExp;
67
+ export interface StylePreprocessorResults {
68
+ code: string;
69
+ map?: object;
70
+ errors: RollupError[];
71
+ deps: string[];
72
+ }
@@ -0,0 +1,5 @@
1
+ import { Plugin } from '../plugin';
2
+ /**
3
+ * Build only, since importing from a data URI works natively.
4
+ */
5
+ export declare function dataURIPlugin(): Plugin;
@@ -0,0 +1,3 @@
1
+ import { ResolvedConfig } from '../config';
2
+ import { Plugin } from '../plugin';
3
+ export declare function definePlugin(config: ResolvedConfig): Plugin;
@@ -0,0 +1,15 @@
1
+ import { Plugin } from '../plugin';
2
+ import { TransformOptions, TransformResult } from 'esbuild';
3
+ import { SourceMap } from 'rollup';
4
+ import { ResolvedConfig } from '..';
5
+ export interface ESBuildOptions extends TransformOptions {
6
+ include?: string | RegExp | string[] | RegExp[];
7
+ exclude?: string | RegExp | string[] | RegExp[];
8
+ jsxInject?: string;
9
+ }
10
+ export declare type ESBuildTransformResult = Omit<TransformResult, 'map'> & {
11
+ map: SourceMap;
12
+ };
13
+ export declare function transformWithEsbuild(code: string, filename: string, options?: TransformOptions, inMap?: object): Promise<ESBuildTransformResult>;
14
+ export declare function esbuildPlugin(options?: ESBuildOptions): Plugin;
15
+ export declare const buildEsbuildPlugin: (config: ResolvedConfig) => Plugin;
@@ -0,0 +1,102 @@
1
+ import { Plugin } from '../plugin';
2
+ import { ViteDevServer } from '../server';
3
+ import { OutputBundle, OutputChunk } from 'rollup';
4
+ import { ResolvedConfig } from '../config';
5
+ import { AttributeNode, NodeTransform, ElementNode } from '@vue/compiler-dom';
6
+ export declare const isHTMLProxy: (id: string) => boolean;
7
+ export declare const htmlProxyMap: WeakMap<Readonly<Omit<import("../config").UserConfig, "plugins" | "alias" | "dedupe" | "assetsInclude" | "optimizeDeps"> & {
8
+ configFile: string | undefined;
9
+ configFileDependencies: string[];
10
+ inlineConfig: import("../config").InlineConfig;
11
+ root: string;
12
+ base: string;
13
+ publicDir: string;
14
+ command: "build" | "serve";
15
+ mode: string;
16
+ isProduction: boolean;
17
+ env: Record<string, any>;
18
+ resolve: import("./resolve").ResolveOptions & {
19
+ alias: import("types/alias").Alias[];
20
+ };
21
+ plugins: readonly Plugin[];
22
+ server: import("../server").ResolvedServerOptions;
23
+ build: Required<Omit<import("..").BuildOptions, "base" | "cleanCssOptions" | "polyfillDynamicImport" | "brotliSize">>;
24
+ preview: import("..").ResolvedPreviewOptions;
25
+ assetsInclude: (file: string) => boolean;
26
+ logger: import("..").Logger;
27
+ createResolver: (options?: Partial<import("./resolve").InternalResolveOptions> | undefined) => import("../config").ResolveFn;
28
+ optimizeDeps: Omit<import("..").DepOptimizationOptions, "keepNames">;
29
+ packageCache: import("..").PackageCache;
30
+ }>, Map<string, string[]>>;
31
+ export declare function htmlInlineScriptProxyPlugin(config: ResolvedConfig): Plugin;
32
+ /** Add script to cache */
33
+ export declare function addToHTMLProxyCache(config: ResolvedConfig, filePath: string, index: number, code: string): void;
34
+ export declare const assetAttrsConfig: Record<string, string[]>;
35
+ export declare const isAsyncScriptMap: WeakMap<Readonly<Omit<import("../config").UserConfig, "plugins" | "alias" | "dedupe" | "assetsInclude" | "optimizeDeps"> & {
36
+ configFile: string | undefined;
37
+ configFileDependencies: string[];
38
+ inlineConfig: import("../config").InlineConfig;
39
+ root: string;
40
+ base: string;
41
+ publicDir: string;
42
+ command: "build" | "serve";
43
+ mode: string;
44
+ isProduction: boolean;
45
+ env: Record<string, any>;
46
+ resolve: import("./resolve").ResolveOptions & {
47
+ alias: import("types/alias").Alias[];
48
+ };
49
+ plugins: readonly Plugin[];
50
+ server: import("../server").ResolvedServerOptions;
51
+ build: Required<Omit<import("..").BuildOptions, "base" | "cleanCssOptions" | "polyfillDynamicImport" | "brotliSize">>;
52
+ preview: import("..").ResolvedPreviewOptions;
53
+ assetsInclude: (file: string) => boolean;
54
+ logger: import("..").Logger;
55
+ createResolver: (options?: Partial<import("./resolve").InternalResolveOptions> | undefined) => import("../config").ResolveFn;
56
+ optimizeDeps: Omit<import("..").DepOptimizationOptions, "keepNames">;
57
+ packageCache: import("..").PackageCache;
58
+ }>, Map<string, boolean>>;
59
+ export declare function traverseHtml(html: string, filePath: string, visitor: NodeTransform): Promise<void>;
60
+ export declare function getScriptInfo(node: ElementNode): {
61
+ src: AttributeNode | undefined;
62
+ isModule: boolean;
63
+ isAsync: boolean;
64
+ };
65
+ /**
66
+ * Compiles index.html into an entry js module
67
+ */
68
+ export declare function buildHtmlPlugin(config: ResolvedConfig): Plugin;
69
+ export interface HtmlTagDescriptor {
70
+ tag: string;
71
+ attrs?: Record<string, string | boolean | undefined>;
72
+ children?: string | HtmlTagDescriptor[];
73
+ /**
74
+ * default: 'head-prepend'
75
+ */
76
+ injectTo?: 'head' | 'body' | 'head-prepend' | 'body-prepend';
77
+ }
78
+ export declare type IndexHtmlTransformResult = string | HtmlTagDescriptor[] | {
79
+ html: string;
80
+ tags: HtmlTagDescriptor[];
81
+ };
82
+ export interface IndexHtmlTransformContext {
83
+ /**
84
+ * public path when served
85
+ */
86
+ path: string;
87
+ /**
88
+ * filename on disk
89
+ */
90
+ filename: string;
91
+ server?: ViteDevServer;
92
+ bundle?: OutputBundle;
93
+ chunk?: OutputChunk;
94
+ originalUrl?: string;
95
+ }
96
+ export declare type IndexHtmlTransformHook = (html: string, ctx: IndexHtmlTransformContext) => IndexHtmlTransformResult | void | Promise<IndexHtmlTransformResult | void>;
97
+ export declare type IndexHtmlTransform = IndexHtmlTransformHook | {
98
+ enforce?: 'pre' | 'post';
99
+ transform: IndexHtmlTransformHook;
100
+ };
101
+ export declare function resolveHtmlTransforms(plugins: readonly Plugin[]): [IndexHtmlTransformHook[], IndexHtmlTransformHook[]];
102
+ export declare function applyHtmlTransforms(html: string, hooks: IndexHtmlTransformHook[], ctx: IndexHtmlTransformContext): Promise<string>;
@@ -0,0 +1,46 @@
1
+ import { Plugin } from '../plugin';
2
+ import { ResolvedConfig } from '../config';
3
+ /**
4
+ * Server-only plugin that lexes, resolves, rewrites and analyzes url imports.
5
+ *
6
+ * - Imports are resolved to ensure they exist on disk
7
+ *
8
+ * - Lexes HMR accept calls and updates import relationships in the module graph
9
+ *
10
+ * - Bare module imports are resolved (by @rollup-plugin/node-resolve) to
11
+ * absolute file paths, e.g.
12
+ *
13
+ * ```js
14
+ * import 'foo'
15
+ * ```
16
+ * is rewritten to
17
+ * ```js
18
+ * import '/@fs//project/node_modules/foo/dist/foo.js'
19
+ * ```
20
+ *
21
+ * - CSS imports are appended with `.js` since both the js module and the actual
22
+ * css (referenced via <link>) may go through the transform pipeline:
23
+ *
24
+ * ```js
25
+ * import './style.css'
26
+ * ```
27
+ * is rewritten to
28
+ * ```js
29
+ * import './style.css.js'
30
+ * ```
31
+ */
32
+ export declare function importAnalysisPlugin(config: ResolvedConfig): Plugin;
33
+ /**
34
+ * Detect import statements to a known optimized CJS dependency and provide
35
+ * ES named imports interop. We do this by rewriting named imports to a variable
36
+ * assignment to the corresponding property on the `module.exports` of the cjs
37
+ * module. Note this doesn't support dynamic re-assignments from within the cjs
38
+ * module.
39
+ *
40
+ * Note that es-module-lexer treats `export * from '...'` as an import as well,
41
+ * so, we may encounter ExportAllDeclaration here, in which case `undefined`
42
+ * will be returned.
43
+ *
44
+ * Credits \@csr632 via #837
45
+ */
46
+ export declare function transformCjsImport(importExp: string, url: string, rawUrl: string, importIndex: number): string | undefined;
@@ -0,0 +1,15 @@
1
+ import { ResolvedConfig } from '../config';
2
+ import { Plugin } from '../plugin';
3
+ /**
4
+ * A flag for injected helpers. This flag will be set to `false` if the output
5
+ * target is not native es - so that injected helper logic can be conditionally
6
+ * dropped.
7
+ */
8
+ export declare const isModernFlag = "__VITE_IS_MODERN__";
9
+ export declare const preloadMethod = "__vitePreload";
10
+ export declare const preloadMarker = "__VITE_PRELOAD__";
11
+ export declare const preloadBaseMarker = "__VITE_PRELOAD_BASE__";
12
+ /**
13
+ * Build only. During serve this is performed as part of ./importAnalysis.
14
+ */
15
+ export declare function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin;
@@ -0,0 +1,3 @@
1
+ import { ResolvedConfig } from '../config';
2
+ import { Plugin } from '../plugin';
3
+ export declare function resolvePlugins(config: ResolvedConfig, prePlugins: Plugin[], normalPlugins: Plugin[], postPlugins: Plugin[]): Promise<Plugin[]>;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * https://github.com/rollup/plugins/blob/master/packages/json/src/index.js
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file at
6
+ * https://github.com/rollup/plugins/blob/master/LICENSE
7
+ */
8
+ import { Plugin } from 'rollup';
9
+ export interface JsonOptions {
10
+ /**
11
+ * Generate a named export for every property of the JSON object
12
+ * @default true
13
+ */
14
+ namedExports?: boolean;
15
+ /**
16
+ * Generate performant output as JSON.parse("stringified").
17
+ * Enabling this will disable namedExports.
18
+ * @default false
19
+ */
20
+ stringify?: boolean;
21
+ }
22
+ export declare function jsonPlugin(options: JsonOptions | undefined, isBuild: boolean): Plugin;
@@ -0,0 +1,5 @@
1
+ import { Plugin } from '..';
2
+ /**
3
+ * A plugin to provide build load fallback for arbitrary request with queries.
4
+ */
5
+ export declare function loadFallbackPlugin(): Plugin;
@@ -0,0 +1,14 @@
1
+ import { ResolvedConfig } from '..';
2
+ import { Plugin } from '../plugin';
3
+ export declare type Manifest = Record<string, ManifestChunk>;
4
+ export interface ManifestChunk {
5
+ src?: string;
6
+ file: string;
7
+ css?: string[];
8
+ assets?: string[];
9
+ isEntry?: boolean;
10
+ isDynamicEntry?: boolean;
11
+ imports?: string[];
12
+ dynamicImports?: string[];
13
+ }
14
+ export declare function manifestPlugin(config: ResolvedConfig): Plugin;
@@ -0,0 +1,4 @@
1
+ import { ResolvedConfig } from '..';
2
+ import { Plugin } from '../plugin';
3
+ export declare const modulePreloadPolyfillId = "vite/modulepreload-polyfill";
4
+ export declare function modulePreloadPolyfillPlugin(config: ResolvedConfig): Plugin;
@@ -0,0 +1,5 @@
1
+ import { Plugin } from '../plugin';
2
+ /**
3
+ * A plugin to avoid an aliased AND optimized dep from being aliased in src
4
+ */
5
+ export declare function preAliasPlugin(): Plugin;