@rollup/wasm-node 4.23.0 → 4.24.1

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.
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  @license
3
- Rollup.js v4.23.0
4
- Tue, 01 Oct 2024 07:09:35 GMT - commit ed98e0821e6ad064839f0af46ceca061adbe3f14
3
+ Rollup.js v4.24.1
4
+ Sun, 27 Oct 2024 06:42:30 GMT - commit 88a54d892dacbb0efdbcade263a32d9df1a77b37
5
5
 
6
6
  https://github.com/rollup/rollup
7
7
 
@@ -31,7 +31,7 @@ function _interopNamespaceDefault(e) {
31
31
 
32
32
  const tty__namespace = /*#__PURE__*/_interopNamespaceDefault(tty);
33
33
 
34
- var version = "4.23.0";
34
+ var version = "4.24.1";
35
35
 
36
36
  function ensureArray$1(items) {
37
37
  if (Array.isArray(items)) {
@@ -698,6 +698,32 @@ const treeshakePresets = {
698
698
  unknownGlobalSideEffects: false
699
699
  }
700
700
  };
701
+ const jsxPresets = {
702
+ preserve: {
703
+ factory: null,
704
+ fragment: null,
705
+ importSource: null,
706
+ mode: 'preserve'
707
+ },
708
+ 'preserve-react': {
709
+ factory: 'React.createElement',
710
+ fragment: 'React.Fragment',
711
+ importSource: 'react',
712
+ mode: 'preserve'
713
+ },
714
+ react: {
715
+ factory: 'React.createElement',
716
+ fragment: 'React.Fragment',
717
+ importSource: 'react',
718
+ mode: 'classic'
719
+ },
720
+ 'react-jsx': {
721
+ factory: 'React.createElement',
722
+ importSource: 'react',
723
+ jsxImportSource: 'react/jsx-runtime',
724
+ mode: 'automatic'
725
+ }
726
+ };
701
727
  const generatedCodePresets = {
702
728
  es2015: {
703
729
  arrowFunctions: true,
@@ -1260,6 +1286,7 @@ function mergeInputOptions(config, overrides, plugins, log, onLog) {
1260
1286
  experimentalLogSideEffects: getOption('experimentalLogSideEffects'),
1261
1287
  external: getExternal(config, overrides),
1262
1288
  input: getOption('input') || [],
1289
+ jsx: getObjectOption(config, overrides, 'jsx', objectifyOptionWithPresets(jsxPresets, 'jsx', parseAst_js.URL_JSX, 'false, ')),
1263
1290
  logLevel: getOption('logLevel'),
1264
1291
  makeAbsoluteExternalsRelative: getOption('makeAbsoluteExternalsRelative'),
1265
1292
  maxParallelFileOps: getOption('maxParallelFileOps'),
@@ -2110,27 +2137,6 @@ class Mappings {
2110
2137
  let charInHiresBoundary = false;
2111
2138
 
2112
2139
  while (originalCharIndex < chunk.end) {
2113
- if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
2114
- const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
2115
-
2116
- if (this.hires === 'boundary') {
2117
- // in hires "boundary", group segments per word boundary than per char
2118
- if (wordRegex.test(original[originalCharIndex])) {
2119
- // for first char in the boundary found, start the boundary by pushing a segment
2120
- if (!charInHiresBoundary) {
2121
- this.rawSegments.push(segment);
2122
- charInHiresBoundary = true;
2123
- }
2124
- } else {
2125
- // for non-word char, end the boundary by pushing a segment
2126
- this.rawSegments.push(segment);
2127
- charInHiresBoundary = false;
2128
- }
2129
- } else {
2130
- this.rawSegments.push(segment);
2131
- }
2132
- }
2133
-
2134
2140
  if (original[originalCharIndex] === '\n') {
2135
2141
  loc.line += 1;
2136
2142
  loc.column = 0;
@@ -2139,6 +2145,27 @@ class Mappings {
2139
2145
  this.generatedCodeColumn = 0;
2140
2146
  first = true;
2141
2147
  } else {
2148
+ if (this.hires || first || sourcemapLocations.has(originalCharIndex)) {
2149
+ const segment = [this.generatedCodeColumn, sourceIndex, loc.line, loc.column];
2150
+
2151
+ if (this.hires === 'boundary') {
2152
+ // in hires "boundary", group segments per word boundary than per char
2153
+ if (wordRegex.test(original[originalCharIndex])) {
2154
+ // for first char in the boundary found, start the boundary by pushing a segment
2155
+ if (!charInHiresBoundary) {
2156
+ this.rawSegments.push(segment);
2157
+ charInHiresBoundary = true;
2158
+ }
2159
+ } else {
2160
+ // for non-word char, end the boundary by pushing a segment
2161
+ this.rawSegments.push(segment);
2162
+ charInHiresBoundary = false;
2163
+ }
2164
+ } else {
2165
+ this.rawSegments.push(segment);
2166
+ }
2167
+ }
2168
+
2142
2169
  loc.column += 1;
2143
2170
  this.generatedCodeColumn += 1;
2144
2171
  first = false;
@@ -3711,6 +3738,7 @@ class Variable extends ExpressionEntity {
3711
3738
  this.name = name;
3712
3739
  this.alwaysRendered = false;
3713
3740
  this.forbiddenNames = null;
3741
+ this.globalName = null;
3714
3742
  this.initReached = false;
3715
3743
  this.isId = false;
3716
3744
  this.kind = null;
@@ -3756,6 +3784,9 @@ class Variable extends ExpressionEntity {
3756
3784
  this.name);
3757
3785
  }
3758
3786
  getName(getPropertyAccess, useOriginalName) {
3787
+ if (this.globalName) {
3788
+ return this.globalName;
3789
+ }
3759
3790
  if (useOriginalName?.(this)) {
3760
3791
  return this.name;
3761
3792
  }
@@ -3769,10 +3800,10 @@ class Variable extends ExpressionEntity {
3769
3800
  return type !== INTERACTION_ACCESSED || path.length > 0;
3770
3801
  }
3771
3802
  /**
3772
- * Marks this variable as being part of the bundle, which is usually the case when one of
3773
- * its identifiers becomes part of the bundle. Returns true if it has not been included
3774
- * previously.
3775
- * Once a variable is included, it should take care all its declarations are included.
3803
+ * Marks this variable as being part of the bundle, which is usually the case
3804
+ * when one of its identifiers becomes part of the bundle. Returns true if it
3805
+ * has not been included previously. Once a variable is included, it should
3806
+ * take care all its declarations are included.
3776
3807
  */
3777
3808
  include() {
3778
3809
  this.included = true;
@@ -4258,6 +4289,21 @@ const childNodeKeys = {
4258
4289
  ImportExpression: ['source', 'options'],
4259
4290
  ImportNamespaceSpecifier: ['local'],
4260
4291
  ImportSpecifier: ['imported', 'local'],
4292
+ JSXAttribute: ['name', 'value'],
4293
+ JSXClosingElement: ['name'],
4294
+ JSXClosingFragment: [],
4295
+ JSXElement: ['openingElement', 'children', 'closingElement'],
4296
+ JSXEmptyExpression: [],
4297
+ JSXExpressionContainer: ['expression'],
4298
+ JSXFragment: ['openingFragment', 'children', 'closingFragment'],
4299
+ JSXIdentifier: [],
4300
+ JSXMemberExpression: ['object', 'property'],
4301
+ JSXNamespacedName: ['namespace', 'name'],
4302
+ JSXOpeningElement: ['name', 'attributes'],
4303
+ JSXOpeningFragment: [],
4304
+ JSXSpreadAttribute: ['argument'],
4305
+ JSXSpreadChild: ['expression'],
4306
+ JSXText: [],
4261
4307
  LabeledStatement: ['label', 'body'],
4262
4308
  Literal: [],
4263
4309
  LogicalExpression: ['left', 'right'],
@@ -6372,11 +6418,11 @@ class LocalVariable extends Variable {
6372
6418
  }
6373
6419
 
6374
6420
  const tdzVariableKinds = new Set(['class', 'const', 'let', 'var', 'using', 'await using']);
6375
- class Identifier extends NodeBase {
6421
+ class IdentifierBase extends NodeBase {
6376
6422
  constructor() {
6377
6423
  super(...arguments);
6378
6424
  this.variable = null;
6379
- this.isReferenceVariable = false;
6425
+ this.isVariableReference = false;
6380
6426
  }
6381
6427
  get isTDZAccess() {
6382
6428
  if (!isFlagSet(this.flags, 4 /* Flag.tdzAccessDefined */)) {
@@ -6388,55 +6434,6 @@ class Identifier extends NodeBase {
6388
6434
  this.flags = setFlag(this.flags, 4 /* Flag.tdzAccessDefined */, true);
6389
6435
  this.flags = setFlag(this.flags, 8 /* Flag.tdzAccess */, value);
6390
6436
  }
6391
- addExportedVariables(variables, exportNamesByVariable) {
6392
- if (exportNamesByVariable.has(this.variable)) {
6393
- variables.push(this.variable);
6394
- }
6395
- }
6396
- bind() {
6397
- if (!this.variable && is_reference(this, this.parent)) {
6398
- this.variable = this.scope.findVariable(this.name);
6399
- this.variable.addReference(this);
6400
- this.isReferenceVariable = true;
6401
- }
6402
- }
6403
- declare(kind, init) {
6404
- let variable;
6405
- const { treeshake } = this.scope.context.options;
6406
- switch (kind) {
6407
- case 'var': {
6408
- variable = this.scope.addDeclaration(this, this.scope.context, init, kind);
6409
- if (treeshake && treeshake.correctVarValueBeforeDeclaration) {
6410
- // Necessary to make sure the init is deoptimized. We cannot call deoptimizePath here.
6411
- variable.markInitializersForDeoptimization();
6412
- }
6413
- break;
6414
- }
6415
- case 'function': {
6416
- // in strict mode, functions are only hoisted within a scope but not across block scopes
6417
- variable = this.scope.addDeclaration(this, this.scope.context, init, kind);
6418
- break;
6419
- }
6420
- case 'let':
6421
- case 'const':
6422
- case 'using':
6423
- case 'await using':
6424
- case 'class': {
6425
- variable = this.scope.addDeclaration(this, this.scope.context, init, kind);
6426
- break;
6427
- }
6428
- case 'parameter': {
6429
- variable = this.scope.addParameterDeclaration(this);
6430
- break;
6431
- }
6432
- /* istanbul ignore next */
6433
- default: {
6434
- /* istanbul ignore next */
6435
- throw new Error(`Internal Error: Unexpected identifier kind ${kind}.`);
6436
- }
6437
- }
6438
- return [(this.variable = variable)];
6439
- }
6440
6437
  deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker) {
6441
6438
  this.variable.deoptimizeArgumentsOnInteractionAtPath(interaction, path, recursionTracker);
6442
6439
  }
@@ -6527,32 +6524,6 @@ class Identifier extends NodeBase {
6527
6524
  }
6528
6525
  return (this.isTDZAccess = false);
6529
6526
  }
6530
- markDeclarationReached() {
6531
- this.variable.initReached = true;
6532
- }
6533
- render(code, { snippets: { getPropertyAccess }, useOriginalName }, { renderedParentType, isCalleeOfRenderedParent, isShorthandProperty } = parseAst_js.BLANK) {
6534
- if (this.variable) {
6535
- const name = this.variable.getName(getPropertyAccess, useOriginalName);
6536
- if (name !== this.name) {
6537
- code.overwrite(this.start, this.end, name, {
6538
- contentOnly: true,
6539
- storeName: true
6540
- });
6541
- if (isShorthandProperty) {
6542
- code.prependRight(this.start, `${this.name}: `);
6543
- }
6544
- }
6545
- // In strict mode, any variable named "eval" must be the actual "eval" function
6546
- if (name === 'eval' &&
6547
- renderedParentType === parseAst_js.CallExpression &&
6548
- isCalleeOfRenderedParent) {
6549
- code.appendRight(this.start, '0, ');
6550
- }
6551
- }
6552
- }
6553
- disallowImportReassignment() {
6554
- return this.scope.context.error(parseAst_js.logIllegalImportReassignment(this.name, this.scope.context.module.id), this.start);
6555
- }
6556
6527
  applyDeoptimizations() {
6557
6528
  this.deoptimized = true;
6558
6529
  if (this.variable instanceof LocalVariable) {
@@ -6565,11 +6536,14 @@ class Identifier extends NodeBase {
6565
6536
  this.variable.consolidateInitializers();
6566
6537
  this.scope.context.requestTreeshakingPass();
6567
6538
  }
6568
- if (this.isReferenceVariable) {
6539
+ if (this.isVariableReference) {
6569
6540
  this.variable.addUsedPlace(this);
6570
6541
  this.scope.context.requestTreeshakingPass();
6571
6542
  }
6572
6543
  }
6544
+ disallowImportReassignment() {
6545
+ return this.scope.context.error(parseAst_js.logIllegalImportReassignment(this.name, this.scope.context.module.id), this.start);
6546
+ }
6573
6547
  getVariableRespectingTDZ() {
6574
6548
  if (this.isPossibleTDZ()) {
6575
6549
  return UNKNOWN_EXPRESSION;
@@ -6600,6 +6574,85 @@ function closestParentFunctionOrProgram(node) {
6600
6574
  return node;
6601
6575
  }
6602
6576
 
6577
+ class Identifier extends IdentifierBase {
6578
+ constructor() {
6579
+ super(...arguments);
6580
+ this.variable = null;
6581
+ }
6582
+ addExportedVariables(variables, exportNamesByVariable) {
6583
+ if (exportNamesByVariable.has(this.variable)) {
6584
+ variables.push(this.variable);
6585
+ }
6586
+ }
6587
+ bind() {
6588
+ if (!this.variable && is_reference(this, this.parent)) {
6589
+ this.variable = this.scope.findVariable(this.name);
6590
+ this.variable.addReference(this);
6591
+ this.isVariableReference = true;
6592
+ }
6593
+ }
6594
+ declare(kind, init) {
6595
+ let variable;
6596
+ const { treeshake } = this.scope.context.options;
6597
+ switch (kind) {
6598
+ case 'var': {
6599
+ variable = this.scope.addDeclaration(this, this.scope.context, init, kind);
6600
+ if (treeshake && treeshake.correctVarValueBeforeDeclaration) {
6601
+ // Necessary to make sure the init is deoptimized. We cannot call deoptimizePath here.
6602
+ variable.markInitializersForDeoptimization();
6603
+ }
6604
+ break;
6605
+ }
6606
+ case 'function': {
6607
+ // in strict mode, functions are only hoisted within a scope but not across block scopes
6608
+ variable = this.scope.addDeclaration(this, this.scope.context, init, kind);
6609
+ break;
6610
+ }
6611
+ case 'let':
6612
+ case 'const':
6613
+ case 'using':
6614
+ case 'await using':
6615
+ case 'class': {
6616
+ variable = this.scope.addDeclaration(this, this.scope.context, init, kind);
6617
+ break;
6618
+ }
6619
+ case 'parameter': {
6620
+ variable = this.scope.addParameterDeclaration(this);
6621
+ break;
6622
+ }
6623
+ /* istanbul ignore next */
6624
+ default: {
6625
+ /* istanbul ignore next */
6626
+ throw new Error(`Internal Error: Unexpected identifier kind ${kind}.`);
6627
+ }
6628
+ }
6629
+ return [(this.variable = variable)];
6630
+ }
6631
+ markDeclarationReached() {
6632
+ this.variable.initReached = true;
6633
+ }
6634
+ render(code, { snippets: { getPropertyAccess }, useOriginalName }, { renderedParentType, isCalleeOfRenderedParent, isShorthandProperty } = parseAst_js.BLANK) {
6635
+ if (this.variable) {
6636
+ const name = this.variable.getName(getPropertyAccess, useOriginalName);
6637
+ if (name !== this.name) {
6638
+ code.overwrite(this.start, this.end, name, {
6639
+ contentOnly: true,
6640
+ storeName: true
6641
+ });
6642
+ if (isShorthandProperty) {
6643
+ code.prependRight(this.start, `${this.name}: `);
6644
+ }
6645
+ }
6646
+ // In strict mode, any variable named "eval" must be the actual "eval" function
6647
+ if (name === 'eval' &&
6648
+ renderedParentType === parseAst_js.CallExpression &&
6649
+ isCalleeOfRenderedParent) {
6650
+ code.appendRight(this.start, '0, ');
6651
+ }
6652
+ }
6653
+ }
6654
+ }
6655
+
6603
6656
  function getSafeName(baseName, usedNames, forbiddenNames) {
6604
6657
  let safeName = baseName;
6605
6658
  let count = 1;
@@ -6728,6 +6781,11 @@ class ChildScope extends Scope {
6728
6781
  findLexicalBoundary() {
6729
6782
  return this.parent.findLexicalBoundary();
6730
6783
  }
6784
+ findGlobal(name) {
6785
+ const variable = this.parent.findVariable(name);
6786
+ this.accessedOutsideVariables.set(name, variable);
6787
+ return variable;
6788
+ }
6731
6789
  findVariable(name) {
6732
6790
  const knownVariable = this.variables.get(name) || this.accessedOutsideVariables.get(name);
6733
6791
  if (knownVariable) {
@@ -9997,7 +10055,6 @@ function requireConstants () {
9997
10055
  if (hasRequiredConstants) return constants;
9998
10056
  hasRequiredConstants = 1;
9999
10057
 
10000
- const path = require$$0;
10001
10058
  const WIN_SLASH = '\\\\/';
10002
10059
  const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
10003
10060
 
@@ -10020,6 +10077,7 @@ function requireConstants () {
10020
10077
  const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
10021
10078
  const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
10022
10079
  const STAR = `${QMARK}*?`;
10080
+ const SEP = '/';
10023
10081
 
10024
10082
  const POSIX_CHARS = {
10025
10083
  DOT_LITERAL,
@@ -10036,7 +10094,8 @@ function requireConstants () {
10036
10094
  NO_DOTS_SLASH,
10037
10095
  QMARK_NO_DOT,
10038
10096
  STAR,
10039
- START_ANCHOR
10097
+ START_ANCHOR,
10098
+ SEP
10040
10099
  };
10041
10100
 
10042
10101
  /**
@@ -10056,7 +10115,8 @@ function requireConstants () {
10056
10115
  NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
10057
10116
  QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
10058
10117
  START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
10059
- END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
10118
+ END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
10119
+ SEP: '\\'
10060
10120
  };
10061
10121
 
10062
10122
  /**
@@ -10150,8 +10210,6 @@ function requireConstants () {
10150
10210
  CHAR_VERTICAL_LINE: 124, /* | */
10151
10211
  CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */
10152
10212
 
10153
- SEP: path.sep,
10154
-
10155
10213
  /**
10156
10214
  * Create EXTGLOB_CHARS
10157
10215
  */
@@ -10177,6 +10235,8 @@ function requireConstants () {
10177
10235
  return constants;
10178
10236
  }
10179
10237
 
10238
+ /*global navigator*/
10239
+
10180
10240
  var hasRequiredUtils;
10181
10241
 
10182
10242
  function requireUtils () {
@@ -10184,8 +10244,6 @@ function requireUtils () {
10184
10244
  hasRequiredUtils = 1;
10185
10245
  (function (exports) {
10186
10246
 
10187
- const path = require$$0;
10188
- const win32 = process.platform === 'win32';
10189
10247
  const {
10190
10248
  REGEX_BACKSLASH,
10191
10249
  REGEX_REMOVE_BACKSLASH,
@@ -10199,25 +10257,23 @@ function requireUtils () {
10199
10257
  exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
10200
10258
  exports.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/');
10201
10259
 
10202
- exports.removeBackslashes = str => {
10203
- return str.replace(REGEX_REMOVE_BACKSLASH, match => {
10204
- return match === '\\' ? '' : match;
10205
- });
10206
- };
10260
+ exports.isWindows = () => {
10261
+ if (typeof navigator !== 'undefined' && navigator.platform) {
10262
+ const platform = navigator.platform.toLowerCase();
10263
+ return platform === 'win32' || platform === 'windows';
10264
+ }
10207
10265
 
10208
- exports.supportsLookbehinds = () => {
10209
- const segs = process.version.slice(1).split('.').map(Number);
10210
- if (segs.length === 3 && segs[0] >= 9 || (segs[0] === 8 && segs[1] >= 10)) {
10211
- return true;
10266
+ if (typeof process !== 'undefined' && process.platform) {
10267
+ return process.platform === 'win32';
10212
10268
  }
10269
+
10213
10270
  return false;
10214
10271
  };
10215
10272
 
10216
- exports.isWindows = options => {
10217
- if (options && typeof options.windows === 'boolean') {
10218
- return options.windows;
10219
- }
10220
- return win32 === true || path.sep === '\\';
10273
+ exports.removeBackslashes = str => {
10274
+ return str.replace(REGEX_REMOVE_BACKSLASH, match => {
10275
+ return match === '\\' ? '' : match;
10276
+ });
10221
10277
  };
10222
10278
 
10223
10279
  exports.escapeLast = (input, char, lastIdx) => {
@@ -10245,6 +10301,17 @@ function requireUtils () {
10245
10301
  output = `(?:^(?!${output}).*$)`;
10246
10302
  }
10247
10303
  return output;
10304
+ };
10305
+
10306
+ exports.basename = (path, { windows } = {}) => {
10307
+ const segs = path.split(windows ? /[\\/]/ : '/');
10308
+ const last = segs[segs.length - 1];
10309
+
10310
+ if (last === '') {
10311
+ return segs[segs.length - 2];
10312
+ }
10313
+
10314
+ return last;
10248
10315
  };
10249
10316
  } (utils));
10250
10317
  return utils;
@@ -10720,10 +10787,9 @@ function requireParse () {
10720
10787
  const tokens = [bos];
10721
10788
 
10722
10789
  const capture = opts.capture ? '' : '?:';
10723
- const win32 = utils.isWindows(options);
10724
10790
 
10725
10791
  // create constants based on platform, for windows or posix
10726
- const PLATFORM_CHARS = constants.globChars(win32);
10792
+ const PLATFORM_CHARS = constants.globChars(opts.windows);
10727
10793
  const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
10728
10794
 
10729
10795
  const {
@@ -10859,8 +10925,8 @@ function requireParse () {
10859
10925
 
10860
10926
  if (tok.value || tok.output) append(tok);
10861
10927
  if (prev && prev.type === 'text' && tok.type === 'text') {
10928
+ prev.output = (prev.output || prev.value) + tok.value;
10862
10929
  prev.value += tok.value;
10863
- prev.output = (prev.output || '') + tok.value;
10864
10930
  return;
10865
10931
  }
10866
10932
 
@@ -11348,10 +11414,6 @@ function requireParse () {
11348
11414
  const next = peek();
11349
11415
  let output = value;
11350
11416
 
11351
- if (next === '<' && !utils.supportsLookbehinds()) {
11352
- throw new Error('Node.js v10 or higher is required for regex lookbehinds');
11353
- }
11354
-
11355
11417
  if ((prev.value === '(' && !/[!=<:]/.test(next)) || (next === '<' && !/<([!=]|\w+>)/.test(remaining()))) {
11356
11418
  output = `\\${value}`;
11357
11419
  }
@@ -11659,7 +11721,6 @@ function requireParse () {
11659
11721
  }
11660
11722
 
11661
11723
  input = REPLACEMENTS[input] || input;
11662
- const win32 = utils.isWindows(options);
11663
11724
 
11664
11725
  // create constants based on platform, for windows or posix
11665
11726
  const {
@@ -11672,7 +11733,7 @@ function requireParse () {
11672
11733
  NO_DOTS_SLASH,
11673
11734
  STAR,
11674
11735
  START_ANCHOR
11675
- } = constants.globChars(win32);
11736
+ } = constants.globChars(opts.windows);
11676
11737
 
11677
11738
  const nodot = opts.dot ? NO_DOTS : NO_DOT;
11678
11739
  const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
@@ -11741,14 +11802,13 @@ function requireParse () {
11741
11802
  return parse_1;
11742
11803
  }
11743
11804
 
11744
- var picomatch_1;
11805
+ var picomatch_1$1;
11745
11806
  var hasRequiredPicomatch$1;
11746
11807
 
11747
11808
  function requirePicomatch$1 () {
11748
- if (hasRequiredPicomatch$1) return picomatch_1;
11809
+ if (hasRequiredPicomatch$1) return picomatch_1$1;
11749
11810
  hasRequiredPicomatch$1 = 1;
11750
11811
 
11751
- const path = require$$0;
11752
11812
  const scan = /*@__PURE__*/ requireScan();
11753
11813
  const parse = /*@__PURE__*/ requireParse();
11754
11814
  const utils = /*@__PURE__*/ requireUtils();
@@ -11797,7 +11857,7 @@ function requirePicomatch$1 () {
11797
11857
  }
11798
11858
 
11799
11859
  const opts = options || {};
11800
- const posix = utils.isWindows(options);
11860
+ const posix = opts.windows;
11801
11861
  const regex = isState
11802
11862
  ? picomatch.compileRe(glob, options)
11803
11863
  : picomatch.makeRe(glob, options, false, true);
@@ -11906,9 +11966,9 @@ function requirePicomatch$1 () {
11906
11966
  * @api public
11907
11967
  */
11908
11968
 
11909
- picomatch.matchBase = (input, glob, options, posix = utils.isWindows(options)) => {
11969
+ picomatch.matchBase = (input, glob, options) => {
11910
11970
  const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
11911
- return regex.test(path.basename(input));
11971
+ return regex.test(utils.basename(input));
11912
11972
  };
11913
11973
 
11914
11974
  /**
@@ -12087,19 +12147,33 @@ function requirePicomatch$1 () {
12087
12147
  * Expose "picomatch"
12088
12148
  */
12089
12149
 
12090
- picomatch_1 = picomatch;
12091
- return picomatch_1;
12150
+ picomatch_1$1 = picomatch;
12151
+ return picomatch_1$1;
12092
12152
  }
12093
12153
 
12094
- var picomatch;
12154
+ var picomatch_1;
12095
12155
  var hasRequiredPicomatch;
12096
12156
 
12097
12157
  function requirePicomatch () {
12098
- if (hasRequiredPicomatch) return picomatch;
12158
+ if (hasRequiredPicomatch) return picomatch_1;
12099
12159
  hasRequiredPicomatch = 1;
12100
12160
 
12101
- picomatch = /*@__PURE__*/ requirePicomatch$1();
12102
- return picomatch;
12161
+ const pico = /*@__PURE__*/ requirePicomatch$1();
12162
+ const utils = /*@__PURE__*/ requireUtils();
12163
+
12164
+ function picomatch(glob, options, returnState = false) {
12165
+ // default to os.platform()
12166
+ if (options && (options.windows === null || options.windows === undefined)) {
12167
+ // don't mutate the original options object
12168
+ options = { ...options, windows: utils.isWindows() };
12169
+ }
12170
+
12171
+ return pico(glob, options, returnState);
12172
+ }
12173
+
12174
+ Object.assign(picomatch, pico);
12175
+ picomatch_1 = picomatch;
12176
+ return picomatch_1;
12103
12177
  }
12104
12178
 
12105
12179
  var picomatchExports = /*@__PURE__*/ requirePicomatch();
@@ -13892,6 +13966,497 @@ class ImportSpecifier extends NodeBase {
13892
13966
  applyDeoptimizations() { }
13893
13967
  }
13894
13968
 
13969
+ class JSXIdentifier extends IdentifierBase {
13970
+ constructor() {
13971
+ super(...arguments);
13972
+ this.isNativeElement = false;
13973
+ }
13974
+ bind() {
13975
+ const type = this.getType();
13976
+ if (type === 0 /* IdentifierType.Reference */) {
13977
+ this.variable = this.scope.findVariable(this.name);
13978
+ this.variable.addReference(this);
13979
+ }
13980
+ else if (type === 1 /* IdentifierType.NativeElementName */) {
13981
+ this.isNativeElement = true;
13982
+ }
13983
+ }
13984
+ render(code, { snippets: { getPropertyAccess }, useOriginalName }) {
13985
+ if (this.variable) {
13986
+ const name = this.variable.getName(getPropertyAccess, useOriginalName);
13987
+ if (name !== this.name) {
13988
+ code.overwrite(this.start, this.end, name, {
13989
+ contentOnly: true,
13990
+ storeName: true
13991
+ });
13992
+ }
13993
+ }
13994
+ else if (this.isNativeElement &&
13995
+ this.scope.context.options.jsx.mode !== 'preserve') {
13996
+ code.update(this.start, this.end, JSON.stringify(this.name));
13997
+ }
13998
+ }
13999
+ getType() {
14000
+ switch (this.parent.type) {
14001
+ case 'JSXOpeningElement':
14002
+ case 'JSXClosingElement': {
14003
+ return this.name.startsWith(this.name.charAt(0).toUpperCase())
14004
+ ? 0 /* IdentifierType.Reference */
14005
+ : 1 /* IdentifierType.NativeElementName */;
14006
+ }
14007
+ case 'JSXMemberExpression': {
14008
+ return this.parent.object === this
14009
+ ? 0 /* IdentifierType.Reference */
14010
+ : 2 /* IdentifierType.Other */;
14011
+ }
14012
+ case 'JSXAttribute':
14013
+ case 'JSXNamespacedName': {
14014
+ return 2 /* IdentifierType.Other */;
14015
+ }
14016
+ default: {
14017
+ /* istanbul ignore next */
14018
+ throw new Error(`Unexpected parent node type for JSXIdentifier: ${this.parent.type}`);
14019
+ }
14020
+ }
14021
+ }
14022
+ }
14023
+
14024
+ class JSXAttribute extends NodeBase {
14025
+ render(code, options, { jsxMode } = parseAst_js.BLANK) {
14026
+ super.render(code, options);
14027
+ if (['classic', 'automatic'].includes(jsxMode)) {
14028
+ const { name, value } = this;
14029
+ const key = name instanceof JSXIdentifier ? name.name : `${name.namespace.name}:${name.name.name}`;
14030
+ if (!(jsxMode === 'automatic' && key === 'key')) {
14031
+ const safeKey = stringifyObjectKeyIfNeeded(key);
14032
+ if (key !== safeKey) {
14033
+ code.overwrite(name.start, name.end, safeKey, { contentOnly: true });
14034
+ }
14035
+ if (value) {
14036
+ code.overwrite(name.end, value.start, ': ', { contentOnly: true });
14037
+ }
14038
+ else {
14039
+ code.appendLeft(name.end, ': true');
14040
+ }
14041
+ }
14042
+ }
14043
+ }
14044
+ }
14045
+
14046
+ class JSXClosingBase extends NodeBase {
14047
+ render(code, options) {
14048
+ const { mode } = this.scope.context.options.jsx;
14049
+ if (mode !== 'preserve') {
14050
+ code.overwrite(this.start, this.end, ')', { contentOnly: true });
14051
+ }
14052
+ else {
14053
+ super.render(code, options);
14054
+ }
14055
+ }
14056
+ }
14057
+
14058
+ class JSXClosingElement extends JSXClosingBase {
14059
+ }
14060
+
14061
+ class JSXClosingFragment extends JSXClosingBase {
14062
+ }
14063
+
14064
+ class JSXSpreadAttribute extends NodeBase {
14065
+ render(code, options) {
14066
+ this.argument.render(code, options);
14067
+ const { mode } = this.scope.context.options.jsx;
14068
+ if (mode !== 'preserve') {
14069
+ code.overwrite(this.start, this.argument.start, '', { contentOnly: true });
14070
+ code.overwrite(this.argument.end, this.end, '', { contentOnly: true });
14071
+ }
14072
+ }
14073
+ }
14074
+
14075
+ class JSXEmptyExpression extends NodeBase {
14076
+ }
14077
+
14078
+ class JSXExpressionContainer extends NodeBase {
14079
+ render(code, options) {
14080
+ const { mode } = this.scope.context.options.jsx;
14081
+ if (mode !== 'preserve') {
14082
+ code.remove(this.start, this.expression.start);
14083
+ code.remove(this.expression.end, this.end);
14084
+ }
14085
+ this.expression.render(code, options);
14086
+ }
14087
+ }
14088
+
14089
+ function getRenderedJsxChildren(children) {
14090
+ let renderedChildren = 0;
14091
+ for (const child of children) {
14092
+ if (!(child instanceof JSXExpressionContainer && child.expression instanceof JSXEmptyExpression)) {
14093
+ renderedChildren++;
14094
+ }
14095
+ }
14096
+ return renderedChildren;
14097
+ }
14098
+
14099
+ function getAndIncludeFactoryVariable(factory, preserve, importSource, node) {
14100
+ const [baseName, nestedName] = factory.split('.');
14101
+ let factoryVariable;
14102
+ if (importSource) {
14103
+ factoryVariable = node.scope.context.getImportedJsxFactoryVariable(nestedName ? 'default' : baseName, node.start, importSource);
14104
+ if (preserve) {
14105
+ // This pretends we are accessing an included global variable of the same name
14106
+ const globalVariable = node.scope.findGlobal(baseName);
14107
+ globalVariable.include();
14108
+ // This excludes this variable from renaming
14109
+ factoryVariable.globalName = baseName;
14110
+ }
14111
+ }
14112
+ else {
14113
+ factoryVariable = node.scope.findGlobal(baseName);
14114
+ }
14115
+ node.scope.context.includeVariableInModule(factoryVariable);
14116
+ if (factoryVariable instanceof LocalVariable) {
14117
+ factoryVariable.consolidateInitializers();
14118
+ factoryVariable.addUsedPlace(node);
14119
+ node.scope.context.requestTreeshakingPass();
14120
+ }
14121
+ return factoryVariable;
14122
+ }
14123
+
14124
+ class JSXElementBase extends NodeBase {
14125
+ constructor() {
14126
+ super(...arguments);
14127
+ this.factoryVariable = null;
14128
+ this.factory = null;
14129
+ }
14130
+ initialise() {
14131
+ super.initialise();
14132
+ const { importSource } = (this.jsxMode = this.getRenderingMode());
14133
+ if (importSource) {
14134
+ this.scope.context.addImportSource(importSource);
14135
+ }
14136
+ }
14137
+ include(context, includeChildrenRecursively) {
14138
+ if (!this.included) {
14139
+ const { factory, importSource, mode } = this.jsxMode;
14140
+ if (factory) {
14141
+ this.factory = factory;
14142
+ this.factoryVariable = getAndIncludeFactoryVariable(factory, mode === 'preserve', importSource, this);
14143
+ }
14144
+ }
14145
+ super.include(context, includeChildrenRecursively);
14146
+ }
14147
+ applyDeoptimizations() { }
14148
+ getRenderingMode() {
14149
+ const jsx = this.scope.context.options.jsx;
14150
+ const { mode, factory, importSource } = jsx;
14151
+ if (mode === 'automatic') {
14152
+ return {
14153
+ factory: getRenderedJsxChildren(this.children) > 1 ? 'jsxs' : 'jsx',
14154
+ importSource: jsx.jsxImportSource,
14155
+ mode
14156
+ };
14157
+ }
14158
+ return { factory, importSource, mode };
14159
+ }
14160
+ renderChildren(code, options, openingEnd) {
14161
+ const { children } = this;
14162
+ let hasMultipleChildren = false;
14163
+ let childrenEnd = openingEnd;
14164
+ let firstChild = null;
14165
+ for (const child of children) {
14166
+ if (child instanceof JSXExpressionContainer &&
14167
+ child.expression instanceof JSXEmptyExpression) {
14168
+ code.remove(childrenEnd, child.end);
14169
+ }
14170
+ else {
14171
+ code.appendLeft(childrenEnd, ', ');
14172
+ child.render(code, options);
14173
+ if (firstChild) {
14174
+ hasMultipleChildren = true;
14175
+ }
14176
+ else {
14177
+ firstChild = child;
14178
+ }
14179
+ }
14180
+ childrenEnd = child.end;
14181
+ }
14182
+ return { childrenEnd, firstChild, hasMultipleChildren };
14183
+ }
14184
+ }
14185
+
14186
+ class JSXElement extends JSXElementBase {
14187
+ render(code, options) {
14188
+ switch (this.jsxMode.mode) {
14189
+ case 'classic': {
14190
+ this.renderClassicMode(code, options);
14191
+ break;
14192
+ }
14193
+ case 'automatic': {
14194
+ this.renderAutomaticMode(code, options);
14195
+ break;
14196
+ }
14197
+ default: {
14198
+ super.render(code, options);
14199
+ }
14200
+ }
14201
+ }
14202
+ getRenderingMode() {
14203
+ const jsx = this.scope.context.options.jsx;
14204
+ const { mode, factory, importSource } = jsx;
14205
+ if (mode === 'automatic') {
14206
+ // In the case there is a key after a spread attribute, we fall back to
14207
+ // classic mode, see https://github.com/facebook/react/issues/20031#issuecomment-710346866
14208
+ // for reasoning.
14209
+ let hasSpread = false;
14210
+ for (const attribute of this.openingElement.attributes) {
14211
+ if (attribute instanceof JSXSpreadAttribute) {
14212
+ hasSpread = true;
14213
+ }
14214
+ else if (hasSpread && attribute.name.name === 'key') {
14215
+ return { factory, importSource, mode: 'classic' };
14216
+ }
14217
+ }
14218
+ }
14219
+ return super.getRenderingMode();
14220
+ }
14221
+ renderClassicMode(code, options) {
14222
+ const { snippets: { getPropertyAccess }, useOriginalName } = options;
14223
+ const { closingElement, end, factory, factoryVariable, openingElement: { end: openingEnd, selfClosing } } = this;
14224
+ const [, ...nestedName] = factory.split('.');
14225
+ const { firstAttribute, hasAttributes, hasSpread, inObject, previousEnd } = this.renderAttributes(code, options, [factoryVariable.getName(getPropertyAccess, useOriginalName), ...nestedName].join('.'), false);
14226
+ this.wrapAttributes(code, inObject, hasAttributes, hasSpread, firstAttribute, 'null', previousEnd);
14227
+ this.renderChildren(code, options, openingEnd);
14228
+ if (selfClosing) {
14229
+ code.appendLeft(end, ')');
14230
+ }
14231
+ else {
14232
+ closingElement.render(code, options);
14233
+ }
14234
+ }
14235
+ renderAutomaticMode(code, options) {
14236
+ const { snippets: { getPropertyAccess }, useOriginalName } = options;
14237
+ const { closingElement, end, factoryVariable, openingElement: { end: openindEnd, selfClosing } } = this;
14238
+ let { firstAttribute, hasAttributes, hasSpread, inObject, keyAttribute, previousEnd } = this.renderAttributes(code, options, factoryVariable.getName(getPropertyAccess, useOriginalName), true);
14239
+ const { firstChild, hasMultipleChildren, childrenEnd } = this.renderChildren(code, options, openindEnd);
14240
+ if (firstChild) {
14241
+ code.prependRight(firstChild.start, `children: ${hasMultipleChildren ? '[' : ''}`);
14242
+ if (!inObject) {
14243
+ code.prependRight(firstChild.start, '{ ');
14244
+ inObject = true;
14245
+ }
14246
+ previousEnd = closingElement.start;
14247
+ if (hasMultipleChildren) {
14248
+ code.appendLeft(previousEnd, ']');
14249
+ }
14250
+ }
14251
+ this.wrapAttributes(code, inObject, hasAttributes || !!firstChild, hasSpread, firstAttribute || firstChild, '{}', childrenEnd);
14252
+ if (keyAttribute) {
14253
+ const { value } = keyAttribute;
14254
+ // This will appear to the left of the moved code...
14255
+ code.appendLeft(childrenEnd, ', ');
14256
+ if (value) {
14257
+ code.move(value.start, value.end, childrenEnd);
14258
+ }
14259
+ else {
14260
+ code.appendLeft(childrenEnd, 'true');
14261
+ }
14262
+ }
14263
+ if (selfClosing) {
14264
+ // Moving the key attribute will also move the parenthesis to the right position
14265
+ code.appendLeft(keyAttribute?.value?.end || end, ')');
14266
+ }
14267
+ else {
14268
+ closingElement.render(code, options);
14269
+ }
14270
+ }
14271
+ renderAttributes(code, options, factoryName, extractKeyAttribute) {
14272
+ const { jsxMode: { mode }, openingElement } = this;
14273
+ const { attributes, end: openingEnd, start: openingStart, name: { start: nameStart, end: nameEnd } } = openingElement;
14274
+ code.update(openingStart, nameStart, `/*#__PURE__*/${factoryName}(`);
14275
+ openingElement.render(code, options, { jsxMode: mode });
14276
+ let keyAttribute = null;
14277
+ let hasSpread = false;
14278
+ let inObject = false;
14279
+ let previousEnd = nameEnd;
14280
+ let hasAttributes = false;
14281
+ let firstAttribute = null;
14282
+ for (const attribute of attributes) {
14283
+ if (attribute instanceof JSXAttribute) {
14284
+ if (extractKeyAttribute && attribute.name.name === 'key') {
14285
+ keyAttribute = attribute;
14286
+ code.remove(previousEnd, attribute.value?.start || attribute.end);
14287
+ continue;
14288
+ }
14289
+ code.appendLeft(previousEnd, ',');
14290
+ if (!inObject) {
14291
+ code.prependRight(attribute.start, '{ ');
14292
+ inObject = true;
14293
+ }
14294
+ hasAttributes = true;
14295
+ }
14296
+ else {
14297
+ if (inObject) {
14298
+ if (hasAttributes) {
14299
+ code.appendLeft(previousEnd, ' ');
14300
+ }
14301
+ code.appendLeft(previousEnd, '},');
14302
+ inObject = false;
14303
+ }
14304
+ else {
14305
+ code.appendLeft(previousEnd, ',');
14306
+ }
14307
+ hasSpread = true;
14308
+ }
14309
+ previousEnd = attribute.end;
14310
+ if (!firstAttribute) {
14311
+ firstAttribute = attribute;
14312
+ }
14313
+ }
14314
+ code.remove(attributes.at(-1)?.end || previousEnd, openingEnd);
14315
+ return { firstAttribute, hasAttributes, hasSpread, inObject, keyAttribute, previousEnd };
14316
+ }
14317
+ wrapAttributes(code, inObject, hasAttributes, hasSpread, firstAttribute, missingAttributesFallback, attributesEnd) {
14318
+ if (inObject) {
14319
+ code.appendLeft(attributesEnd, ' }');
14320
+ }
14321
+ if (hasSpread) {
14322
+ if (hasAttributes) {
14323
+ const { start } = firstAttribute;
14324
+ if (firstAttribute instanceof JSXSpreadAttribute) {
14325
+ code.prependRight(start, '{}, ');
14326
+ }
14327
+ code.prependRight(start, 'Object.assign(');
14328
+ code.appendLeft(attributesEnd, ')');
14329
+ }
14330
+ }
14331
+ else if (!hasAttributes) {
14332
+ code.appendLeft(attributesEnd, `, ${missingAttributesFallback}`);
14333
+ }
14334
+ }
14335
+ }
14336
+
14337
+ class JSXFragment extends JSXElementBase {
14338
+ render(code, options) {
14339
+ switch (this.jsxMode.mode) {
14340
+ case 'classic': {
14341
+ this.renderClassicMode(code, options);
14342
+ break;
14343
+ }
14344
+ case 'automatic': {
14345
+ this.renderAutomaticMode(code, options);
14346
+ break;
14347
+ }
14348
+ default: {
14349
+ super.render(code, options);
14350
+ }
14351
+ }
14352
+ }
14353
+ renderClassicMode(code, options) {
14354
+ const { snippets: { getPropertyAccess }, useOriginalName } = options;
14355
+ const { closingFragment, factory, factoryVariable, openingFragment, start } = this;
14356
+ const [, ...nestedName] = factory.split('.');
14357
+ openingFragment.render(code, options);
14358
+ code.prependRight(start, `/*#__PURE__*/${[
14359
+ factoryVariable.getName(getPropertyAccess, useOriginalName),
14360
+ ...nestedName
14361
+ ].join('.')}(`);
14362
+ code.appendLeft(openingFragment.end, ', null');
14363
+ this.renderChildren(code, options, openingFragment.end);
14364
+ closingFragment.render(code, options);
14365
+ }
14366
+ renderAutomaticMode(code, options) {
14367
+ const { snippets: { getPropertyAccess }, useOriginalName } = options;
14368
+ const { closingFragment, factoryVariable, openingFragment, start } = this;
14369
+ openingFragment.render(code, options);
14370
+ code.prependRight(start, `/*#__PURE__*/${factoryVariable.getName(getPropertyAccess, useOriginalName)}(`);
14371
+ const { firstChild, hasMultipleChildren, childrenEnd } = this.renderChildren(code, options, openingFragment.end);
14372
+ if (firstChild) {
14373
+ code.prependRight(firstChild.start, `{ children: ${hasMultipleChildren ? '[' : ''}`);
14374
+ if (hasMultipleChildren) {
14375
+ code.appendLeft(closingFragment.start, ']');
14376
+ }
14377
+ code.appendLeft(childrenEnd, ' }');
14378
+ }
14379
+ else {
14380
+ code.appendLeft(openingFragment.end, ', {}');
14381
+ }
14382
+ closingFragment.render(code, options);
14383
+ }
14384
+ }
14385
+
14386
+ class JSXMemberExpression extends NodeBase {
14387
+ }
14388
+
14389
+ class JSXNamespacedName extends NodeBase {
14390
+ }
14391
+
14392
+ class JSXOpeningElement extends NodeBase {
14393
+ render(code, options, { jsxMode = this.scope.context.options.jsx.mode } = {}) {
14394
+ this.name.render(code, options);
14395
+ for (const attribute of this.attributes) {
14396
+ attribute.render(code, options, { jsxMode });
14397
+ }
14398
+ }
14399
+ }
14400
+
14401
+ class JSXOpeningFragment extends NodeBase {
14402
+ constructor() {
14403
+ super(...arguments);
14404
+ this.fragment = null;
14405
+ this.fragmentVariable = null;
14406
+ }
14407
+ include(context, includeChildrenRecursively) {
14408
+ if (!this.included) {
14409
+ const jsx = this.scope.context.options.jsx;
14410
+ if (jsx.mode === 'automatic') {
14411
+ this.fragment = 'Fragment';
14412
+ this.fragmentVariable = getAndIncludeFactoryVariable('Fragment', false, jsx.jsxImportSource, this);
14413
+ }
14414
+ else {
14415
+ const { fragment, importSource, mode } = jsx;
14416
+ if (fragment != null) {
14417
+ this.fragment = fragment;
14418
+ this.fragmentVariable = getAndIncludeFactoryVariable(fragment, mode === 'preserve', importSource, this);
14419
+ }
14420
+ }
14421
+ }
14422
+ super.include(context, includeChildrenRecursively);
14423
+ }
14424
+ render(code, options) {
14425
+ const { mode } = this.scope.context.options.jsx;
14426
+ if (mode !== 'preserve') {
14427
+ const { snippets: { getPropertyAccess }, useOriginalName } = options;
14428
+ const [, ...nestedFragment] = this.fragment.split('.');
14429
+ const fragment = [
14430
+ this.fragmentVariable.getName(getPropertyAccess, useOriginalName),
14431
+ ...nestedFragment
14432
+ ].join('.');
14433
+ code.update(this.start, this.end, fragment);
14434
+ }
14435
+ }
14436
+ }
14437
+
14438
+ class JSXSpreadChild extends NodeBase {
14439
+ render(code, options) {
14440
+ super.render(code, options);
14441
+ const { mode } = this.scope.context.options.jsx;
14442
+ if (mode !== 'preserve') {
14443
+ code.overwrite(this.start, this.expression.start, '...', { contentOnly: true });
14444
+ code.overwrite(this.expression.end, this.end, '', { contentOnly: true });
14445
+ }
14446
+ }
14447
+ }
14448
+
14449
+ class JSXText extends NodeBase {
14450
+ render(code) {
14451
+ const { mode } = this.scope.context.options.jsx;
14452
+ if (mode !== 'preserve') {
14453
+ code.overwrite(this.start, this.end, JSON.stringify(this.value), {
14454
+ contentOnly: true
14455
+ });
14456
+ }
14457
+ }
14458
+ }
14459
+
13895
14460
  class LabeledStatement extends NodeBase {
13896
14461
  hasEffects(context) {
13897
14462
  const { brokenFlow, includedLabels } = context;
@@ -15220,6 +15785,21 @@ const nodeTypeStrings = [
15220
15785
  'ImportExpression',
15221
15786
  'ImportNamespaceSpecifier',
15222
15787
  'ImportSpecifier',
15788
+ 'JSXAttribute',
15789
+ 'JSXClosingElement',
15790
+ 'JSXClosingFragment',
15791
+ 'JSXElement',
15792
+ 'JSXEmptyExpression',
15793
+ 'JSXExpressionContainer',
15794
+ 'JSXFragment',
15795
+ 'JSXIdentifier',
15796
+ 'JSXMemberExpression',
15797
+ 'JSXNamespacedName',
15798
+ 'JSXOpeningElement',
15799
+ 'JSXOpeningFragment',
15800
+ 'JSXSpreadAttribute',
15801
+ 'JSXSpreadChild',
15802
+ 'JSXText',
15223
15803
  'LabeledStatement',
15224
15804
  'Literal',
15225
15805
  'Literal',
@@ -15302,6 +15882,21 @@ const nodeConstructors$1 = [
15302
15882
  ImportExpression,
15303
15883
  ImportNamespaceSpecifier,
15304
15884
  ImportSpecifier,
15885
+ JSXAttribute,
15886
+ JSXClosingElement,
15887
+ JSXClosingFragment,
15888
+ JSXElement,
15889
+ JSXEmptyExpression,
15890
+ JSXExpressionContainer,
15891
+ JSXFragment,
15892
+ JSXIdentifier,
15893
+ JSXMemberExpression,
15894
+ JSXNamespacedName,
15895
+ JSXOpeningElement,
15896
+ JSXOpeningFragment,
15897
+ JSXSpreadAttribute,
15898
+ JSXSpreadChild,
15899
+ JSXText,
15305
15900
  LabeledStatement,
15306
15901
  Literal,
15307
15902
  Literal,
@@ -15608,6 +16203,74 @@ const bufferParsers = [
15608
16203
  node.imported =
15609
16204
  importedPosition === 0 ? node.local : convertNode(node, scope, importedPosition, buffer);
15610
16205
  },
16206
+ function jsxAttribute(node, position, buffer) {
16207
+ const { scope } = node;
16208
+ node.name = convertNode(node, scope, buffer[position], buffer);
16209
+ const valuePosition = buffer[position + 1];
16210
+ node.value = valuePosition === 0 ? null : convertNode(node, scope, valuePosition, buffer);
16211
+ },
16212
+ function jsxClosingElement(node, position, buffer) {
16213
+ const { scope } = node;
16214
+ node.name = convertNode(node, scope, buffer[position], buffer);
16215
+ },
16216
+ function jsxClosingFragment() { },
16217
+ function jsxElement(node, position, buffer) {
16218
+ const { scope } = node;
16219
+ node.openingElement = convertNode(node, scope, buffer[position], buffer);
16220
+ node.children = convertNodeList(node, scope, buffer[position + 1], buffer);
16221
+ const closingElementPosition = buffer[position + 2];
16222
+ node.closingElement =
16223
+ closingElementPosition === 0
16224
+ ? null
16225
+ : convertNode(node, scope, closingElementPosition, buffer);
16226
+ },
16227
+ function jsxEmptyExpression() { },
16228
+ function jsxExpressionContainer(node, position, buffer) {
16229
+ const { scope } = node;
16230
+ node.expression = convertNode(node, scope, buffer[position], buffer);
16231
+ },
16232
+ function jsxFragment(node, position, buffer) {
16233
+ const { scope } = node;
16234
+ node.openingFragment = convertNode(node, scope, buffer[position], buffer);
16235
+ node.children = convertNodeList(node, scope, buffer[position + 1], buffer);
16236
+ node.closingFragment = convertNode(node, scope, buffer[position + 2], buffer);
16237
+ },
16238
+ function jsxIdentifier(node, position, buffer) {
16239
+ node.name = buffer.convertString(buffer[position]);
16240
+ },
16241
+ function jsxMemberExpression(node, position, buffer) {
16242
+ const { scope } = node;
16243
+ node.object = convertNode(node, scope, buffer[position], buffer);
16244
+ node.property = convertNode(node, scope, buffer[position + 1], buffer);
16245
+ },
16246
+ function jsxNamespacedName(node, position, buffer) {
16247
+ const { scope } = node;
16248
+ node.namespace = convertNode(node, scope, buffer[position], buffer);
16249
+ node.name = convertNode(node, scope, buffer[position + 1], buffer);
16250
+ },
16251
+ function jsxOpeningElement(node, position, buffer) {
16252
+ const { scope } = node;
16253
+ const flags = buffer[position];
16254
+ node.selfClosing = (flags & 1) === 1;
16255
+ node.name = convertNode(node, scope, buffer[position + 1], buffer);
16256
+ node.attributes = convertNodeList(node, scope, buffer[position + 2], buffer);
16257
+ },
16258
+ function jsxOpeningFragment(node) {
16259
+ node.attributes = [];
16260
+ node.selfClosing = false;
16261
+ },
16262
+ function jsxSpreadAttribute(node, position, buffer) {
16263
+ const { scope } = node;
16264
+ node.argument = convertNode(node, scope, buffer[position], buffer);
16265
+ },
16266
+ function jsxSpreadChild(node, position, buffer) {
16267
+ const { scope } = node;
16268
+ node.expression = convertNode(node, scope, buffer[position], buffer);
16269
+ },
16270
+ function jsxText(node, position, buffer) {
16271
+ node.value = buffer.convertString(buffer[position]);
16272
+ node.raw = buffer.convertString(buffer[position + 1]);
16273
+ },
15611
16274
  function labeledStatement(node, position, buffer) {
15612
16275
  const { scope } = node;
15613
16276
  node.label = convertNode(node, scope, buffer[position], buffer);
@@ -15897,6 +16560,21 @@ const nodeConstructors = {
15897
16560
  ImportExpression,
15898
16561
  ImportNamespaceSpecifier,
15899
16562
  ImportSpecifier,
16563
+ JSXAttribute,
16564
+ JSXClosingElement,
16565
+ JSXClosingFragment,
16566
+ JSXElement,
16567
+ JSXEmptyExpression,
16568
+ JSXExpressionContainer,
16569
+ JSXFragment,
16570
+ JSXIdentifier,
16571
+ JSXMemberExpression,
16572
+ JSXNamespacedName,
16573
+ JSXOpeningElement,
16574
+ JSXOpeningFragment,
16575
+ JSXSpreadAttribute,
16576
+ JSXSpreadChild,
16577
+ JSXText,
15900
16578
  LabeledStatement,
15901
16579
  Literal,
15902
16580
  LogicalExpression,
@@ -16757,11 +17435,13 @@ class Module {
16757
17435
  addExport: this.addExport.bind(this),
16758
17436
  addImport: this.addImport.bind(this),
16759
17437
  addImportMeta: this.addImportMeta.bind(this),
17438
+ addImportSource: this.addImportSource.bind(this),
16760
17439
  code, // Only needed for debugging
16761
17440
  deoptimizationTracker: this.graph.deoptimizationTracker,
16762
17441
  error: this.error.bind(this),
16763
17442
  fileName, // Needed for warnings
16764
17443
  getExports: this.getExports.bind(this),
17444
+ getImportedJsxFactoryVariable: this.getImportedJsxFactoryVariable.bind(this),
16765
17445
  getModuleExecIndex: () => this.execIndex,
16766
17446
  getModuleName: this.basename.bind(this),
16767
17447
  getNodeConstructor: (name) => nodeConstructors[name] || nodeConstructors.UnknownNode,
@@ -16791,7 +17471,7 @@ class Module {
16791
17471
  else {
16792
17472
  // Measuring asynchronous code does not provide reasonable results
16793
17473
  timeEnd('generate ast', 3);
16794
- const astBuffer = await native_js.parseAsync(code, false);
17474
+ const astBuffer = await native_js.parseAsync(code, false, this.options.jsx !== false);
16795
17475
  timeStart('generate ast', 3);
16796
17476
  this.ast = convertProgram(astBuffer, programParent, this.scope);
16797
17477
  // Make lazy and apply LRU cache to not hog the memory
@@ -16984,6 +17664,11 @@ class Module {
16984
17664
  });
16985
17665
  }
16986
17666
  }
17667
+ addImportSource(importSource) {
17668
+ if (importSource && !this.sourcesWithAttributes.has(importSource)) {
17669
+ this.sourcesWithAttributes.set(importSource, parseAst_js.EMPTY_OBJECT);
17670
+ }
17671
+ }
16987
17672
  addImportMeta(node) {
16988
17673
  this.importMetas.push(node);
16989
17674
  }
@@ -17047,6 +17732,15 @@ class Module {
17047
17732
  this.sourcesWithAttributes.set(source, parsedAttributes);
17048
17733
  }
17049
17734
  }
17735
+ getImportedJsxFactoryVariable(baseName, nodeStart, importSource) {
17736
+ const { id } = this.resolvedIds[importSource];
17737
+ const module = this.graph.modulesById.get(id);
17738
+ const [variable] = module.getVariableForExportName(baseName);
17739
+ if (!variable) {
17740
+ return this.error(parseAst_js.logMissingJsxExport(baseName, id, this.id), nodeStart);
17741
+ }
17742
+ return variable;
17743
+ }
17050
17744
  getVariableFromNamespaceReexports(name, importerForSideEffects, searchedNamesAndModules) {
17051
17745
  let foundSyntheticDeclaration = null;
17052
17746
  const foundInternalDeclarations = new Map();
@@ -17167,7 +17861,7 @@ class Module {
17167
17861
  }
17168
17862
  tryParse() {
17169
17863
  try {
17170
- return parseAst_js.parseAst(this.info.code);
17864
+ return parseAst_js.parseAst(this.info.code, { jsx: this.options.jsx !== false });
17171
17865
  }
17172
17866
  catch (error_) {
17173
17867
  return this.error(parseAst_js.logModuleParseError(error_, this.id), error_.pos);
@@ -19791,7 +20485,7 @@ class Bundle {
19791
20485
  for (const file of Object.values(bundle)) {
19792
20486
  if ('code' in file) {
19793
20487
  try {
19794
- parseAst_js.parseAst(file.code);
20488
+ parseAst_js.parseAst(file.code, { jsx: this.inputOptions.jsx !== false });
19795
20489
  }
19796
20490
  catch (error_) {
19797
20491
  this.inputOptions.onLog(parseAst_js.LOGLEVEL_WARN, parseAst_js.logChunkInvalid(file, error_));
@@ -20866,6 +21560,7 @@ async function normalizeInputOptions(config, watchMode) {
20866
21560
  experimentalLogSideEffects: config.experimentalLogSideEffects || false,
20867
21561
  external: getIdMatcher(config.external),
20868
21562
  input: getInput(config),
21563
+ jsx: getJsx(config),
20869
21564
  logLevel,
20870
21565
  makeAbsoluteExternalsRelative: config.makeAbsoluteExternalsRelative ?? 'ifRelativeSource',
20871
21566
  maxParallelFileOps,
@@ -20911,6 +21606,46 @@ const getInput = (config) => {
20911
21606
  const configInput = config.input;
20912
21607
  return configInput == null ? [] : typeof configInput === 'string' ? [configInput] : configInput;
20913
21608
  };
21609
+ const getJsx = (config) => {
21610
+ const configJsx = config.jsx;
21611
+ if (!configJsx)
21612
+ return false;
21613
+ const configWithPreset = getOptionWithPreset(configJsx, jsxPresets, 'jsx', parseAst_js.URL_JSX, 'false, ');
21614
+ const { factory, importSource, mode } = configWithPreset;
21615
+ switch (mode) {
21616
+ case 'automatic': {
21617
+ return {
21618
+ factory: factory || 'React.createElement',
21619
+ importSource: importSource || 'react',
21620
+ jsxImportSource: configWithPreset.jsxImportSource || 'react/jsx-runtime',
21621
+ mode: 'automatic'
21622
+ };
21623
+ }
21624
+ case 'preserve': {
21625
+ if (importSource && !(factory || configWithPreset.fragment)) {
21626
+ parseAst_js.error(parseAst_js.logInvalidOption('jsx', parseAst_js.URL_JSX, 'when preserving JSX and specifying an importSource, you also need to specify a factory or fragment'));
21627
+ }
21628
+ return {
21629
+ factory: factory || null,
21630
+ fragment: configWithPreset.fragment || null,
21631
+ importSource: importSource || null,
21632
+ mode: 'preserve'
21633
+ };
21634
+ }
21635
+ // case 'classic':
21636
+ default: {
21637
+ if (mode && mode !== 'classic') {
21638
+ parseAst_js.error(parseAst_js.logInvalidOption('jsx.mode', parseAst_js.URL_JSX, 'mode must be "automatic", "classic" or "preserve"', mode));
21639
+ }
21640
+ return {
21641
+ factory: factory || 'React.createElement',
21642
+ fragment: configWithPreset.fragment || 'React.Fragment',
21643
+ importSource: importSource || null,
21644
+ mode: 'classic'
21645
+ };
21646
+ }
21647
+ }
21648
+ };
20914
21649
  const getMaxParallelFileOps = (config) => {
20915
21650
  const maxParallelFileOps = config.maxParallelFileOps;
20916
21651
  if (typeof maxParallelFileOps === 'number') {