vite 2.6.6 → 2.6.10

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 (82) hide show
  1. package/dist/node/chunks/{dep-8fc3d0a8.js → dep-8e7741a0.js} +2 -2
  2. package/dist/node/chunks/{dep-8fc3d0a8.js.map → dep-8e7741a0.js.map} +1 -1
  3. package/dist/node/chunks/{dep-6a58f2f7.js → dep-9b6b378f.js} +2 -2
  4. package/dist/node/chunks/{dep-6a58f2f7.js.map → dep-9b6b378f.js.map} +1 -1
  5. package/dist/node/chunks/{dep-da8087f5.js → dep-b502d052.js} +2 -2
  6. package/dist/node/chunks/{dep-da8087f5.js.map → dep-b502d052.js.map} +1 -1
  7. package/dist/node/chunks/{dep-713b45e1.js → dep-be032392.js} +59 -27
  8. package/dist/node/chunks/dep-be032392.js.map +1 -0
  9. package/dist/node/cli.js +4 -4
  10. package/dist/node/index.d.ts +517 -2
  11. package/dist/node/index.js +1 -1
  12. package/package.json +6 -6
  13. package/types/ws.d.ts +532 -0
  14. package/CHANGELOG.md +0 -2265
  15. package/dist/client/client.d.ts +0 -17
  16. package/dist/client/env.d.ts +0 -4
  17. package/dist/client/overlay.d.ts +0 -8
  18. package/dist/node/build.d.ts +0 -191
  19. package/dist/node/chunks/dep-1ee92c88.js +0 -10031
  20. package/dist/node/chunks/dep-1ee92c88.js.map +0 -1
  21. package/dist/node/chunks/dep-51d7aa64.js +0 -10032
  22. package/dist/node/chunks/dep-51d7aa64.js.map +0 -1
  23. package/dist/node/chunks/dep-713b45e1.js.map +0 -1
  24. package/dist/node/chunks/dep-e5804462.js +0 -10032
  25. package/dist/node/chunks/dep-e5804462.js.map +0 -1
  26. package/dist/node/cli.d.ts +0 -1
  27. package/dist/node/config.d.ts +0 -193
  28. package/dist/node/constants.d.ts +0 -27
  29. package/dist/node/importGlob.d.ts +0 -9
  30. package/dist/node/logger.d.ts +0 -28
  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/plugin.d.ts +0 -110
  36. package/dist/node/plugins/asset.d.ts +0 -40
  37. package/dist/node/plugins/assetImportMetaUrl.d.ts +0 -13
  38. package/dist/node/plugins/clientInjections.d.ts +0 -7
  39. package/dist/node/plugins/css.d.ts +0 -68
  40. package/dist/node/plugins/dataUri.d.ts +0 -5
  41. package/dist/node/plugins/define.d.ts +0 -3
  42. package/dist/node/plugins/esbuild.d.ts +0 -15
  43. package/dist/node/plugins/html.d.ts +0 -74
  44. package/dist/node/plugins/importAnalysis.d.ts +0 -32
  45. package/dist/node/plugins/importAnalysisBuild.d.ts +0 -15
  46. package/dist/node/plugins/index.d.ts +0 -3
  47. package/dist/node/plugins/json.d.ts +0 -22
  48. package/dist/node/plugins/loadFallback.d.ts +0 -5
  49. package/dist/node/plugins/manifest.d.ts +0 -14
  50. package/dist/node/plugins/modulePreloadPolyfill.d.ts +0 -4
  51. package/dist/node/plugins/preAlias.d.ts +0 -5
  52. package/dist/node/plugins/reporter.d.ts +0 -3
  53. package/dist/node/plugins/resolve.d.ts +0 -51
  54. package/dist/node/plugins/terser.d.ts +0 -3
  55. package/dist/node/plugins/wasm.d.ts +0 -3
  56. package/dist/node/plugins/worker.d.ts +0 -3
  57. package/dist/node/preview.d.ts +0 -2
  58. package/dist/node/server/hmr.d.ts +0 -37
  59. package/dist/node/server/http.d.ts +0 -14
  60. package/dist/node/server/index.d.ts +0 -235
  61. package/dist/node/server/middlewares/base.d.ts +0 -3
  62. package/dist/node/server/middlewares/error.d.ts +0 -11
  63. package/dist/node/server/middlewares/indexHtml.d.ts +0 -4
  64. package/dist/node/server/middlewares/proxy.d.ts +0 -20
  65. package/dist/node/server/middlewares/spaFallback.d.ts +0 -2
  66. package/dist/node/server/middlewares/static.d.ts +0 -7
  67. package/dist/node/server/middlewares/time.d.ts +0 -2
  68. package/dist/node/server/middlewares/transform.d.ts +0 -3
  69. package/dist/node/server/moduleGraph.d.ts +0 -46
  70. package/dist/node/server/openBrowser.d.ts +0 -15
  71. package/dist/node/server/pluginContainer.d.ts +0 -27
  72. package/dist/node/server/searchRoot.d.ts +0 -8
  73. package/dist/node/server/send.d.ts +0 -4
  74. package/dist/node/server/sourcemap.d.ts +0 -8
  75. package/dist/node/server/transformRequest.d.ts +0 -14
  76. package/dist/node/server/ws.d.ts +0 -11
  77. package/dist/node/ssr/ssrExternal.d.ts +0 -10
  78. package/dist/node/ssr/ssrManifestPlugin.d.ts +0 -3
  79. package/dist/node/ssr/ssrModuleLoader.d.ts +0 -8
  80. package/dist/node/ssr/ssrStacktrace.d.ts +0 -3
  81. package/dist/node/ssr/ssrTransform.d.ts +0 -8
  82. package/dist/node/utils.d.ts +0 -90
