vite 4.3.1 → 4.3.3

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.

@@ -353,12 +353,6 @@ function getTokenAttr(token, attrName) {
353
353
  return null;
354
354
  }
355
355
 
356
- var token = {
357
- __proto__: null,
358
- get TokenType () { return TokenType; },
359
- getTokenAttr: getTokenAttr
360
- };
361
-
362
356
  // Generated using scripts/write-decode-map.ts
363
357
  var htmlDecodeTree = new Uint16Array(
364
358
  // prettier-ignore
@@ -935,31 +929,6 @@ const SPECIAL_ELEMENTS = {
935
929
  function isNumberedHeader(tn) {
936
930
  return tn === $.H1 || tn === $.H2 || tn === $.H3 || tn === $.H4 || tn === $.H5 || tn === $.H6;
937
931
  }
938
- const UNESCAPED_TEXT = new Set([
939
- TAG_NAMES.STYLE,
940
- TAG_NAMES.SCRIPT,
941
- TAG_NAMES.XMP,
942
- TAG_NAMES.IFRAME,
943
- TAG_NAMES.NOEMBED,
944
- TAG_NAMES.NOFRAMES,
945
- TAG_NAMES.PLAINTEXT,
946
- ]);
947
- function hasUnescapedText(tn, scriptingEnabled) {
948
- return UNESCAPED_TEXT.has(tn) || (scriptingEnabled && tn === TAG_NAMES.NOSCRIPT);
949
- }
950
-
951
- var html = {
952
- __proto__: null,
953
- get ATTRS () { return ATTRS; },
954
- get DOCUMENT_MODE () { return DOCUMENT_MODE; },
955
- get NS () { return NS; },
956
- SPECIAL_ELEMENTS: SPECIAL_ELEMENTS,
957
- get TAG_ID () { return TAG_ID; },
958
- get TAG_NAMES () { return TAG_NAMES; },
959
- getTagID: getTagID,
960
- hasUnescapedText: hasUnescapedText,
961
- isNumberedHeader: isNumberedHeader
962
- };
963
932
 
964
933
  //C1 Unicode control character reference replacements
965
934
  const C1_CONTROLS_REFERENCE_REPLACEMENTS = new Map([
@@ -4794,17 +4763,6 @@ function isIntegrationPoint(tn, ns, attrs, foreignNS) {
4794
4763
  ((!foreignNS || foreignNS === NS.MATHML) && isMathMLTextIntegrationPoint(tn, ns)));
4795
4764
  }
4796
4765
 
4797
- var foreignContent = {
4798
- __proto__: null,
4799
- SVG_TAG_NAMES_ADJUSTMENT_MAP: SVG_TAG_NAMES_ADJUSTMENT_MAP,
4800
- adjustTokenMathMLAttrs: adjustTokenMathMLAttrs,
4801
- adjustTokenSVGAttrs: adjustTokenSVGAttrs,
4802
- adjustTokenSVGTagName: adjustTokenSVGTagName,
4803
- adjustTokenXMLAttrs: adjustTokenXMLAttrs,
4804
- causesExit: causesExit,
4805
- isIntegrationPoint: isIntegrationPoint
4806
- };
4807
-
4808
4766
  //Misc constants
4809
4767
  const HIDDEN_INPUT_TYPE = 'hidden';
4810
4768
  //Adoption agency loops iteration count
@@ -7947,212 +7905,6 @@ function endTagInForeignContent(p, token) {
7947
7905
  }
7948
7906
  }
7949
7907
 
7950
- function getEscaper(regex, map) {
7951
- return function escape(data) {
7952
- let match;
7953
- let lastIdx = 0;
7954
- let result = "";
7955
- while ((match = regex.exec(data))) {
7956
- if (lastIdx !== match.index) {
7957
- result += data.substring(lastIdx, match.index);
7958
- }
7959
- // We know that this chararcter will be in the map.
7960
- result += map.get(match[0].charCodeAt(0));
7961
- // Every match will be of length 1
7962
- lastIdx = match.index + 1;
7963
- }
7964
- return result + data.substring(lastIdx);
7965
- };
7966
- }
7967
- /**
7968
- * Encodes all characters that have to be escaped in HTML attributes,
7969
- * following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
7970
- *
7971
- * @param data String to escape.
7972
- */
7973
- const escapeAttribute = getEscaper(/["&\u00A0]/g, new Map([
7974
- [34, """],
7975
- [38, "&"],
7976
- [160, " "],
7977
- ]));
7978
- /**
7979
- * Encodes all characters that have to be escaped in HTML text,
7980
- * following {@link https://html.spec.whatwg.org/multipage/parsing.html#escapingString}.
7981
- *
7982
- * @param data String to escape.
7983
- */
7984
- const escapeText = getEscaper(/[&<>\u00A0]/g, new Map([
7985
- [38, "&amp;"],
7986
- [60, "&lt;"],
7987
- [62, "&gt;"],
7988
- [160, "&nbsp;"],
7989
- ]));
7990
-
7991
- // Sets
7992
- const VOID_ELEMENTS = new Set([
7993
- TAG_NAMES.AREA,
7994
- TAG_NAMES.BASE,
7995
- TAG_NAMES.BASEFONT,
7996
- TAG_NAMES.BGSOUND,
7997
- TAG_NAMES.BR,
7998
- TAG_NAMES.COL,
7999
- TAG_NAMES.EMBED,
8000
- TAG_NAMES.FRAME,
8001
- TAG_NAMES.HR,
8002
- TAG_NAMES.IMG,
8003
- TAG_NAMES.INPUT,
8004
- TAG_NAMES.KEYGEN,
8005
- TAG_NAMES.LINK,
8006
- TAG_NAMES.META,
8007
- TAG_NAMES.PARAM,
8008
- TAG_NAMES.SOURCE,
8009
- TAG_NAMES.TRACK,
8010
- TAG_NAMES.WBR,
8011
- ]);
8012
- function isVoidElement(node, options) {
8013
- return (options.treeAdapter.isElementNode(node) &&
8014
- options.treeAdapter.getNamespaceURI(node) === NS.HTML &&
8015
- VOID_ELEMENTS.has(options.treeAdapter.getTagName(node)));
8016
- }
8017
- const defaultOpts = { treeAdapter: defaultTreeAdapter, scriptingEnabled: true };
8018
- /**
8019
- * Serializes an AST node to an HTML string.
8020
- *
8021
- * @example
8022
- *
8023
- * ```js
8024
- * const parse5 = require('parse5');
8025
- *
8026
- * const document = parse5.parse('<!DOCTYPE html><html><head></head><body>Hi there!</body></html>');
8027
- *
8028
- * // Serializes a document.
8029
- * const html = parse5.serialize(document);
8030
- *
8031
- * // Serializes the <html> element content.
8032
- * const str = parse5.serialize(document.childNodes[1]);
8033
- *
8034
- * console.log(str); //> '<head></head><body>Hi there!</body>'
8035
- * ```
8036
- *
8037
- * @param node Node to serialize.
8038
- * @param options Serialization options.
8039
- */
8040
- function serialize(node, options) {
8041
- const opts = { ...defaultOpts, ...options };
8042
- if (isVoidElement(node, opts)) {
8043
- return '';
8044
- }
8045
- return serializeChildNodes(node, opts);
8046
- }
8047
- /**
8048
- * Serializes an AST element node to an HTML string, including the element node.
8049
- *
8050
- * @example
8051
- *
8052
- * ```js
8053
- * const parse5 = require('parse5');
8054
- *
8055
- * const document = parse5.parseFragment('<div>Hello, <b>world</b>!</div>');
8056
- *
8057
- * // Serializes the <div> element.
8058
- * const html = parse5.serializeOuter(document.childNodes[0]);
8059
- *
8060
- * console.log(str); //> '<div>Hello, <b>world</b>!</div>'
8061
- * ```
8062
- *
8063
- * @param node Node to serialize.
8064
- * @param options Serialization options.
8065
- */
8066
- function serializeOuter(node, options) {
8067
- const opts = { ...defaultOpts, ...options };
8068
- return serializeNode(node, opts);
8069
- }
8070
- function serializeChildNodes(parentNode, options) {
8071
- let html = '';
8072
- // Get container of the child nodes
8073
- const container = options.treeAdapter.isElementNode(parentNode) &&
8074
- options.treeAdapter.getTagName(parentNode) === TAG_NAMES.TEMPLATE &&
8075
- options.treeAdapter.getNamespaceURI(parentNode) === NS.HTML
8076
- ? options.treeAdapter.getTemplateContent(parentNode)
8077
- : parentNode;
8078
- const childNodes = options.treeAdapter.getChildNodes(container);
8079
- if (childNodes) {
8080
- for (const currentNode of childNodes) {
8081
- html += serializeNode(currentNode, options);
8082
- }
8083
- }
8084
- return html;
8085
- }
8086
- function serializeNode(node, options) {
8087
- if (options.treeAdapter.isElementNode(node)) {
8088
- return serializeElement(node, options);
8089
- }
8090
- if (options.treeAdapter.isTextNode(node)) {
8091
- return serializeTextNode(node, options);
8092
- }
8093
- if (options.treeAdapter.isCommentNode(node)) {
8094
- return serializeCommentNode(node, options);
8095
- }
8096
- if (options.treeAdapter.isDocumentTypeNode(node)) {
8097
- return serializeDocumentTypeNode(node, options);
8098
- }
8099
- // Return an empty string for unknown nodes
8100
- return '';
8101
- }
8102
- function serializeElement(node, options) {
8103
- const tn = options.treeAdapter.getTagName(node);
8104
- return `<${tn}${serializeAttributes(node, options)}>${isVoidElement(node, options) ? '' : `${serializeChildNodes(node, options)}</${tn}>`}`;
8105
- }
8106
- function serializeAttributes(node, { treeAdapter }) {
8107
- let html = '';
8108
- for (const attr of treeAdapter.getAttrList(node)) {
8109
- html += ' ';
8110
- if (!attr.namespace) {
8111
- html += attr.name;
8112
- }
8113
- else
8114
- switch (attr.namespace) {
8115
- case NS.XML: {
8116
- html += `xml:${attr.name}`;
8117
- break;
8118
- }
8119
- case NS.XMLNS: {
8120
- if (attr.name !== 'xmlns') {
8121
- html += 'xmlns:';
8122
- }
8123
- html += attr.name;
8124
- break;
8125
- }
8126
- case NS.XLINK: {
8127
- html += `xlink:${attr.name}`;
8128
- break;
8129
- }
8130
- default: {
8131
- html += `${attr.prefix}:${attr.name}`;
8132
- }
8133
- }
8134
- html += `="${escapeAttribute(attr.value)}"`;
8135
- }
8136
- return html;
8137
- }
8138
- function serializeTextNode(node, options) {
8139
- const { treeAdapter } = options;
8140
- const content = treeAdapter.getTextNodeContent(node);
8141
- const parent = treeAdapter.getParentNode(node);
8142
- const parentTn = parent && treeAdapter.isElementNode(parent) && treeAdapter.getTagName(parent);
8143
- return parentTn &&
8144
- treeAdapter.getNamespaceURI(parent) === NS.HTML &&
8145
- hasUnescapedText(parentTn, options.scriptingEnabled)
8146
- ? content
8147
- : escapeText(content);
8148
- }
8149
- function serializeCommentNode(node, { treeAdapter }) {
8150
- return `<!--${treeAdapter.getCommentNodeContent(node)}-->`;
8151
- }
8152
- function serializeDocumentTypeNode(node, { treeAdapter }) {
8153
- return `<!DOCTYPE ${treeAdapter.getDocumentTypeNodeName(node)}>`;
8154
- }
8155
-
8156
7908
  // Shorthands
8157
7909
  /**
8158
7910
  * Parses an HTML string.
@@ -8174,15 +7926,5 @@ function serializeDocumentTypeNode(node, { treeAdapter }) {
8174
7926
  function parse(html, options) {
8175
7927
  return Parser.parse(html, options);
8176
7928
  }
8177
- function parseFragment(fragmentContext, html, options) {
8178
- if (typeof fragmentContext === 'string') {
8179
- options = html;
8180
- html = fragmentContext;
8181
- fragmentContext = null;
8182
- }
8183
- const parser = Parser.getFragmentParser(fragmentContext, options);
8184
- parser.tokenizer.write(html, true);
8185
- return parser.getFragment();
8186
- }
8187
7929
 
8188
- export { ERR as ErrorCodes, Parser, token as Token, Tokenizer, TokenizerMode, defaultTreeAdapter, foreignContent, html, parse, parseFragment, serialize, serializeOuter };
7930
+ export { ERR as ErrorCodes, Parser, Tokenizer, TokenizerMode, defaultTreeAdapter, parse };
package/dist/node/cli.js CHANGED
@@ -2,10 +2,11 @@ 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 picocolorsExports, D as bindShortcuts, x as createLogger, h as resolveConfig } from './chunks/dep-24daf00c.js';
5
+ import { C as colors, D as bindShortcuts, x as createLogger, h as resolveConfig } from './chunks/dep-a178814b.js';
6
6
  import { VERSION } from './constants.js';
7
7
  import 'node:fs/promises';
8
8
  import 'node:url';
9
+ import 'node:util';
9
10
  import 'node:module';
10
11
  import 'tty';
11
12
  import 'esbuild';
@@ -25,7 +26,6 @@ import 'node:crypto';
25
26
  import 'node:dns';
26
27
  import 'crypto';
27
28
  import 'node:buffer';
28
- import 'node:util';
29
29
  import 'module';
30
30
  import 'node:assert';
31
31
  import 'node:process';
@@ -667,7 +667,7 @@ const stopProfiler = (log) => {
667
667
  if (!err) {
668
668
  const outPath = path.resolve(`./vite-profile-${profileCount++}.cpuprofile`);
669
669
  fs.writeFileSync(outPath, JSON.stringify(profile));
670
- log(picocolorsExports.yellow(`CPU profile written to ${picocolorsExports.white(picocolorsExports.dim(outPath))}`));
670
+ log(colors.yellow(`CPU profile written to ${colors.white(colors.dim(outPath))}`));
671
671
  profileSession = undefined;
672
672
  res();
673
673
  }
@@ -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-24daf00c.js').then(function (n) { return n.H; });
731
+ const { createServer } = await import('./chunks/dep-a178814b.js').then(function (n) { return n.I; });
732
732
  try {
733
733
  const server = await createServer({
734
734
  root,
@@ -747,9 +747,9 @@ cli
747
747
  const info = server.config.logger.info;
748
748
  const viteStartTime = global.__vite_start_time ?? false;
749
749
  const startupDurationString = viteStartTime
750
- ? picocolorsExports.dim(`ready in ${picocolorsExports.reset(picocolorsExports.bold(Math.ceil(performance.now() - viteStartTime)))} ms`)
750
+ ? colors.dim(`ready in ${colors.reset(colors.bold(Math.ceil(performance.now() - viteStartTime)))} ms`)
751
751
  : '';
752
- info(`\n ${picocolorsExports.green(`${picocolorsExports.bold('VITE')} v${VERSION}`)} ${startupDurationString}\n`, { clear: !server.config.logger.hasWarned });
752
+ info(`\n ${colors.green(`${colors.bold('VITE')} v${VERSION}`)} ${startupDurationString}\n`, { clear: !server.config.logger.hasWarned });
753
753
  server.printUrls();
754
754
  bindShortcuts(server, {
755
755
  print: true,
@@ -781,7 +781,7 @@ cli
781
781
  }
782
782
  catch (e) {
783
783
  const logger = createLogger(options.logLevel);
784
- logger.error(picocolorsExports.red(`error when starting dev server:\n${e.stack}`), {
784
+ logger.error(colors.red(`error when starting dev server:\n${e.stack}`), {
785
785
  error: e,
786
786
  });
787
787
  stopProfiler(logger.info);
@@ -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-24daf00c.js').then(function (n) { return n.G; });
809
+ const { build } = await import('./chunks/dep-a178814b.js').then(function (n) { return n.H; });
810
810
  const buildOptions = cleanOptions(options);
811
811
  try {
812
812
  await build({
@@ -821,7 +821,7 @@ cli
821
821
  });
822
822
  }
823
823
  catch (e) {
824
- createLogger(options.logLevel).error(picocolorsExports.red(`error during build:\n${e.stack}`), { error: e });
824
+ createLogger(options.logLevel).error(colors.red(`error during build:\n${e.stack}`), { error: e });
825
825
  process.exit(1);
826
826
  }
827
827
  finally {
@@ -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-24daf00c.js').then(function (n) { return n.F; });
837
+ const { optimizeDeps } = await import('./chunks/dep-a178814b.js').then(function (n) { return n.G; });
838
838
  try {
839
839
  const config = await resolveConfig({
840
840
  root,
@@ -846,7 +846,7 @@ cli
846
846
  await optimizeDeps(config, options.force, true);
847
847
  }
848
848
  catch (e) {
849
- createLogger(options.logLevel).error(picocolorsExports.red(`error when optimizing deps:\n${e.stack}`), { error: e });
849
+ createLogger(options.logLevel).error(colors.red(`error when optimizing deps:\n${e.stack}`), { error: e });
850
850
  process.exit(1);
851
851
  }
852
852
  });
@@ -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-24daf00c.js').then(function (n) { return n.I; });
863
+ const { preview } = await import('./chunks/dep-a178814b.js').then(function (n) { return n.J; });
864
864
  try {
865
865
  const server = await preview({
866
866
  root,
@@ -882,7 +882,7 @@ cli
882
882
  server.printUrls();
883
883
  }
884
884
  catch (e) {
885
- createLogger(options.logLevel).error(picocolorsExports.red(`error when starting preview server:\n${e.stack}`), { error: e });
885
+ createLogger(options.logLevel).error(colors.red(`error when starting preview server:\n${e.stack}`), { error: e });
886
886
  process.exit(1);
887
887
  }
888
888
  finally {
@@ -599,6 +599,14 @@ export declare interface DepOptimizationConfig {
599
599
  * @experimental
600
600
  */
601
601
  disabled?: boolean | 'build' | 'dev';
602
+ /**
603
+ * Automatic dependency discovery. When `noDiscovery` is true, only dependencies
604
+ * listed in `include` will be optimized. The scanner isn't run for cold start
605
+ * in this case. CJS-only dependencies must be present in `include` during dev.
606
+ * @default false
607
+ * @experimental
608
+ */
609
+ noDiscovery?: boolean;
602
610
  }
603
611
 
604
612
  export declare interface DepOptimizationMetadata {
@@ -1,5 +1,5 @@
1
- import { i as isInNodeModules } from './chunks/dep-24daf00c.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-24daf00c.js';
1
+ import { i as isInNodeModules } from './chunks/dep-a178814b.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-a178814b.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';
@@ -7,6 +7,7 @@ import 'node:fs';
7
7
  import 'node:fs/promises';
8
8
  import 'node:path';
9
9
  import 'node:url';
10
+ import 'node:util';
10
11
  import 'node:perf_hooks';
11
12
  import 'node:module';
12
13
  import 'tty';
@@ -27,7 +28,6 @@ import 'node:crypto';
27
28
  import 'node:dns';
28
29
  import 'crypto';
29
30
  import 'node:buffer';
30
- import 'node:util';
31
31
  import 'module';
32
32
  import 'node:assert';
33
33
  import 'node:process';