vite 2.7.8 → 2.7.12

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.

@@ -20397,7 +20397,7 @@ async function compileCSS(id, code, config, urlReplacer, atImportResolvers, serv
20397
20397
  replacer: urlReplacer
20398
20398
  }));
20399
20399
  if (isModule) {
20400
- postcssPlugins.unshift((await Promise.resolve().then(function () { return require('./dep-245e2712.js'); }).then(function (n) { return n.index; })).default({
20400
+ postcssPlugins.unshift((await Promise.resolve().then(function () { return require('./dep-73d734ac.js'); }).then(function (n) { return n.index; })).default({
20401
20401
  ...modulesOptions,
20402
20402
  getJSON(cssFileName, _modules, outputFileName) {
20403
20403
  modules = _modules;
@@ -21402,7 +21402,7 @@ const assetAttrsConfig = {
21402
21402
  const isAsyncScriptMap = new WeakMap();
21403
21403
  async function traverseHtml(html, filePath, visitor) {
21404
21404
  // lazy load compiler
21405
- const { parse, transform } = await Promise.resolve().then(function () { return require('./dep-2d04f1e8.js'); }).then(function (n) { return n.compilerDom_cjs; });
21405
+ const { parse, transform } = await Promise.resolve().then(function () { return require('./dep-d7204208.js'); }).then(function (n) { return n.compilerDom_cjs; });
21406
21406
  // @vue/compiler-core doesn't like lowercase doctypes
21407
21407
  html = html.replace(/<!doctype\s/i, '<!DOCTYPE ');
21408
21408
  try {
@@ -37840,13 +37840,10 @@ function getPkgName(root) {
37840
37840
  function createMoveToVendorChunkFn(config) {
37841
37841
  const cache = new Map();
37842
37842
  return (id, { getModuleInfo }) => {
37843
- if (id.includes('node_modules') && !isCSSRequest(id)) {
37844
- if (staticImportedByEntry(id, getModuleInfo, cache)) {
37845
- return 'vendor';
37846
- }
37847
- else {
37848
- return 'async-vendor';
37849
- }
37843
+ if (id.includes('node_modules') &&
37844
+ !isCSSRequest(id) &&
37845
+ staticImportedByEntry(id, getModuleInfo, cache)) {
37846
+ return 'vendor';
37850
37847
  }
37851
37848
  };
37852
37849
  }
@@ -43722,7 +43719,7 @@ function readFileIfExists(value) {
43722
43719
  * https://github.com/webpack/webpack-dev-server/blob/master/LICENSE
43723
43720
  */
43724
43721
  async function createCertificate() {
43725
- const { generate } = await Promise.resolve().then(function () { return require('./dep-21eb5f0a.js'); }).then(function (n) { return n.index; });
43722
+ const { generate } = await Promise.resolve().then(function () { return require('./dep-374a3cfd.js'); }).then(function (n) { return n.index; });
43726
43723
  const pems = generate(null, {
43727
43724
  algorithm: 'sha256',
43728
43725
  days: 30,
@@ -50946,6 +50943,37 @@ function walk(root, { onIdentifier, onImportMeta, onDynamicImport }) {
50946
50943
  function isInScope(name, parents) {
50947
50944
  return parents.some((node) => { var _a; return node && ((_a = scopeMap.get(node)) === null || _a === void 0 ? void 0 : _a.has(name)); });
50948
50945
  }
50946
+ function handlePattern(p, parentFunction) {
50947
+ if (p.type === 'Identifier') {
50948
+ setScope(parentFunction, p.name);
50949
+ }
50950
+ else if (p.type === 'RestElement') {
50951
+ handlePattern(p.argument, parentFunction);
50952
+ }
50953
+ else if (p.type === 'ObjectPattern') {
50954
+ p.properties.forEach((property) => {
50955
+ if (property.type === 'RestElement') {
50956
+ setScope(parentFunction, property.argument.name);
50957
+ }
50958
+ else {
50959
+ handlePattern(property.value, parentFunction);
50960
+ }
50961
+ });
50962
+ }
50963
+ else if (p.type === 'ArrayPattern') {
50964
+ p.elements.forEach((element) => {
50965
+ if (element) {
50966
+ handlePattern(element, parentFunction);
50967
+ }
50968
+ });
50969
+ }
50970
+ else if (p.type === 'AssignmentPattern') {
50971
+ handlePattern(p.left, parentFunction);
50972
+ }
50973
+ else {
50974
+ setScope(parentFunction, p.name);
50975
+ }
50976
+ }
50949
50977
  walk$1(root, {
50950
50978
  enter(node, parent) {
50951
50979
  if (node.type === 'ImportDeclaration') {
@@ -50976,25 +51004,31 @@ function walk(root, { onIdentifier, onImportMeta, onDynamicImport }) {
50976
51004
  }
50977
51005
  // walk function expressions and add its arguments to known identifiers
50978
51006
  // so that we don't prefix them
50979
- node.params.forEach((p) => walk$1(p.type === 'AssignmentPattern' ? p.left : p, {
50980
- enter(child, parent) {
50981
- if (child.type !== 'Identifier')
50982
- return;
50983
- // do not record as scope variable if is a destructuring keyword
50984
- if (isStaticPropertyKey(child, parent))
50985
- return;
50986
- // do not record if this is a default value
50987
- // assignment of a destructuring variable
50988
- if (((parent === null || parent === void 0 ? void 0 : parent.type) === 'AssignmentPattern' &&
50989
- (parent === null || parent === void 0 ? void 0 : parent.right) === child) ||
50990
- ((parent === null || parent === void 0 ? void 0 : parent.type) === 'TemplateLiteral' &&
50991
- (parent === null || parent === void 0 ? void 0 : parent.expressions.includes(child))) ||
50992
- ((parent === null || parent === void 0 ? void 0 : parent.type) === 'CallExpression' && (parent === null || parent === void 0 ? void 0 : parent.callee) === child)) {
50993
- return;
50994
- }
50995
- setScope(node, child.name);
51007
+ node.params.forEach((p) => {
51008
+ if (p.type === 'ObjectPattern' || p.type === 'ArrayPattern') {
51009
+ handlePattern(p, node);
51010
+ return;
50996
51011
  }
50997
- }));
51012
+ walk$1(p.type === 'AssignmentPattern' ? p.left : p, {
51013
+ enter(child, parent) {
51014
+ if (child.type !== 'Identifier')
51015
+ return;
51016
+ // do not record as scope variable if is a destructuring keyword
51017
+ if (isStaticPropertyKey(child, parent))
51018
+ return;
51019
+ // do not record if this is a default value
51020
+ // assignment of a destructuring variable
51021
+ if (((parent === null || parent === void 0 ? void 0 : parent.type) === 'AssignmentPattern' &&
51022
+ (parent === null || parent === void 0 ? void 0 : parent.right) === child) ||
51023
+ ((parent === null || parent === void 0 ? void 0 : parent.type) === 'TemplateLiteral' &&
51024
+ (parent === null || parent === void 0 ? void 0 : parent.expressions.includes(child))) ||
51025
+ ((parent === null || parent === void 0 ? void 0 : parent.type) === 'CallExpression' && (parent === null || parent === void 0 ? void 0 : parent.callee) === child)) {
51026
+ return;
51027
+ }
51028
+ setScope(node, child.name);
51029
+ }
51030
+ });
51031
+ });
50998
51032
  }
50999
51033
  else if (node.type === 'Property' && parent.type === 'ObjectPattern') {
51000
51034
  node.inPattern = true;
@@ -51002,36 +51036,7 @@ function walk(root, { onIdentifier, onImportMeta, onDynamicImport }) {
51002
51036
  else if (node.type === 'VariableDeclarator') {
51003
51037
  const parentFunction = findParentFunction(parentStack);
51004
51038
  if (parentFunction) {
51005
- const handlePattern = (p) => {
51006
- if (p.type === 'Identifier') {
51007
- setScope(parentFunction, p.name);
51008
- }
51009
- else if (p.type === 'RestElement') {
51010
- handlePattern(p.argument);
51011
- }
51012
- else if (p.type === 'ObjectPattern') {
51013
- p.properties.forEach((property) => {
51014
- if (property.type === 'RestElement') {
51015
- setScope(parentFunction, property.argument.name);
51016
- }
51017
- else
51018
- handlePattern(property.value);
51019
- });
51020
- }
51021
- else if (p.type === 'ArrayPattern') {
51022
- p.elements.forEach((element) => {
51023
- if (element)
51024
- handlePattern(element);
51025
- });
51026
- }
51027
- else if (p.type === 'AssignmentPattern') {
51028
- handlePattern(p.left);
51029
- }
51030
- else {
51031
- setScope(parentFunction, p.name);
51032
- }
51033
- };
51034
- handlePattern(node.id);
51039
+ handlePattern(node.id, parentFunction);
51035
51040
  }
51036
51041
  }
51037
51042
  },
@@ -59943,7 +59948,8 @@ function ssrRequireHookPlugin(config) {
59943
59948
  return {
59944
59949
  code: s.toString(),
59945
59950
  map: s.generateMap({
59946
- source: id
59951
+ source: id,
59952
+ hires: true
59947
59953
  })
59948
59954
  };
59949
59955
  }
@@ -60641,7 +60647,10 @@ function resolvedAllowDir(root, dir) {
60641
60647
  }
60642
60648
  function resolveServerOptions(root, raw) {
60643
60649
  var _a, _b, _c, _d;
60644
- const server = raw || {};
60650
+ const server = {
60651
+ preTransformRequests: true,
60652
+ ...raw
60653
+ };
60645
60654
  let allowDirs = (_a = server.fs) === null || _a === void 0 ? void 0 : _a.allow;
60646
60655
  const deny = ((_b = server.fs) === null || _b === void 0 ? void 0 : _b.deny) || ['.env', '.env.*', '*.{crt,pem}'];
60647
60656
  if (!allowDirs) {
@@ -73943,7 +73952,7 @@ function importAnalysisPlugin(config) {
73943
73952
  isDebug &&
73944
73953
  debug$1(`${timeFrom(start)} ${source.dim(`[${importedUrls.size} imports rewritten] ${prettyImporter}`)}`);
73945
73954
  // pre-transform known direct imports
73946
- if (staticImportedUrls.size) {
73955
+ if (config.server.preTransformRequests && staticImportedUrls.size) {
73947
73956
  staticImportedUrls.forEach((url) => {
73948
73957
  transformRequest(unwrapId$1(removeImportQuery(url)), server, { ssr });
73949
73958
  });
@@ -74417,7 +74426,6 @@ async function resolvePlugins(config, prePlugins, normalPlugins, postPlugins) {
74417
74426
  ssrConfig: config.ssr,
74418
74427
  asSrc: true
74419
74428
  }),
74420
- config.build.ssr ? ssrRequireHookPlugin(config) : null,
74421
74429
  htmlInlineScriptProxyPlugin(config),
74422
74430
  cssPlugin(config),
74423
74431
  config.esbuild !== false ? esbuildPlugin(config.esbuild) : null,
@@ -74431,6 +74439,7 @@ async function resolvePlugins(config, prePlugins, normalPlugins, postPlugins) {
74431
74439
  ...normalPlugins,
74432
74440
  definePlugin(config),
74433
74441
  cssPostPlugin(config),
74442
+ config.build.ssr ? ssrRequireHookPlugin(config) : null,
74434
74443
  ...buildPlugins.pre,
74435
74444
  ...postPlugins,
74436
74445
  ...buildPlugins.post,
@@ -74683,10 +74692,10 @@ async function resolveConfig(inlineConfig, command, defaultMode = 'development')
74683
74692
  { find: /^[\/]?@vite\/client/, replacement: () => CLIENT_ENTRY }
74684
74693
  ];
74685
74694
  // resolve alias with internal client alias
74686
- const resolvedAlias = mergeAlias(
74695
+ const resolvedAlias = normalizeAlias(mergeAlias(
74687
74696
  // @ts-ignore because @rollup/plugin-alias' type doesn't allow function
74688
74697
  // replacement, but its implementation does work with function values.
74689
- clientAlias, ((_a = config.resolve) === null || _a === void 0 ? void 0 : _a.alias) || config.alias || []);
74698
+ clientAlias, ((_a = config.resolve) === null || _a === void 0 ? void 0 : _a.alias) || config.alias || []));
74690
74699
  const resolveOptions = {
74691
74700
  dedupe: config.dedupe,
74692
74701
  ...config.resolve,
@@ -74920,28 +74929,30 @@ function mergeConfigRecursively(defaults, overrides, rootPath) {
74920
74929
  continue;
74921
74930
  }
74922
74931
  const existing = merged[key];
74923
- if (Array.isArray(existing) && Array.isArray(value)) {
74924
- merged[key] = [...existing, ...value];
74932
+ if (existing == null) {
74933
+ merged[key] = value;
74934
+ continue;
74935
+ }
74936
+ // fields that require special handling
74937
+ if (key === 'alias' && (rootPath === 'resolve' || rootPath === '')) {
74938
+ merged[key] = mergeAlias(existing, value);
74939
+ continue;
74940
+ }
74941
+ else if (key === 'assetsInclude' && rootPath === '') {
74942
+ merged[key] = [].concat(existing, value);
74943
+ continue;
74944
+ }
74945
+ else if (key === 'noExternal' && existing === true) {
74946
+ continue;
74947
+ }
74948
+ if (Array.isArray(existing) || Array.isArray(value)) {
74949
+ merged[key] = [...arraify(existing !== null && existing !== void 0 ? existing : []), ...arraify(value !== null && value !== void 0 ? value : [])];
74925
74950
  continue;
74926
74951
  }
74927
74952
  if (isObject$3(existing) && isObject$3(value)) {
74928
74953
  merged[key] = mergeConfigRecursively(existing, value, rootPath ? `${rootPath}.${key}` : key);
74929
74954
  continue;
74930
74955
  }
74931
- // fields that require special handling
74932
- if (existing != null) {
74933
- if (key === 'alias' && (rootPath === 'resolve' || rootPath === '')) {
74934
- merged[key] = mergeAlias(existing, value);
74935
- continue;
74936
- }
74937
- else if (key === 'assetsInclude' && rootPath === '') {
74938
- merged[key] = [].concat(existing, value);
74939
- continue;
74940
- }
74941
- else if (key === 'noExternal' && existing === true) {
74942
- continue;
74943
- }
74944
- }
74945
74956
  merged[key] = value;
74946
74957
  }
74947
74958
  return merged;
@@ -74949,10 +74960,19 @@ function mergeConfigRecursively(defaults, overrides, rootPath) {
74949
74960
  function mergeConfig(defaults, overrides, isRoot = true) {
74950
74961
  return mergeConfigRecursively(defaults, overrides, isRoot ? '' : '.');
74951
74962
  }
74952
- function mergeAlias(a = [], b = []) {
74953
- return [...normalizeAlias(a), ...normalizeAlias(b)];
74963
+ function mergeAlias(a, b) {
74964
+ if (!a)
74965
+ return b;
74966
+ if (!b)
74967
+ return a;
74968
+ if (isObject$3(a) && isObject$3(b)) {
74969
+ return { ...a, ...b };
74970
+ }
74971
+ // the order is flipped because the alias is resolved from top-down,
74972
+ // where the later should have higher priority
74973
+ return [...normalizeAlias(b), ...normalizeAlias(a)];
74954
74974
  }
74955
- function normalizeAlias(o) {
74975
+ function normalizeAlias(o = []) {
74956
74976
  return Array.isArray(o)
74957
74977
  ? o.map(normalizeSingleAlias)
74958
74978
  : Object.keys(o).map((find) => normalizeSingleAlias({
@@ -75233,4 +75253,4 @@ exports.send = send$1;
75233
75253
  exports.sortUserPlugins = sortUserPlugins;
75234
75254
  exports.source = source;
75235
75255
  exports.transformWithEsbuild = transformWithEsbuild;
75236
- //# sourceMappingURL=dep-24a6b4c4.js.map
75256
+ //# sourceMappingURL=dep-0351185a.js.map