@@ -1 +0,0 @@
1
- export {};
@@ -1,193 +0,0 @@
1
- import { Plugin } from './plugin';
2
- import { BuildOptions } from './build';
3
- import { ResolvedServerOptions, ServerOptions } from './server';
4
- import { CSSOptions } from './plugins/css';
5
- import { ESBuildOptions } from './plugins/esbuild';
6
- import { Alias, AliasOptions } from 'types/alias';
7
- import { InternalResolveOptions, ResolveOptions } from './plugins/resolve';
8
- import { Logger, LogLevel } from './logger';
9
- import { DepOptimizationOptions } from './optimizer';
10
- import { ResolvedBuildOptions } from '.';
11
- import { JsonOptions } from './plugins/json';
12
- export interface ConfigEnv {
13
- command: 'build' | 'serve';
14
- mode: string;
15
- }
16
- export declare type UserConfigFn = (env: ConfigEnv) => UserConfig | Promise<UserConfig>;
17
- export declare type UserConfigExport = UserConfig | Promise<UserConfig> | UserConfigFn;
18
- /**
19
- * Type helper to make it easier to use vite.config.ts
20
- * accepts a direct {@link UserConfig} object, or a function that returns it.
21
- * The function receives a {@link ConfigEnv} object that exposes two properties:
22
- * `command` (either `'build'` or `'serve'`), and `mode`.
23
- */
24
- export declare function defineConfig(config: UserConfigExport): UserConfigExport;
25
- export declare type PluginOption = Plugin | false | null | undefined;
26
- export interface UserConfig {
27
- /**
28
- * Project root directory. Can be an absolute path, or a path relative from
29
- * the location of the config file itself.
30
- * @default process.cwd()
31
- */
32
- root?: string;
33
- /**
34
- * Base public path when served in development or production.
35
- * @default '/'
36
- */
37
- base?: string;
38
- /**
39
- * Directory to serve as plain static assets. Files in this directory are
40
- * served and copied to build dist dir as-is without transform. The value
41
- * can be either an absolute file system path or a path relative to <root>.
42
- *
43
- * Set to `false` or an empty string to disable copied static assets to build dist dir.
44
- * @default 'public'
45
- */
46
- publicDir?: string | false;
47
- /**
48
- * Directory to save cache files. Files in this directory are pre-bundled
49
- * deps or some other cache files that generated by vite, which can improve
50
- * the performance. You can use `--force` flag or manually delete the directory
51
- * to regenerate the cache files. The value can be either an absolute file
52
- * system path or a path relative to <root>.
53
- * @default 'node_modules/.vite'
54
- */
55
- cacheDir?: string;
56
- /**
57
- * Explicitly set a mode to run in. This will override the default mode for
58
- * each command, and can be overridden by the command line --mode option.
59
- */
60
- mode?: string;
61
- /**
62
- * Define global variable replacements.
63
- * Entries will be defined on `window` during dev and replaced during build.
64
- */
65
- define?: Record<string, any>;
66
- /**
67
- * Array of vite plugins to use.
68
- */
69
- plugins?: (PluginOption | PluginOption[])[];
70
- /**
71
- * Configure resolver
72
- */
73
- resolve?: ResolveOptions & {
74
- alias?: AliasOptions;
75
- };
76
- /**
77
- * CSS related options (preprocessors and CSS modules)
78
- */
79
- css?: CSSOptions;
80
- /**
81
- * JSON loading options
82
- */
83
- json?: JsonOptions;
84
- /**
85
- * Transform options to pass to esbuild.
86
- * Or set to `false` to disable esbuild.
87
- */
88
- esbuild?: ESBuildOptions | false;
89
- /**
90
- * Specify additional picomatch patterns to be treated as static assets.
91
- */
92
- assetsInclude?: string | RegExp | (string | RegExp)[];
93
- /**
94
- * Server specific options, e.g. host, port, https...
95
- */
96
- server?: ServerOptions;
97
- /**
98
- * Build specific options
99
- */
100
- build?: BuildOptions;
101
- /**
102
- * Dep optimization options
103
- */
104
- optimizeDeps?: DepOptimizationOptions;
105
- /**
106
- * SSR specific options
107
- * @alpha
108
- */
109
- ssr?: SSROptions;
110
- /**
111
- * Log level.
112
- * Default: 'info'
113
- */
114
- logLevel?: LogLevel;
115
- /**
116
- * Custom logger.
117
- */
118
- customLogger?: Logger;
119
- /**
120
- * Default: true
121
- */
122
- clearScreen?: boolean;
123
- /**
124
- * Environment files directory. Can be an absolute path, or a path relative from
125
- * the location of the config file itself.
126
- * @default root
127
- */
128
- envDir?: string;
129
- /**
130
- * Env variables starts with `envPrefix` will be exposed to your client source code via import.meta.env.
131
- * @default 'VITE_'
132
- */
133
- envPrefix?: string | string[];
134
- /**
135
- * Import aliases
136
- * @deprecated use `resolve.alias` instead
137
- */
138
- alias?: AliasOptions;
139
- /**
140
- * Force Vite to always resolve listed dependencies to the same copy (from
141
- * project root).
142
- * @deprecated use `resolve.dedupe` instead
143
- */
144
- dedupe?: string[];
145
- }
146
- export declare type SSRTarget = 'node' | 'webworker';
147
- export interface SSROptions {
148
- external?: string[];
149
- noExternal?: string | RegExp | (string | RegExp)[] | true;
150
- /**
151
- * Define the target for the ssr build. The browser field in package.json
152
- * is ignored for node but used if webworker is the target
153
- * Default: 'node'
154
- */
155
- target?: SSRTarget;
156
- }
157
- export interface InlineConfig extends UserConfig {
158
- configFile?: string | false;
159
- envFile?: false;
160
- }
161
- export declare type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'alias' | 'dedupe' | 'assetsInclude' | 'optimizeDeps'> & {
162
- configFile: string | undefined;
163
- configFileDependencies: string[];
164
- inlineConfig: InlineConfig;
165
- root: string;
166
- base: string;
167
- publicDir: string;
168
- command: 'build' | 'serve';
169
- mode: string;
170
- isProduction: boolean;
171
- env: Record<string, any>;
172
- resolve: ResolveOptions & {
173
- alias: Alias[];
174
- };
175
- plugins: readonly Plugin[];
176
- server: ResolvedServerOptions;
177
- build: ResolvedBuildOptions;
178
- assetsInclude: (file: string) => boolean;
179
- logger: Logger;
180
- createResolver: (options?: Partial<InternalResolveOptions>) => ResolveFn;
181
- optimizeDeps: Omit<DepOptimizationOptions, 'keepNames'>;
182
- }>;
183
- export declare type ResolveFn = (id: string, importer?: string, aliasOnly?: boolean, ssr?: boolean) => Promise<string | undefined>;
184
- export declare function resolveConfig(inlineConfig: InlineConfig, command: 'build' | 'serve', defaultMode?: string): Promise<ResolvedConfig>;
185
- export declare function mergeConfig(a: Record<string, any>, b: Record<string, any>, isRoot?: boolean): Record<string, any>;
186
- export declare function sortUserPlugins(plugins: (Plugin | Plugin[])[] | undefined): [Plugin[], Plugin[], Plugin[]];
187
- export declare function loadConfigFromFile(configEnv: ConfigEnv, configFile?: string, configRoot?: string, logLevel?: LogLevel): Promise<{
188
- path: string;
189
- config: UserConfig;
190
- dependencies: string[];
191
- } | null>;
192
- export declare function loadEnv(mode: string, envDir: string, prefixes?: string | string[]): Record<string, string>;
193
- export declare function resolveEnvPrefix({ envPrefix }: UserConfig): string[];
@@ -1,27 +0,0 @@
1
- export declare const DEFAULT_MAIN_FIELDS: string[];
2
- export declare const DEFAULT_EXTENSIONS: string[];
3
- export declare const JS_TYPES_RE: RegExp;
4
- export declare const OPTIMIZABLE_ENTRY_RE: RegExp;
5
- export declare const SPECIAL_QUERY_RE: RegExp;
6
- /**
7
- * Prefix for resolved fs paths, since windows paths may not be valid as URLs.
8
- */
9
- export declare const FS_PREFIX = "/@fs/";
10
- /**
11
- * Prefix for resolved Ids that are not valid browser import specifiers
12
- */
13
- export declare const VALID_ID_PREFIX = "/@id/";
14
- /**
15
- * Some Rollup plugins use ids that starts with the null byte \0 to avoid
16
- * collisions, but it is not permitted in import URLs so we have to replace
17
- * them.
18
- */
19
- export declare const NULL_BYTE_PLACEHOLDER = "__x00__";
20
- export declare const CLIENT_PUBLIC_PATH = "/@vite/client";
21
- export declare const ENV_PUBLIC_PATH = "/@vite/env";
22
- export declare const CLIENT_ENTRY: string;
23
- export declare const ENV_ENTRY: string;
24
- export declare const CLIENT_DIR: string;
25
- export declare const KNOWN_ASSET_TYPES: string[];
26
- export declare const DEFAULT_ASSETS_RE: RegExp;
27
- export declare const DEP_VERSION_RE: RegExp;
@@ -1,9 +0,0 @@
1
- export declare function transformImportGlob(source: string, pos: number, importer: string, importIndex: number, root: string, normalizeUrl?: (url: string, pos: number) => Promise<[string, string]>, preload?: boolean): Promise<{
2
- importsString: string;
3
- imports: string[];
4
- exp: string;
5
- endIndex: number;
6
- isEager: boolean;
7
- pattern: string;
8
- base: string;
9
- }>;
@@ -1,28 +0,0 @@
1
- import { RollupError } from 'rollup';
2
- import { Hostname } from './utils';
3
- export declare type LogType = 'error' | 'warn' | 'info';
4
- export declare type LogLevel = LogType | 'silent';
5
- export interface Logger {
6
- info(msg: string, options?: LogOptions): void;
7
- warn(msg: string, options?: LogOptions): void;
8
- warnOnce(msg: string, options?: LogOptions): void;
9
- error(msg: string, options?: LogErrorOptions): void;
10
- clearScreen(type: LogType): void;
11
- hasErrorLogged(error: Error | RollupError): boolean;
12
- hasWarned: boolean;
13
- }
14
- export interface LogOptions {
15
- clear?: boolean;
16
- timestamp?: boolean;
17
- }
18
- export interface LogErrorOptions extends LogOptions {
19
- error?: Error | RollupError | null;
20
- }
21
- export declare const LogLevels: Record<LogLevel, number>;
22
- export interface LoggerOptions {
23
- prefix?: string;
24
- allowClearScreen?: boolean;
25
- customLogger?: Logger;
26
- }
27
- export declare function createLogger(level?: LogLevel, options?: LoggerOptions): Logger;
28
- export declare function printServerUrls(hostname: Hostname, protocol: string, port: number, base: string, info: Logger['info']): void;
@@ -1,4 +0,0 @@
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;
@@ -1,66 +0,0 @@
1
- import { BuildOptions as EsbuildBuildOptions } from 'esbuild';
2
- import { ResolvedConfig } from '../config';
3
- import { ImportSpecifier } from 'es-module-lexer';
4
- export declare type ExportsData = [ImportSpecifier[], string[]] & {
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>;
@@ -1,2 +0,0 @@
1
- import { ViteDevServer } from '..';
2
- export declare function createMissingImporterRegisterFn(server: ViteDevServer): (id: string, resolved: string, ssr?: boolean) => void;
@@ -1,9 +0,0 @@
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;
@@ -1,110 +0,0 @@
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): Promise<ResolveIdResult> | ResolveIdResult;
108
- load?(this: PluginContext, id: string, ssr?: boolean): Promise<LoadResult> | LoadResult;
109
- transform?(this: TransformPluginContext, code: string, id: string, ssr?: boolean): Promise<TransformResult> | TransformResult;
110
- }
@@ -1,40 +0,0 @@
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>;
@@ -1,13 +0,0 @@
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 tempalte 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;
@@ -1,7 +0,0 @@
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;
@@ -1,68 +0,0 @@
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
- assetsInclude: (file: string) => boolean;
50
- logger: import("../logger").Logger;
51
- createResolver: (options?: Partial<import("./resolve").InternalResolveOptions> | undefined) => ResolveFn;
52
- optimizeDeps: Omit<import("../optimizer").DepOptimizationOptions, "keepNames">;
53
- }>, Map<string, RenderedChunk>>;
54
- /**
55
- * Plugin applied before user plugins
56
- */
57
- export declare function cssPlugin(config: ResolvedConfig): Plugin;
58
- /**
59
- * Plugin applied after user plugins
60
- */
61
- export declare function cssPostPlugin(config: ResolvedConfig): Plugin;
62
- export declare const cssUrlRE: RegExp;
63
- export interface StylePreprocessorResults {
64
- code: string;
65
- map?: object;
66
- errors: RollupError[];
67
- deps: string[];
68
- }
@@ -1,5 +0,0 @@
1
- import { Plugin } from '../plugin';
2
- /**
3
- * Build only, since importing from a data URI works natively.
4
- */
5
- export declare function dataURIPlugin(): Plugin;
@@ -1,3 +0,0 @@
1
- import { ResolvedConfig } from '../config';
2
- import { Plugin } from '../plugin';
3
- export declare function definePlugin(config: ResolvedConfig): Plugin;
@@ -1,15 +0,0 @@
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;