vite 4.3.7 → 4.3.9

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.

@@ -1,4 +1,4 @@
1
- import { F as commonjsGlobal, E as getDefaultExportFromCjs } from './dep-1f986b87.js';
1
+ import { F as commonjsGlobal, E as getDefaultExportFromCjs } from './dep-e8f070e8.js';
2
2
  import require$$0__default from 'fs';
3
3
  import require$$0 from 'postcss';
4
4
  import require$$0$1 from 'path';
@@ -1,4 +1,4 @@
1
- import { E as getDefaultExportFromCjs } from './dep-1f986b87.js';
1
+ import { E as getDefaultExportFromCjs } from './dep-e8f070e8.js';
2
2
  import require$$0 from 'path';
3
3
  import require$$0__default from 'fs';
4
4
  import { l as lib } from './dep-c423598f.js';
@@ -28718,12 +28718,12 @@ function optimizedDepsBuildPlugin(config) {
28718
28718
  ...options,
28719
28719
  skipSelf: true,
28720
28720
  });
28721
- if (resolved) {
28721
+ if (resolved && !resolved.external) {
28722
28722
  depsOptimizer.delayDepsOptimizerUntil(resolved.id, async () => {
28723
28723
  await this.load(resolved);
28724
28724
  });
28725
- return resolved;
28726
28725
  }
28726
+ return resolved;
28727
28727
  }
28728
28728
  },
