vite 6.0.0-alpha.4 → 6.0.0-alpha.5

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.
@@ -15158,6 +15158,34 @@ function terserPlugin(config) {
15158
15158
  };
15159
15159
  }
15160
15160
 
15161
+ async function resolveBoundedPlugins(environment) {
15162
+ const resolvedPlugins = [];
15163
+ for (const plugin of environment.config.plugins) {
15164
+ if (plugin.create) {
15165
+ const boundedPlugin = await plugin.create(environment);
15166
+ if (boundedPlugin) {
15167
+ const flatPlugins = await asyncFlattenBoundedPlugin(environment, boundedPlugin);
15168
+ resolvedPlugins.push(...flatPlugins);
15169
+ }
15170
+ }
15171
+ else {
15172
+ resolvedPlugins.push(plugin);
15173
+ }
15174
+ }
15175
+ return resolvedPlugins;
15176
+ }
15177
+ async function asyncFlattenBoundedPlugin(environment, plugins) {
15178
+ if (!Array.isArray(plugins)) {
15179
+ plugins = [plugins];
15180
+ }
15181
+ do {
15182
+ plugins = (await Promise.all(plugins.map((p) => (p && p.split ? p.split(environment) : p))))
15183
+ .flat(Infinity)
15184
+ .filter(Boolean);
15185
+ } while (plugins.some((v) => v?.then || v?.split));
15186
+ return plugins;
15187
+ }
15188
+
15161
15189
  const mimes = {
15162
15190
  "3g2": "video/3gpp2",
15163
15191
  "3gp": "video/3gpp",
@@ -36429,34 +36457,6 @@ function esbuildCjsExternalPlugin(externals, platform) {
36429
36457
  };
36430
36458
  }
36431
36459
 
36432
- async function resolveBoundedPlugins(environment) {
36433
- const resolvedPlugins = [];
36434
- for (const plugin of environment.config.plugins) {
36435
- if (plugin.create) {
36436
- const boundedPlugin = await plugin.create(environment);
36437
- if (boundedPlugin) {
36438
- const flatPlugins = await asyncFlattenBoundedPlugin(environment, boundedPlugin);
36439
- resolvedPlugins.push(...flatPlugins);
36440
- }
36441
- }
36442
- else {
36443
- resolvedPlugins.push(plugin);
36444
- }
36445
- }
36446
- return resolvedPlugins;
36447
- }
36448
- async function asyncFlattenBoundedPlugin(environment, plugins) {
36449
- if (!Array.isArray(plugins)) {
36450
- plugins = [plugins];
36451
- }
36452
- do {
36453
- plugins = (await Promise.all(plugins.map((p) => (p && p.split ? p.split(environment) : p))))
36454
- .flat(Infinity)
36455
- .filter(Boolean);
36456
- } while (plugins.some((v) => v?.then || v?.split));
36457
- return plugins;
36458
- }
36459
-
36460
36460
  // Copyright 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 Simon Lydell
36461
36461
  // License: MIT.
36462
36462
  var HashbangComment, Identifier, JSXIdentifier, JSXPunctuator, JSXString, JSXText, KeywordsWithExpressionAfter, KeywordsWithNoLineTerminatorAfter, LineTerminatorSequence, MultiLineComment, Newline, NumericLiteral, Punctuator, RegularExpressionLiteral, SingleLineComment, StringLiteral, Template, TokensNotPrecedingObjectLiteral, TokensPrecedingExpression, WhiteSpace;
@@ -68056,9 +68056,8 @@ async function buildEnvironment(config, environment, libOptions = false) {
68056
68056
  }
68057
68057
  const outDir = resolve(options.outDir);
68058
68058
  // inject environment and ssr arg to plugin load/transform hooks
68059
- const plugins = (environment || ssr
68060
- ? config.plugins.map((p) => injectEnvironmentToHooks(p, environment))
68061
- : config.plugins);
68059
+ // TODO: rework lib mode
68060
+ const plugins = (libOptions ? config : environment).plugins.map((p) => injectEnvironmentToHooks(p, environment));
68062
68061
  const rollupOptions = {
68063
68062
  preserveEntrySignatures: ssr
68064
68063
  ? 'allow-extension'
@@ -68580,6 +68579,13 @@ class BuildEnvironment extends Environment {
68580
68579
  }
68581
68580
  super(name, config, options);
68582
68581
  }
68582
+ async init() {
68583
+ if (this._inited) {
68584
+ return;
68585
+ }
68586
+ this._inited = true;
68587
+ this._plugins = await resolveBoundedPlugins(this);
68588
+ }
68583
68589
  }
