vite 6.0.0-alpha.7 → 6.0.0-alpha.8

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.
@@ -15161,6 +15161,7 @@ function terserPlugin(config) {
15161
15161
  async function resolveBoundedPlugins(environment) {
15162
15162
  const resolvedPlugins = [];
15163
15163
  for (const plugin of environment.config.plugins) {
15164
+ resolvedPlugins.push(plugin);
15164
15165
  if (plugin.create) {
15165
15166
  const boundedPlugin = await plugin.create(environment);
15166
15167
  if (boundedPlugin) {
@@ -15168,9 +15169,6 @@ async function resolveBoundedPlugins(environment) {
15168
15169
  resolvedPlugins.push(...flatPlugins);
15169
15170
  }
15170
15171
  }
15171
- else {
15172
- resolvedPlugins.push(plugin);
15173
- }
15174
15172
  }
15175
15173
  return resolvedPlugins;
15176
15174
  }
@@ -15735,12 +15733,10 @@ function assetPlugin(config) {
15735
15733
  return {
15736
15734
  name: 'vite:asset',
15737
15735
  buildStart() {
15738
- const { environment } = this;
15739
- if (!environment) {
15736
+ if (!this.environment)
15740
15737
  return;
15741
- }
15742
- assetCache.set(environment, new Map());
15743
- generatedAssetsMap.set(environment, new Map());
15738
+ assetCache.set(this.environment, new Map());
15739
+ generatedAssetsMap.set(this.environment, new Map());
15744
15740
  },
15745
15741
  resolveId(id) {
15746
15742
  if (!config.assetsInclude(cleanUrl(id)) && !urlRE.test(id)) {
@@ -16012,12 +16008,10 @@ function manifestPlugin() {
16012
16008
  outputCount = 0;
16013
16009
  },
16014
16010
  generateBundle({ format }, bundle) {
16015
- const { environment } = this;
16016
- if (!environment) {
16011
+ if (!this.environment)
16017
16012
  return;
16018
- }
16019
- const { root } = environment.config;
16020
- const buildOptions = environment.options.build;
16013
+ const { root } = this.environment.config;
16014
+ const buildOptions = this.environment.options.build;
16021
16015
  function getChunkName(chunk) {
16022
16016
  return getChunkOriginalFileName(chunk, root, format);
16023
16017
  }
@@ -16075,7 +16069,7 @@ function manifestPlugin() {
16075
16069
  return manifestChunk;
16076
16070
  }
16077
16071
  const fileNameToAssetMeta = new Map();
16078
- const assets = generatedAssetsMap.get(environment);
16072
+ const assets = generatedAssetsMap.get(this.environment);
16079
16073
  assets.forEach((asset, referenceId) => {
16080
16074
  try {
16081
16075
  const fileName = this.getFileName(referenceId);
@@ -58052,6 +58046,9 @@ function buildHtmlPlugin(config) {
58052
58046
  name: 'vite:build-html',
58053
58047
  async transform(html, id) {
58054
58048
  if (id.endsWith('.html')) {
58049
+ if (!this.environment)
58050
+ return;
58051
+ const { modulePreload } = this.environment.options.build;
58055
58052
  id = normalizePath$3(id);
58056
58053
  const relativeUrlPath = path$o.posix.relative(config.root, id);
58057
58054
  const publicPath = `/${relativeUrlPath}`;
@@ -58297,7 +58294,6 @@ function buildHtmlPlugin(config) {
58297
58294
  }
58298
58295
  processedHtml.set(id, s.toString());
58299
58296
  // inject module preload polyfill only when configured and needed
58300
- const { modulePreload } = config.build;
58301
58297
  if (modulePreload !== false &&
58302
58298
  modulePreload.polyfill &&
58303
58299
  (someScriptsAreAsync || someScriptsAreDefer)) {
@@ -58309,6 +58305,9 @@ function buildHtmlPlugin(config) {
58309
58305
  }
58310
58306
  },
58311
58307
  async generateBundle(options, bundle) {
58308
+ if (!this.environment)
58309
+ return;
58310
+ const { modulePreload } = this.environment.options.build;
58312
58311
  const analyzedChunk = new Map();
58313
58312
  const inlineEntryChunk = new Set();
58314
58313
  const getImportedChunks = (chunk, seen = new Set()) => {
@@ -58410,7 +58409,6 @@ function buildHtmlPlugin(config) {
58410
58409
  }
58411
58410
  else {
58412
58411
  assetTags = [toScriptTag(chunk, toOutputAssetFilePath, isAsync)];
58413
- const { modulePreload } = config.build;
58414
58412
  if (modulePreload !== false) {
58415
58413
  const resolveDependencies = typeof modulePreload === 'object' &&
58416
58414
  modulePreload.resolveDependencies;
@@ -62597,11 +62595,9 @@ function definePlugin(config) {
62597
62595
  return {
62598
62596
  name: 'vite:define',
62599
62597
  async transform(code, id) {
62600
- const { environment } = this;
62601
- if (!environment) {
62598
+ if (!this.environment)
62602
62599
  return;
62603
- }
62604
- if (environment.name === 'client' && !isBuild) {
62600
+ if (this.environment.name === 'client' && !isBuild) {
62605
62601
  // for dev we inject actual global defines in the vite client to
62606
62602
  // avoid the transform cost. see the `clientInjection` and
62607
62603
  // `importAnalysis` plugin.
@@ -62615,18 +62611,18 @@ function definePlugin(config) {
62615
62611
  config.assetsInclude(id)) {
62616
62612
  return;
62617
62613
  }
62618
- const [define, pattern] = getPattern(environment);
62614
+ const [define, pattern] = getPattern(this.environment);
62619
62615
  if (!pattern)
62620
62616
  return;
62621
62617
  // Check if our code needs any replacements before running esbuild
62622
62618
  pattern.lastIndex = 0;
62623
62619
  if (!pattern.test(code))
62624
62620
  return;
62625
- return await replaceDefine(code, id, define, config);
62621
+ return await replaceDefine(this.environment, code, id, define);
62626
62622
  },
62627
62623
  };
62628
62624
  }
62629
- async function replaceDefine(code, id, define, config) {
62625
+ async function replaceDefine(environment, code, id, define) {
62630
62626
  // Because esbuild only allows JSON-serializable values, and `import.meta.env`
62631
62627
  // may contain values with raw identifiers, making it non-JSON-serializable,
62632
62628
  // we replace it with a temporary marker and then replace it back after to
@@ -62639,14 +62635,16 @@ async function replaceDefine(code, id, define, config) {
62639
62635
  replacementMarkers[marker] = env;
62640
62636
  define = { ...define, 'import.meta.env': marker };
62641
62637
  }
62642
- const esbuildOptions = config.esbuild || {};
62638
+ const esbuildOptions = environment.config.esbuild || {};
62643
62639
  const result = await transform$1(code, {
62644
62640
  loader: 'js',
62645
62641
  charset: esbuildOptions.charset ?? 'utf8',
62646
62642
  platform: 'neutral',
62647
62643
  define,
62648
62644
  sourcefile: id,
62649
- sourcemap: config.command === 'build' ? !!config.build.sourcemap : true,
62645
+ sourcemap: environment.config.command === 'build'
62646
+ ? !!environment.options.build.sourcemap
62647
+ : true,
62650
62648
  });
62651
62649
  // remove esbuild's <define:...> source entries
62652
62650
  // since they would confuse source map remapping/collapsing which expects a single source
@@ -63263,12 +63261,11 @@ function importAnalysisPlugin(config) {
63263
63261
  }
63264
63262
  return {
63265
63263
  name: 'vite:import-analysis',
63266
- async transform(source, importer, options) {
63267
- const ssr = options?.ssr === true;
63268
- const environment = this.environment;
63269
- if (!environment) {
63264
+ async transform(source, importer) {
63265
+ if (!this.environment)
63270
63266
  return;
63271
- }
63267
+ const environment = this.environment;
63268
+ const ssr = environment.name !== 'client'; // TODO
63272
63269
  const moduleGraph = environment.moduleGraph;
63273
63270
  if (canSkipImportAnalysis(importer)) {
63274
63271
  debug$1?.(colors$1.dim(`[skipped] ${prettifyUrl(importer, root)}`));
@@ -63909,21 +63906,25 @@ function clientInjectionsPlugin(config) {
63909
63906
  .replace(`__HMR_CONFIG_NAME__`, hmrConfigNameReplacement);
63910
63907
  };
63911
63908
  },
63912
- async transform(code, id, options) {
63909
+ async transform(code, id) {
63910
+ if (!this.environment)
63911
+ return;
63912
+ // TODO: !environment.options.nodeCompatible ?
63913
+ const ssr = this.environment.name !== 'client';
63913
63914
  if (id === normalizedClientEntry || id === normalizedEnvEntry) {
63914
63915
  return injectConfigValues(code);
63915
63916
  }
63916
- else if (!options?.ssr && code.includes('process.env.NODE_ENV')) {
63917
+ else if (!ssr && code.includes('process.env.NODE_ENV')) {
63917
63918
  // replace process.env.NODE_ENV instead of defining a global
63918
63919
  // for it to avoid shimming a `process` object during dev,
63919
63920
  // avoiding inconsistencies between dev and build
63920
63921
  const nodeEnv = config.define?.['process.env.NODE_ENV'] ||
63921
63922
  JSON.stringify(process.env.NODE_ENV || config.mode);
63922
- return await replaceDefine(code, id, {
63923
+ return await replaceDefine(this.environment, code, id, {
63923
63924
  'process.env.NODE_ENV': nodeEnv,
63924
63925
  'global.process.env.NODE_ENV': nodeEnv,
63925
63926
  'globalThis.process.env.NODE_ENV': nodeEnv,
63926
- }, config);
63927
+ });
63927
63928
  }
63928
63929
  },
63929
63930
  };
@@ -65705,11 +65706,9 @@ function cssPostPlugin(config) {
65705
65706
  };
65706
65707
  },
65707
65708
  async renderChunk(code, chunk, opts) {
65708
- const { environment } = this;
65709
- if (!environment) {
65709
+ if (!this.environment)
65710
65710
  return;
65711
- }
65712
- const generatedAssets = generatedAssetsMap.get(environment);
65711
+ const generatedAssets = generatedAssetsMap.get(this.environment);
65713
65712
  let chunkCSS = '';
65714
65713
  let isPureCssChunk = true;
65715
65714
  const ids = Object.keys(chunk.modules);
@@ -67584,14 +67583,15 @@ function buildImportAnalysisPlugin(config) {
67584
67583
  return null;
67585
67584
  },
67586
67585
  generateBundle({ format }, bundle) {
67587
- const { environment } = this;
67588
- const ssr = environment?.options.build.ssr;
67589
- if (!environment || format !== 'es' || ssr || isWorker) {
67586
+ if (!this.environment)
67587
+ return;
67588
+ const ssr = this.environment.name !== 'client'; // TODO
67589
+ if (format !== 'es' || ssr || isWorker) {
67590
67590
  return;
67591
67591
  }
67592
- const buildSourcemap = environment.options.build.sourcemap;
67593
- const { modulePreload } = environment.options.build;
67594
- const { customModulePreloadPaths, optimizeModulePreloadRelativePaths } = getModulePreloadData(environment);
67592
+ const buildSourcemap = this.environment.options.build.sourcemap;
67593
+ const { modulePreload } = this.environment.options.build;
67594
+ const { customModulePreloadPaths, optimizeModulePreloadRelativePaths } = getModulePreloadData(this.environment);
67595
67595
  for (const file in bundle) {
67596
67596
  const chunk = bundle[file];
67597
67597
  // can't use chunk.dynamicImports.length here since some modules e.g.
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-o_W9DKGE.js').then(function (n) { return n.C; });
734
+ const { createServer } = await import('./chunks/dep-8PNdpITG.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-o_W9DKGE.js').then(function (n) { return n.E; });
815
+ const { createBuilder, buildEnvironment } = await import('./chunks/dep-8PNdpITG.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-o_W9DKGE.js').then(function (n) { return n.F; });
891
+ const { preview } = await import('./chunks/dep-8PNdpITG.js').then(function (n) { return n.F; });
892
892
  try {
893
893
  const server = await preview({
894
894
  root,
@@ -1,6 +1,6 @@
1
1
  export { parseAst, parseAstAsync } from 'rollup/parseAst';
2
- import { i as isInNodeModules, a as arraify } from './chunks/dep-o_W9DKGE.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-o_W9DKGE.js';
2
+ import { i as isInNodeModules, a as arraify } from './chunks/dep-8PNdpITG.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-8PNdpITG.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.7",
3
+ "version": "6.0.0-alpha.8",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",