28729
28729
  async load(id) {
@@ -38206,10 +38206,9 @@ function cssPostPlugin(config) {
38206
38206
  `${style}.textContent = ${cssString};` +
38207
38207
  `document.head.appendChild(${style});`;
38208
38208
  const wrapIdx = code.indexOf('System.register');
38209
- const insertMark = "'use strict';";
38210
- const insertIdx = code.indexOf(insertMark, wrapIdx);
38209
+ const executeFnStart = code.indexOf('{', code.indexOf('execute:', wrapIdx)) + 1;
38211
38210
  const s = new MagicString(code);
38212
- s.appendLeft(insertIdx + insertMark.length, injectCode);
38211
+ s.appendRight(executeFnStart, injectCode);
38213
38212
  if (config.build.sourcemap) {
38214
38213
  // resolve public URL from CSS paths, we need to use absolute paths
38215
38214
  return {
@@ -38471,6 +38470,7 @@ async function compileCSS(id, code, config, urlReplacer) {
38471
38470
  return {
38472
38471
  code,
38473
38472
  map: preprocessorMap,
38473
+ deps,
38474
38474
  };
38475
38475
  }
38476
38476
  let postcssResult;
@@ -38572,8 +38572,8 @@ function createCachedImport(imp) {
38572
38572
  return cached;
38573
38573
  };
38574
38574
  }
38575
- const importPostcssImport = createCachedImport(() => import('./dep-7c975f20.js').then(function (n) { return n.i; }));
38576
- const importPostcssModules = createCachedImport(() => import('./dep-a6949a9d.js').then(function (n) { return n.i; }));
38575
+ const importPostcssImport = createCachedImport(() => import('./dep-93197d47.js').then(function (n) { return n.i; }));
38576
+ const importPostcssModules = createCachedImport(() => import('./dep-8124a809.js').then(function (n) { return n.i; }));
38577
38577
  const importPostcss = createCachedImport(() => import('postcss'));
38578
38578
  /**
38579
38579
  * @experimental
@@ -40453,9 +40453,9 @@ function importAnalysisPlugin(config) {
40453
40453
  // since we are already in the transform phase of the importer, it must
40454
40454
  // have been loaded so its entry is guaranteed in the module graph.
40455
40455
  const importerModule = moduleGraph.getModuleById(importer);
40456
- if (!importerModule && depsOptimizer?.isOptimizedDepFile(importer)) {
40457
- // Ids of optimized deps could be invalidated and removed from the graph
40458
- // Return without transforming, this request is no longer valid, a full reload
40456
+ if (!importerModule) {
40457
+ // When the server is restarted, the module graph is cleared, so we
40458
+ // return without transforming. This request is no longer valid, a full reload
40459
40459
  // is going to request this id again. Throwing an outdated error so we
40460
40460
  // properly finish the request with a 504 sent to the browser.
40461
40461
  throwOutdatedRequest(importer);
@@ -46065,7 +46065,7 @@ function serveStaticMiddleware(dir, server) {
46065
46065
  isInternalRequest(req.url)) {
46066
46066
  return next();
46067
46067
  }
46068
- const url = new URL(req.url, 'http://example.com');
46068
+ const url = new URL(req.url.replace(/^\/+/, '/'), 'http://example.com');
46069
46069
  const pathname = decodeURIComponent(url.pathname);
46070
46070
  // apply aliases to static requests as well
46071
46071
  let redirectedPathname;
@@ -46104,7 +46104,7 @@ function serveRawFsMiddleware(server) {
46104
46104
  const serveFromRoot = sirv('/', sirvOptions({ headers: server.config.server.headers }));
46105
46105
  // Keep the named function. The name is visible in debug logs via `DEBUG=connect:dispatcher ...`
46106
46106
  return function viteServeRawFsMiddleware(req, res, next) {
46107
- const url = new URL(req.url, 'http://example.com');
46107
+ const url = new URL(req.url.replace(/^\/+/, '/'), 'http://example.com');
46108
46108
  // In some cases (e.g. linked monorepos) files outside of root will
46109
46109
  // reference assets that are also out of served root. In such cases
46110
46110
  // the paths are rewritten to `/@fs/` prefixed paths and must be served by
@@ -54183,17 +54183,23 @@ function isInDestructuringAssignment(parent, parentStack) {
54183
54183
  }
54184
54184
 
54185
54185
  let offset;
54186
- try {
54187
- new Function('throw new Error(1)')();
54188
- }
54189
- catch (e) {
54190
- // in Node 12, stack traces account for the function wrapper.
54191
- // in Node 13 and later, the function wrapper adds two lines,
54192
- // which must be subtracted to generate a valid mapping
54193
- const match = /:(\d+):\d+\)$/.exec(e.stack.split('\n')[1]);
54194
- offset = match ? +match[1] - 1 : 0;
54186
+ function calculateOffsetOnce() {
54187
+ if (offset !== undefined) {
54188
+ return;
54189
+ }
54190
+ try {
54191
+ new Function('throw new Error(1)')();
54192
+ }
54193
+ catch (e) {
54194
+ // in Node 12, stack traces account for the function wrapper.
54195
+ // in Node 13 and later, the function wrapper adds two lines,
54196
+ // which must be subtracted to generate a valid mapping
54197
+ const match = /:(\d+):\d+\)$/.exec(e.stack.split('\n')[1]);
54198
+ offset = match ? +match[1] - 1 : 0;
54199
+ }
54195
54200
  }
54196
54201
  function ssrRewriteStacktrace(stack, moduleGraph) {
54202
+ calculateOffsetOnce();
54197
54203
  return stack
54198
54204
  .split('\n')
54199
54205
  .map((line) => {
@@ -61611,6 +61617,9 @@ function getHtmlFilename(url, server) {
61611
61617
  return decodeURIComponent(normalizePath$3(path$o.join(server.config.root, url.slice(1))));
61612
61618
  }
61613
61619
  }
61620
+ function shouldPreTransform(url, config) {
61621
+ return (!checkPublicFile(url, config) && (isJSRequest(url) || isCSSRequest(url)));
61622
+ }
61614
61623
  const processNodeUrl = (attr, sourceCodeLocation, s, config, htmlPath, originalUrl, server) => {
61615
61624
  let url = attr.value || '';
61616
61625
  if (server?.moduleGraph) {
@@ -61624,7 +61633,7 @@ const processNodeUrl = (attr, sourceCodeLocation, s, config, htmlPath, originalU
61624
61633
  // prefix with base (dev only, base is never relative)
61625
61634
  const fullUrl = path$o.posix.join(devBase, url);
61626
61635
  overwriteAttrValue(s, sourceCodeLocation, fullUrl);
61627
- if (server && !checkPublicFile(url, config)) {
61636
+ if (server && shouldPreTransform(url, config)) {
61628
61637
  preTransformRequest(server, fullUrl, devBase);
61629
61638
  }
61630
61639
  }
@@ -61635,7 +61644,7 @@ const processNodeUrl = (attr, sourceCodeLocation, s, config, htmlPath, originalU
61635
61644
  // prefix with base (dev only, base is never relative)
61636
61645
  const replacer = (url) => {
61637
61646
  const fullUrl = path$o.posix.join(devBase, url);
61638
- if (server && !checkPublicFile(url, config)) {
61647
+ if (server && shouldPreTransform(url, config)) {
61639
61648
  preTransformRequest(server, fullUrl, devBase);
61640
61649
  }
61641
61650
  return fullUrl;
@@ -63305,7 +63314,9 @@ async function _createServer(inlineConfig = {}, options) {
63305
63314
  if (isDepsOptimizerEnabled(config, true)) {
63306
63315
  await initDevSsrDepsOptimizer(config, server);
63307
63316
  }
63308
- await updateCjsSsrExternals(server);
63317
+ if (config.legacy?.buildSsrCjsExternalHeuristics) {
63318
+ await updateCjsSsrExternals(server);
63319
+ }
63309
63320
  return ssrLoadModule(url, server, undefined, undefined, opts?.fixStacktrace);
63310
63321
  },
63311
63322
  ssrFixStacktrace(e) {
@@ -63933,17 +63944,8 @@ var preview$1 = {
63933
63944
  function resolveSSROptions(ssr, preserveSymlinks, buildSsrCjsExternalHeuristics) {
63934
63945
  ssr ?? (ssr = {});
63935
63946
  const optimizeDeps = ssr.optimizeDeps ?? {};
63936
- let format = 'esm';
63937
- let target = 'node';
63938
- if (buildSsrCjsExternalHeuristics) {
63939
- if (ssr) {
63940
- format = 'cjs';
63941
- }
63942
- else {
63943
- target = 'node';
63944
- format = 'cjs';
63945
- }
63946
- }
63947
+ const format = buildSsrCjsExternalHeuristics ? 'cjs' : 'esm';
63948
+ const target = 'node';
63947
63949
  return {
63948
63950
  format,
63949
63951
  target,
@@ -64022,7 +64024,10 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development',
64022
64024
  // run config hooks
64023
64025
  const userPlugins = [...prePlugins, ...normalPlugins, ...postPlugins];
64024
64026
  config = await runConfigHook(config, userPlugins, configEnv);
64025
- if (process.env.VITE_TEST_WITHOUT_PLUGIN_COMMONJS) {
64027
+ // If there are custom commonjsOptions, don't force optimized deps for this test
64028
+ // even if the env var is set as it would interfere with the playground specs.
64029
+ if (!config.build?.commonjsOptions &&
64030
+ process.env.VITE_TEST_WITHOUT_PLUGIN_COMMONJS) {
64026
64031
  config = mergeConfig(config, {
64027
64032
  optimizeDeps: { disabled: false },
64028
64033
  ssr: { optimizeDeps: { disabled: false } },
package/dist/node/cli.js CHANGED
@@ -2,7 +2,7 @@ import path from 'node:path';
2
2
  import fs from 'node:fs';
3
3
  import { performance } from 'node:perf_hooks';
4
4
  import { EventEmitter } from 'events';
5
- import { C as colors, D as bindShortcuts, x as createLogger, h as resolveConfig } from './chunks/dep-1f986b87.js';
5
+ import { C as colors, D as bindShortcuts, x as createLogger, h as resolveConfig } from './chunks/dep-e8f070e8.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
@@ -728,7 +728,7 @@ cli
728
728
  filterDuplicateOptions(options);
729
729
  // output structure is preserved even after bundling so require()
730
730
  // is ok here
731
- const { createServer } = await import('./chunks/dep-1f986b87.js').then(function (n) { return n.I; });
731
+ const { createServer } = await import('./chunks/dep-e8f070e8.js').then(function (n) { return n.I; });
732
732
  try {
733
733
  const server = await createServer({
734
734
  root,
@@ -806,7 +806,7 @@ cli
806
806
  .option('-w, --watch', `[boolean] rebuilds when modules have changed on disk`)
807
807
  .action(async (root, options) => {
808
808
  filterDuplicateOptions(options);
809
- const { build } = await import('./chunks/dep-1f986b87.js').then(function (n) { return n.H; });
809
+ const { build } = await import('./chunks/dep-e8f070e8.js').then(function (n) { return n.H; });
810
810
  const buildOptions = cleanOptions(options);
811
811
  try {
812
812
  await build({
@@ -834,7 +834,7 @@ cli
834
834
  .option('--force', `[boolean] force the optimizer to ignore the cache and re-bundle`)
835
835
  .action(async (root, options) => {
836
836
  filterDuplicateOptions(options);
837
- const { optimizeDeps } = await import('./chunks/dep-1f986b87.js').then(function (n) { return n.G; });
837
+ const { optimizeDeps } = await import('./chunks/dep-e8f070e8.js').then(function (n) { return n.G; });
838
838
  try {
839
839
  const config = await resolveConfig({
840
840
  root,
@@ -860,7 +860,7 @@ cli
860
860
  .option('--outDir <dir>', `[string] output directory (default: dist)`)
861
861
  .action(async (root, options) => {
862
862
  filterDuplicateOptions(options);
863
- const { preview } = await import('./chunks/dep-1f986b87.js').then(function (n) { return n.J; });
863
+ const { preview } = await import('./chunks/dep-e8f070e8.js').then(function (n) { return n.J; });
864
864
  try {
865
865
  const server = await preview({
866
866
  root,
@@ -564,7 +564,7 @@ export declare interface DepOptimizationConfig {
564
564
  */
565
565
  exclude?: string[];
566
566
  /**
567
- * Force ESM interop when importing for these dependencies. Some legacy
567
+ * Forces ESM interop when importing these dependencies. Some legacy
568
568
  * packages advertise themselves as ESM but use `require` internally
569
569
  * @experimental
570
570
  */
@@ -1,5 +1,5 @@
1
- import { i as isInNodeModules } from './chunks/dep-1f986b87.js';
2
- export { b as build, e as buildErrorMessage, v as createFilter, x as createLogger, c as createServer, g as defineConfig, f as formatPostcssSourceMap, k as getDepOptimizationConfig, m as isDepsOptimizerEnabled, z as isFileServingAllowed, l as loadConfigFromFile, A as loadEnv, u as mergeAlias, q as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, j as resolveBaseUrl, h as resolveConfig, B as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, y as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-1f986b87.js';
1
+ import { i as isInNodeModules } from './chunks/dep-e8f070e8.js';
2
+ export { b as build, e as buildErrorMessage, v as createFilter, x as createLogger, c as createServer, g as defineConfig, f as formatPostcssSourceMap, k as getDepOptimizationConfig, m as isDepsOptimizerEnabled, z as isFileServingAllowed, l as loadConfigFromFile, A as loadEnv, u as mergeAlias, q as mergeConfig, n as normalizePath, o as optimizeDeps, a as preprocessCSS, p as preview, j as resolveBaseUrl, h as resolveConfig, B as resolveEnvPrefix, d as resolvePackageData, r as resolvePackageEntry, y as searchForWorkspaceRoot, w as send, s as sortUserPlugins, t as transformWithEsbuild } from './chunks/dep-e8f070e8.js';
3
3
  export { VERSION as version } from './constants.js';
4
4
  export { version as esbuildVersion } from 'esbuild';
5
5
  export { VERSION as rollupVersion } from 'rollup';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite",
3
- "version": "4.3.7",
3
+ "version": "4.3.9",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Evan You",