vite 2.7.0-beta.4 → 2.7.0-beta.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.

Potentially problematic release.


This version of vite might be problematic. Click here for more details.

@@ -20385,7 +20385,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
20385
20385
  replacer: urlReplacer
20386
20386
  }));
20387
20387
  if (isModule) {
20388
- postcssPlugins.unshift((await Promise.resolve().then(function () { return require('./dep-9583e954.js'); }).then(function (n) { return n.index; })).default({
20388
+ postcssPlugins.unshift((await Promise.resolve().then(function () { return require('./dep-0a2fa784.js'); }).then(function (n) { return n.index; })).default({
20389
20389
  ...modulesOptions,
20390
20390
  getJSON(cssFileName, _modules, outputFileName) {
20391
20391
  modules = _modules;
@@ -21350,7 +21350,7 @@ const assetAttrsConfig = {
21350
21350
  const isAsyncScriptMap = new WeakMap();
21351
21351
  async function traverseHtml(html, filePath, visitor) {
21352
21352
  // lazy load compiler
21353
- const { parse, transform } = await Promise.resolve().then(function () { return require('./dep-ef63fa34.js'); }).then(function (n) { return n.compilerDom_cjs; });
21353
+ const { parse, transform } = await Promise.resolve().then(function () { return require('./dep-bc61ebc7.js'); }).then(function (n) { return n.compilerDom_cjs; });
21354
21354
  // @vue/compiler-core doesn't like lowercase doctypes
21355
21355
  html = html.replace(/<!doctype\s/i, '<!DOCTYPE ');
21356
21356
  try {
@@ -30183,11 +30183,28 @@ function tryNodeResolve(id, importer, options, targetWeb, server, ssr) {
30183
30183
  const lastArrowIndex = id.lastIndexOf('>');
30184
30184
  const nestedRoot = id.substring(0, lastArrowIndex).trim();
30185
30185
  const nestedPath = id.substring(lastArrowIndex + 1).trim();
30186
- // check for deep import, e.g. "my-lib/foo"
30187
- const deepMatch = nestedPath.match(deepImportRE);
30188
- const pkgId = deepMatch ? deepMatch[1] || deepMatch[2] : nestedPath;
30186
+ const possiblePkgIds = [];
30187
+ for (let prevSlashIndex = -1;;) {
30188
+ let slashIndex = nestedPath.indexOf('/', prevSlashIndex + 1);
30189
+ if (slashIndex < 0) {
30190
+ slashIndex = nestedPath.length;
30191
+ }
30192
+ const part = nestedPath.slice(prevSlashIndex + 1, (prevSlashIndex = slashIndex));
30193
+ if (!part) {
30194
+ break;
30195
+ }
30196
+ // Assume path parts with an extension are not package roots, except for the
30197
+ // first path part (since periods are sadly allowed in package names).
30198
+ // At the same time, skip the first path part if it begins with "@"
30199
+ // (since "@foo/bar" should be treated as the top-level path).
30200
+ if (possiblePkgIds.length ? path__default.extname(part) : part[0] === '@') {
30201
+ continue;
30202
+ }
30203
+ const possiblePkgId = nestedPath.slice(0, slashIndex);
30204
+ possiblePkgIds.push(possiblePkgId);
30205
+ }
30189
30206
  let basedir;
30190
- if (dedupe && dedupe.includes(pkgId)) {
30207
+ if (dedupe === null || dedupe === void 0 ? void 0 : dedupe.some((id) => possiblePkgIds.includes(id))) {
30191
30208
  basedir = root;
30192
30209
  }
30193
30210
  else if (importer &&
@@ -30202,13 +30219,17 @@ function tryNodeResolve(id, importer, options, targetWeb, server, ssr) {
30202
30219
  if (nestedRoot) {
30203
30220
  basedir = nestedResolveFrom(nestedRoot, basedir, options.preserveSymlinks);
30204
30221
  }
30205
- const pkg = resolvePackageData(pkgId, basedir, options.preserveSymlinks);
30222
+ let pkg;
30223
+ const pkgId = possiblePkgIds.reverse().find((pkgId) => {
30224
+ pkg = resolvePackageData(pkgId, basedir, options.preserveSymlinks);
30225
+ return pkg;
30226
+ });
30206
30227
  if (!pkg) {
30207
30228
  return;
30208
30229
  }
30209
- let resolved = deepMatch
30210
- ? resolveDeepImport('.' + id.slice(pkgId.length), pkg, options, targetWeb, options.preserveSymlinks)
30211
- : resolvePackageEntry(id, pkg, options, targetWeb, options.preserveSymlinks);
30230
+ let resolved = nestedPath !== pkgId
30231
+ ? resolveDeepImport('.' + nestedPath.slice(pkgId.length), pkg, options, targetWeb, options.preserveSymlinks)
30232
+ : resolvePackageEntry(nestedPath, pkg, options, targetWeb, options.preserveSymlinks);
30212
30233
  if (!resolved) {
30213
30234
  return;
30214
30235
  }
@@ -30235,7 +30256,7 @@ function tryNodeResolve(id, importer, options, targetWeb, server, ssr) {
30235
30256
  if (!isJsType ||
30236
30257
  (importer === null || importer === void 0 ? void 0 : importer.includes('node_modules')) ||
30237
30258
  (exclude === null || exclude === void 0 ? void 0 : exclude.includes(pkgId)) ||
30238
- (exclude === null || exclude === void 0 ? void 0 : exclude.includes(id)) ||
30259
+ (exclude === null || exclude === void 0 ? void 0 : exclude.includes(nestedPath)) ||
30239
30260
  SPECIAL_QUERY_RE.test(resolved) ||
30240
30261
  ssr) {
30241
30262
  // excluded from optimization
@@ -42783,7 +42804,7 @@ function esbuildScanPlugin(config, container, depImports, missing, entries) {
42783
42804
  }));
42784
42805
  build.onResolve({ filter: virtualModuleRE }, async ({ path, importer }) => {
42785
42806
  return {
42786
- path,
42807
+ path: await resolve(path.substring('virtual-module:'.length), importer),
42787
42808
  namespace: 'html'
42788
42809
  };
42789
42810
  });
@@ -49325,7 +49346,7 @@ function readFileIfExists(value) {
49325
49346
  * https://github.com/webpack/webpack-dev-server/blob/master/LICENSE
49326
49347
  */
49327
49348
  async function createCertificate() {
49328
- const { generate } = await Promise.resolve().then(function () { return require('./dep-90234190.js'); }).then(function (n) { return n.index; });
49349
+ const { generate } = await Promise.resolve().then(function () { return require('./dep-732fded6.js'); }).then(function (n) { return n.index; });
49329
49350
  const pems = generate(null, {
49330
49351
  algorithm: 'sha256',
49331
49352
  days: 30,
@@ -67053,18 +67074,27 @@ async function instantiateModule(url, server, context = { global }, urlStack = [
67053
67074
  urlStack = urlStack.concat(url);
67054
67075
  const isCircular = (url) => urlStack.includes(url);
67055
67076
  const { isProduction, resolve: { dedupe }, root } = server.config;
67077
+ // The `extensions` and `mainFields` options are used to ensure that
67078
+ // CommonJS modules are preferred. We want to avoid ESM->ESM imports
67079
+ // whenever possible, because `hookNodeResolve` can't intercept them.
67056
67080
  const resolveOptions = {
67057
- conditions: ['node'],
67081
+ // By adding "require" to the `conditions` array, resolution of the
67082
+ // pkg.exports field will use "require" condition whenever it comes
67083
+ // before "import" condition.
67084
+ conditions: ['node', 'require'],
67058
67085
  dedupe,
67059
- // Prefer CommonJS modules.
67060
- extensions: ['.js', '.mjs', '.ts', '.jsx', '.tsx', '.json'],
67086
+ extensions: ['.js', '.cjs', '.mjs', '.jsx', '.json'],
67061
67087
  isBuild: true,
67062
67088
  isProduction,
67063
- // Disable "module" condition.
67064
- isRequire: true,
67065
- mainFields: ['main'],
67089
+ mainFields: ['main', ...DEFAULT_MAIN_FIELDS],
67066
67090
  root
67067
67091
  };
67092
+ // Prevent ESM modules from being resolved during test runs, since Jest
67093
+ // cannot `require` them. Note: This prevents testing of ESM-only packages.
67094
+ if (typeof jest !== 'undefined') {
67095
+ resolveOptions.isRequire = true;
67096
+ resolveOptions.mainFields = ['main'];
67097
+ }
67068
67098
  // Since dynamic imports can happen in parallel, we need to
67069
67099
  // account for multiple pending deps and duplicate imports.
67070
67100
  const pendingDeps = [];
@@ -67144,9 +67174,15 @@ async function nodeImport(id, importer, resolveOptions) {
67144
67174
  return resolved.id;
67145
67175
  };
67146
67176
  // When an ESM module imports an ESM dependency, this hook is *not* used.
67147
- const unhookNodeResolve = hookNodeResolve((nodeResolve) => (id, parent, isMain, options) => id[0] === '.' || isBuiltin(id)
67148
- ? nodeResolve(id, parent, isMain, options)
67149
- : viteResolve(id, parent.id));
67177
+ const unhookNodeResolve = hookNodeResolve((nodeResolve) => (id, parent, isMain, options) => {
67178
+ if (id[0] === '.' || isBuiltin(id)) {
67179
+ return nodeResolve(id, parent, isMain, options);
67180
+ }
67181
+ if (!parent) {
67182
+ return id;
67183
+ }
67184
+ return viteResolve(id, parent.id);
67185
+ });
67150
67186
  let url;
67151
67187
  // `resolve` doesn't handle `node:` builtins, so handle them directly
67152
67188
  if (id.startsWith('node:') || isBuiltin(id)) {
@@ -82168,4 +82204,4 @@ exports.send = send$1;
82168
82204
  exports.sortUserPlugins = sortUserPlugins;
82169
82205
  exports.source = source;
82170
82206
  exports.transformWithEsbuild = transformWithEsbuild;
82171
- //# sourceMappingURL=dep-6cab8e8a.js.map
82207
+ //# sourceMappingURL=dep-6920cd01.js.map