68584
68590
  async function defaultBuildApp(builder) {
68585
68591
  for (const environment of Object.values(builder.environments)) {
@@ -68648,6 +68654,7 @@ async function createBuilder(inlineConfig = {}) {
68648
68654
  environmentConfig = await resolveConfigToBuild(inlineConfig, patchConfig);
68649
68655
  }
68650
68656
  const environment = await createEnvironment(name, environmentConfig);
68657
+ await environment.init();
68651
68658
  environments[name] = environment;
68652
68659
  }
68653
68660
  return builder;
package/dist/node/cli.js CHANGED
@@ -731,7 +731,7 @@ cli
731
731
  filterDuplicateOptions(options);
732
732
  // output structure is preserved even after bundling so require()
733
733
  // is ok here
734
- const { createServer } = await import('./chunks/dep-8UjKy9Ch.js').then(function (n) { return n.C; });
734
+ const { createServer } = await import('./chunks/dep-yyboeDiN.js').then(function (n) { return n.C; });
735
735
  try {
736
736
  const server = await createServer({
737
737
  root,
@@ -812,7 +812,7 @@ cli
812
812
  .option('--app', `[boolean] same as builder.entireApp`)
813
813
  .action(async (root, options) => {
814
814
  filterDuplicateOptions(options);
815
- const { createBuilder, buildEnvironment } = await import('./chunks/dep-8UjKy9Ch.js').then(function (n) { return n.E; });
815
+ const { createBuilder, buildEnvironment } = await import('./chunks/dep-yyboeDiN.js').then(function (n) { return n.E; });
816
816
  const buildOptions = cleanGlobalCLIOptions(cleanBuilderCLIOptions(options));
817
817
  const config = {
818
818
  root,
@@ -888,7 +888,7 @@ cli
888
888
  .option('--outDir <dir>', `[string] output directory (default: dist)`)
889
889
  .action(async (root, options) => {
890
890
  filterDuplicateOptions(options);
891
- const { preview } = await import('./chunks/dep-8UjKy9Ch.js').then(function (n) { return n.F; });
891
+ const { preview } = await import('./chunks/dep-yyboeDiN.js').then(function (n) { return n.F; });
892
892
  try {
893
893
  const server = await preview({
894
894
  root,
@@ -2932,6 +2932,7 @@ declare class BuildEnvironment extends Environment {
2932
2932
  constructor(name: string, config: ResolvedConfig, setup?: {
2933
2933
  options?: EnvironmentOptions;
2934
2934
  });
2935
+ init(): Promise<void>;
2935
2936
  }
2936
2937
  interface ViteBuilder {
2937
2938
  environments: Record<string, BuildEnvironment>;
@@ -1,6 +1,6 @@
1
1
  export { parseAst, parseAstAsync } from 'rollup/parseAst';
2
- import { i as isInNodeModules, a as arraify } from './chunks/dep-8UjKy9Ch.js';
3
- export { B as BuildEnvironment, D as DevEnvironment, S as ServerHMRConnector, b as build, h as buildErrorMessage, e as createBuilder, u as createFilter, j as createNodeDevEnvironment, c as createServer, m as createServerModuleRunner, d as defineConfig, k as fetchModule, f as formatPostcssSourceMap, y as isFileServingAllowed, l as loadConfigFromFile, z as loadEnv, q as mergeAlias, o as mergeConfig, n as normalizePath, g as preprocessCSS, p as preview, r as resolveConfig, A as resolveEnvPrefix, v as rollupVersion, x as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-8UjKy9Ch.js';
2
+ import { i as isInNodeModules, a as arraify } from './chunks/dep-yyboeDiN.js';
3
+ export { B as BuildEnvironment, D as DevEnvironment, S as ServerHMRConnector, b as build, h as buildErrorMessage, e as createBuilder, u as createFilter, j as createNodeDevEnvironment, c as createServer, m as createServerModuleRunner, d as defineConfig, k as fetchModule, f as formatPostcssSourceMap, y as isFileServingAllowed, l as loadConfigFromFile, z as loadEnv, q as mergeAlias, o as mergeConfig, n as normalizePath, g as preprocessCSS, p as preview, r as resolveConfig, A as resolveEnvPrefix, v as rollupVersion, x as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-yyboeDiN.js';
4
4
  export { VERSION as version } from './constants.js';
5
5
  export { version as esbuildVersion } from 'esbuild';
6
6
  export { c as createLogger } from './chunks/dep-C7zR1Rh8.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "6.0.0-alpha.4",
3
+ "version": "6.0.0-alpha.5",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",