what-compiler 0.10.0 → 0.11.0

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.
@@ -577,7 +577,7 @@ function whatBabelPlugin({ types: t }) {
577
577
  t.variableDeclarator(t.identifier(elId), t.callExpression(t.identifier(tmplId), []))
578
578
  ])
579
579
  ];
580
- applyDynamicAttrs(statements, elId, attributes, state);
580
+ applyDynamicAttrs(statements, elId, attributes, state, tagName);
581
581
  applyDynamicChildren(statements, elId, children, node, state);
582
582
  if (!state._pendingSetup) state._pendingSetup = [];
583
583
  state._pendingSetup.push(...statements);
@@ -620,8 +620,33 @@ function whatBabelPlugin({ types: t }) {
620
620
  const propsExpr = props.length > 0 ? t.objectExpression(props) : t.nullLiteral();
621
621
  return t.callExpression(t.identifier("h"), [t.stringLiteral(tagName), propsExpr, ...transformedChildren]);
622
622
  }
623
- function applyDynamicAttrs(statements, elId, attributes, state) {
623
+ const VALUE_PROP_TAGS = /* @__PURE__ */ new Set(["input", "textarea", "select", "option"]);
624
+ function applyDynamicAttrs(statements, elId, attributes, state, tagName) {
624
625
  function buildSetPropCall(propName, valueExpr) {
626
+ if (propName === "class") {
627
+ state.needsSetClass = true;
628
+ return t.callExpression(t.identifier("_$setClass"), [t.identifier(elId), valueExpr]);
629
+ }
630
+ if (propName === "style") {
631
+ state.needsSetStyle = true;
632
+ return t.callExpression(t.identifier("_$setStyle"), [t.identifier(elId), valueExpr]);
633
+ }
634
+ if (propName === "value" && tagName && VALUE_PROP_TAGS.has(tagName)) {
635
+ state.needsSetValue = true;
636
+ return t.callExpression(t.identifier("_$setValue"), [t.identifier(elId), valueExpr]);
637
+ }
638
+ if (propName === "checked" && tagName === "input") {
639
+ state.needsSetChecked = true;
640
+ return t.callExpression(t.identifier("_$setChecked"), [t.identifier(elId), valueExpr]);
641
+ }
642
+ if (propName.startsWith("data-") || propName.startsWith("aria-")) {
643
+ state.needsSetAttr = true;
644
+ return t.callExpression(t.identifier("_$setAttr"), [
645
+ t.identifier(elId),
646
+ t.stringLiteral(propName),
647
+ valueExpr
648
+ ]);
649
+ }
625
650
  state.needsSetProp = true;
626
651
  return t.callExpression(t.identifier("_$setProp"), [
627
652
  t.identifier(elId),
@@ -629,6 +654,14 @@ function whatBabelPlugin({ types: t }) {
629
654
  valueExpr
630
655
  ]);
631
656
  }
657
+ let delegateInitEmitted = false;
658
+ function emitDelegateInit() {
659
+ if (delegateInitEmitted) return;
660
+ delegateInitEmitted = true;
661
+ statements.push(
662
+ t.expressionStatement(t.callExpression(t.identifier("_$delegate$"), []))
663
+ );
664
+ }
632
665
  for (const attr of attributes) {
633
666
  if (t.isJSXSpreadAttribute(attr)) {
634
667
  state.needsSpread = true;
@@ -669,6 +702,7 @@ function whatBabelPlugin({ types: t }) {
669
702
  state.needsDelegation = true;
670
703
  if (!state.delegatedEvents) state.delegatedEvents = /* @__PURE__ */ new Set();
671
704
  state.delegatedEvents.add(event);
705
+ emitDelegateInit();
672
706
  statements.push(
673
707
  t.expressionStatement(
674
708
  t.assignmentExpression(
@@ -812,6 +846,50 @@ function whatBabelPlugin({ types: t }) {
812
846
  }
813
847
  }
814
848
  }
849
+ function buildsDOM(node) {
850
+ if (!node || typeof node !== "object") return false;
851
+ if (Array.isArray(node)) return node.some(buildsDOM);
852
+ if (node.type === "JSXElement" || node.type === "JSXFragment") return true;
853
+ if (node.type === "CallExpression" && node.callee && node.callee.type === "Identifier" && (node.callee.name === "_$mapArray" || node.callee.name === "mapArray")) {
854
+ return true;
855
+ }
856
+ for (const key of Object.keys(node)) {
857
+ if (key === "loc" || key === "start" || key === "end" || key === "leadingComments" || key === "trailingComments" || key === "innerComments") continue;
858
+ const v = node[key];
859
+ if (v && typeof v === "object" && buildsDOM(v)) return true;
860
+ }
861
+ return false;
862
+ }
863
+ function memoizeBranchCondition(expr, statements, state) {
864
+ let testExpr = null;
865
+ let isTernary = false;
866
+ if (t.isConditionalExpression(expr)) {
867
+ testExpr = expr.test;
868
+ isTernary = true;
869
+ } else if (t.isLogicalExpression(expr) && (expr.operator === "&&" || expr.operator === "||")) {
870
+ testExpr = expr.left;
871
+ } else {
872
+ return expr;
873
+ }
874
+ if (!isPotentiallyReactive(testExpr, state.signalNames, state.importedIdentifiers)) return expr;
875
+ const branches = isTernary ? [expr.consequent, expr.alternate] : [expr.right];
876
+ if (!branches.some(buildsDOM)) return expr;
877
+ const condId = state.nextMemoId();
878
+ state.needsMemo = true;
879
+ const memoBody = isTernary ? t.unaryExpression("!", t.unaryExpression("!", testExpr)) : testExpr;
880
+ statements.push(
881
+ t.variableDeclaration("const", [
882
+ t.variableDeclarator(
883
+ t.identifier(condId),
884
+ t.callExpression(t.identifier("_$memo"), [
885
+ t.arrowFunctionExpression([], memoBody)
886
+ ])
887
+ )
888
+ ])
889
+ );
890
+ const condRead = t.callExpression(t.identifier(condId), []);
891
+ return isTernary ? t.conditionalExpression(condRead, expr.consequent, expr.alternate) : t.logicalExpression(expr.operator, condRead, expr.right);
892
+ }
815
893
  function applyDynamicChildren(statements, elId, children, parentNode, state) {
816
894
  const entries = [];
817
895
  let childIndex = 0;
@@ -884,11 +962,16 @@ function whatBabelPlugin({ types: t }) {
884
962
  let expr = entry.child.expression;
885
963
  const marker = getMarker(entry.childIndex);
886
964
  state.needsInsert = true;
887
- const mapResult = tryLowerMapToMapArray(expr, state);
965
+ let mapResult = tryLowerMapToMapArray(expr, state);
888
966
  if (mapResult) {
889
967
  state.needsMapArray = true;
890
968
  const isBareMapArray = t.isCallExpression(mapResult) && t.isIdentifier(mapResult.callee) && (mapResult.callee.name === "_$mapArray" || mapResult.callee.name === "mapArray");
891
969
  const isArrowAlready = t.isArrowFunctionExpression(mapResult);
970
+ if (isArrowAlready && t.isExpression(mapResult.body)) {
971
+ mapResult.body = memoizeBranchCondition(mapResult.body, statements, state);
972
+ } else if (!isBareMapArray && !isArrowAlready) {
973
+ mapResult = memoizeBranchCondition(mapResult, statements, state);
974
+ }
892
975
  const insertArg = isBareMapArray || isArrowAlready ? mapResult : t.arrowFunctionExpression([], mapResult);
893
976
  statements.push(
894
977
  t.expressionStatement(
@@ -917,6 +1000,7 @@ function whatBabelPlugin({ types: t }) {
917
1000
  continue;
918
1001
  }
919
1002
  if (isPotentiallyReactive(expr, state.signalNames, state.importedIdentifiers)) {
1003
+ expr = memoizeBranchCondition(expr, statements, state);
920
1004
  const insertCall = t.callExpression(t.identifier("_$insert"), [
921
1005
  t.identifier(elId),
922
1006
  t.arrowFunctionExpression([], expr),
@@ -974,7 +1058,7 @@ function whatBabelPlugin({ types: t }) {
974
1058
  ])
975
1059
  );
976
1060
  }
977
- applyDynamicAttrs(statements, childElRef, entry.child.openingElement.attributes, state);
1061
+ applyDynamicAttrs(statements, childElRef, entry.child.openingElement.attributes, state, entry.child.openingElement.name.name);
978
1062
  applyDynamicChildren(statements, childElRef, entry.child.children, entry.child, state);
979
1063
  continue;
980
1064
  }
@@ -982,8 +1066,9 @@ function whatBabelPlugin({ types: t }) {
982
1066
  for (const fChild of entry.child.children) {
983
1067
  if (t.isJSXExpressionContainer(fChild) && !t.isJSXEmptyExpression(fChild.expression)) {
984
1068
  state.needsInsert = true;
985
- const expr = fChild.expression;
1069
+ let expr = fChild.expression;
986
1070
  if (isPotentiallyReactive(expr, state.signalNames, state.importedIdentifiers)) {
1071
+ expr = memoizeBranchCondition(expr, statements, state);
987
1072
  statements.push(
988
1073
  t.expressionStatement(
989
1074
  t.callExpression(t.identifier("_$insert"), [
@@ -1276,8 +1361,26 @@ function whatBabelPlugin({ types: t }) {
1276
1361
  condition = whenExpr;
1277
1362
  }
1278
1363
  const vId = path3.scope ? path3.scope.generateUidIdentifier("v") : t.identifier("_v");
1279
- const consequent = t.isFunction(contentExpr) ? t.callExpression(contentExpr, [t.cloneNode(vId)]) : contentExpr;
1364
+ const contentIsFn = t.isFunction(contentExpr);
1365
+ const consequent = contentIsFn ? t.callExpression(contentExpr, [t.cloneNode(vId)]) : contentExpr;
1280
1366
  const alternate = fallbackExpr || t.nullLiteral();
1367
+ if (isPotentiallyReactive(condition, state.signalNames, state.importedIdentifiers)) {
1368
+ const condId = state.nextMemoId();
1369
+ state.needsMemo = true;
1370
+ const memoBody = contentIsFn ? condition : t.unaryExpression("!", t.unaryExpression("!", condition));
1371
+ if (!state._pendingSetup) state._pendingSetup = [];
1372
+ state._pendingSetup.push(
1373
+ t.variableDeclaration("const", [
1374
+ t.variableDeclarator(
1375
+ t.identifier(condId),
1376
+ t.callExpression(t.identifier("_$memo"), [
1377
+ t.arrowFunctionExpression([], memoBody)
1378
+ ])
1379
+ )
1380
+ ])
1381
+ );
1382
+ condition = t.callExpression(t.identifier(condId), []);
1383
+ }
1281
1384
  return t.arrowFunctionExpression([], t.blockStatement([
1282
1385
  t.variableDeclaration("const", [
1283
1386
  t.variableDeclarator(vId, condition)
@@ -1287,6 +1390,34 @@ function whatBabelPlugin({ types: t }) {
1287
1390
  )
1288
1391
  ]));
1289
1392
  }
1393
+ function lowerFragmentExprChild(expr, state) {
1394
+ if (!state._pendingSetup) state._pendingSetup = [];
1395
+ const setup = state._pendingSetup;
1396
+ const mapResult = tryLowerMapToMapArray(expr, state);
1397
+ if (mapResult) {
1398
+ state.needsMapArray = true;
1399
+ const isBareMapArray = t.isCallExpression(mapResult) && t.isIdentifier(mapResult.callee) && (mapResult.callee.name === "_$mapArray" || mapResult.callee.name === "mapArray");
1400
+ const isArrowAlready = t.isArrowFunctionExpression(mapResult);
1401
+ if (isArrowAlready && t.isExpression(mapResult.body)) {
1402
+ mapResult.body = memoizeBranchCondition(mapResult.body, setup, state);
1403
+ return mapResult;
1404
+ }
1405
+ if (isBareMapArray) return mapResult;
1406
+ const memoized = memoizeBranchCondition(mapResult, setup, state);
1407
+ return t.arrowFunctionExpression([], memoized);
1408
+ }
1409
+ const isMapArrayCall = t.isCallExpression(expr) && t.isIdentifier(expr.callee) && (expr.callee.name === "mapArray" || expr.callee.name === "_$mapArray");
1410
+ if (isMapArrayCall) {
1411
+ state.needsMapArray = true;
1412
+ if (expr.callee.name === "mapArray") expr.callee.name = "_$mapArray";
1413
+ return expr;
1414
+ }
1415
+ if (isPotentiallyReactive(expr, state.signalNames, state.importedIdentifiers)) {
1416
+ expr = memoizeBranchCondition(expr, setup, state);
1417
+ return t.arrowFunctionExpression([], expr);
1418
+ }
1419
+ return expr;
1420
+ }
1290
1421
  function transformFragmentFineGrained(path3, state) {
1291
1422
  const { node } = path3;
1292
1423
  const children = node.children;
@@ -1297,7 +1428,7 @@ function whatBabelPlugin({ types: t }) {
1297
1428
  if (text) transformed.push(t.stringLiteral(text));
1298
1429
  } else if (t.isJSXExpressionContainer(child)) {
1299
1430
  if (!t.isJSXEmptyExpression(child.expression)) {
1300
- transformed.push(child.expression);
1431
+ transformed.push(lowerFragmentExprChild(child.expression, state));
1301
1432
  }
1302
1433
  } else if (t.isJSXElement(child)) {
1303
1434
  transformed.push(transformElementFineGrained({ node: child }, state));
@@ -1317,6 +1448,46 @@ function whatBabelPlugin({ types: t }) {
1317
1448
  state.templates.push({ id, html });
1318
1449
  return id;
1319
1450
  }
1451
+ function transformJsxRoot(path3, state, transform) {
1452
+ const scope = path3.scope;
1453
+ let cache = state._signalNamesCache;
1454
+ if (!cache) cache = state._signalNamesCache = /* @__PURE__ */ new WeakMap();
1455
+ let names = cache.get(scope);
1456
+ if (!names) {
1457
+ names = collectSignalNamesFromScope(path3);
1458
+ cache.set(scope, names);
1459
+ }
1460
+ state.signalNames = names;
1461
+ state._pendingSetup = [];
1462
+ const transformed = transform(path3, state);
1463
+ const pending = state._pendingSetup;
1464
+ state._pendingSetup = [];
1465
+ if (pending.length > 0) {
1466
+ let stmtPath = path3;
1467
+ let crossedFunctionBoundary = false;
1468
+ while (stmtPath && !stmtPath.isStatement()) {
1469
+ if (stmtPath.isArrowFunctionExpression() || stmtPath.isFunctionExpression()) {
1470
+ crossedFunctionBoundary = true;
1471
+ }
1472
+ stmtPath = stmtPath.parentPath;
1473
+ }
1474
+ const inStatementList = stmtPath && stmtPath.isStatement() && (stmtPath.listKey === "body" || stmtPath.listKey === "consequent") && Array.isArray(stmtPath.container);
1475
+ if (inStatementList && !crossedFunctionBoundary) {
1476
+ stmtPath.insertBefore(pending);
1477
+ path3.replaceWith(transformed);
1478
+ } else {
1479
+ pending.push(t.returnStatement(transformed));
1480
+ path3.replaceWith(
1481
+ t.callExpression(
1482
+ t.arrowFunctionExpression([], t.blockStatement(pending)),
1483
+ []
1484
+ )
1485
+ );
1486
+ }
1487
+ } else {
1488
+ path3.replaceWith(transformed);
1489
+ }
1490
+ }
1320
1491
  return {
1321
1492
  name: "what-jsx-transform",
1322
1493
  visitor: {
@@ -1328,6 +1499,12 @@ function whatBabelPlugin({ types: t }) {
1328
1499
  state.needsMapArray = false;
1329
1500
  state.needsSpread = false;
1330
1501
  state.needsSetProp = false;
1502
+ state.needsMemo = false;
1503
+ state.needsSetClass = false;
1504
+ state.needsSetStyle = false;
1505
+ state.needsSetAttr = false;
1506
+ state.needsSetValue = false;
1507
+ state.needsSetChecked = false;
1331
1508
  state.needsH = false;
1332
1509
  state.needsCreateComponent = false;
1333
1510
  state.needsFragment = false;
@@ -1338,8 +1515,10 @@ function whatBabelPlugin({ types: t }) {
1338
1515
  state.templateMap = /* @__PURE__ */ new Map();
1339
1516
  state.templateCount = 0;
1340
1517
  state._varCounter = 0;
1518
+ state._memoCounter = 0;
1341
1519
  state._pendingSetup = [];
1342
1520
  state.nextVarId = () => `_el$${state._varCounter++}`;
1521
+ state.nextMemoId = () => `_c$${state._memoCounter++}`;
1343
1522
  state.signalNames = /* @__PURE__ */ new Set();
1344
1523
  state.importedIdentifiers = /* @__PURE__ */ new Set();
1345
1524
  for (const node of path3.node.body) {
@@ -1395,20 +1574,19 @@ function whatBabelPlugin({ types: t }) {
1395
1574
  },
1396
1575
  exit(path3, state) {
1397
1576
  for (const tmpl of state.templates.reverse()) {
1577
+ const tmplCall = t.callExpression(t.identifier("_$template"), [t.stringLiteral(tmpl.html)]);
1578
+ t.addComment(tmplCall, "leading", " @__PURE__ ");
1398
1579
  path3.unshiftContainer(
1399
1580
  "body",
1400
1581
  t.variableDeclaration("const", [
1401
- t.variableDeclarator(
1402
- t.identifier(tmpl.id),
1403
- t.callExpression(t.identifier("_$template"), [t.stringLiteral(tmpl.html)])
1404
- )
1582
+ t.variableDeclarator(t.identifier(tmpl.id), tmplCall)
1405
1583
  ])
1406
1584
  );
1407
1585
  }
1408
1586
  const fgSpecifiers = [];
1409
1587
  if (state.needsTemplate) {
1410
1588
  fgSpecifiers.push(
1411
- t.importSpecifier(t.identifier("_$template"), t.identifier("template"))
1589
+ t.importSpecifier(t.identifier("_$template"), t.identifier("_$template"))
1412
1590
  );
1413
1591
  }
1414
1592
  if (state.needsInsert) {
@@ -1436,6 +1614,36 @@ function whatBabelPlugin({ types: t }) {
1436
1614
  t.importSpecifier(t.identifier("_$setProp"), t.identifier("setProp"))
1437
1615
  );
1438
1616
  }
1617
+ if (state.needsMemo) {
1618
+ fgSpecifiers.push(
1619
+ t.importSpecifier(t.identifier("_$memo"), t.identifier("memo"))
1620
+ );
1621
+ }
1622
+ if (state.needsSetClass) {
1623
+ fgSpecifiers.push(
1624
+ t.importSpecifier(t.identifier("_$setClass"), t.identifier("setClass"))
1625
+ );
1626
+ }
1627
+ if (state.needsSetStyle) {
1628
+ fgSpecifiers.push(
1629
+ t.importSpecifier(t.identifier("_$setStyle"), t.identifier("setStyle"))
1630
+ );
1631
+ }
1632
+ if (state.needsSetAttr) {
1633
+ fgSpecifiers.push(
1634
+ t.importSpecifier(t.identifier("_$setAttr"), t.identifier("setAttr"))
1635
+ );
1636
+ }
1637
+ if (state.needsSetValue) {
1638
+ fgSpecifiers.push(
1639
+ t.importSpecifier(t.identifier("_$setValue"), t.identifier("setValue"))
1640
+ );
1641
+ }
1642
+ if (state.needsSetChecked) {
1643
+ fgSpecifiers.push(
1644
+ t.importSpecifier(t.identifier("_$setChecked"), t.identifier("setChecked"))
1645
+ );
1646
+ }
1439
1647
  if (state.needsCreateComponent) {
1440
1648
  fgSpecifiers.push(
1441
1649
  t.importSpecifier(t.identifier("_$createComponent"), t.identifier("_$createComponent"))
@@ -1493,58 +1701,36 @@ function whatBabelPlugin({ types: t }) {
1493
1701
  const eventArray = t.arrayExpression(
1494
1702
  [...state.delegatedEvents].map((e) => t.stringLiteral(e))
1495
1703
  );
1496
- path3.pushContainer(
1497
- "body",
1498
- t.expressionStatement(
1499
- t.callExpression(t.identifier("_$delegateEvents"), [eventArray])
1500
- )
1704
+ const helperFn = t.functionDeclaration(
1705
+ t.identifier("_$delegate$"),
1706
+ [],
1707
+ t.blockStatement([
1708
+ t.ifStatement(
1709
+ t.identifier("_$delegated$"),
1710
+ t.returnStatement()
1711
+ ),
1712
+ t.expressionStatement(
1713
+ t.assignmentExpression("=", t.identifier("_$delegated$"), t.booleanLiteral(true))
1714
+ ),
1715
+ t.expressionStatement(
1716
+ t.callExpression(t.identifier("_$delegateEvents"), [eventArray])
1717
+ )
1718
+ ])
1501
1719
  );
1720
+ path3.unshiftContainer("body", [
1721
+ t.variableDeclaration("let", [
1722
+ t.variableDeclarator(t.identifier("_$delegated$"), t.booleanLiteral(false))
1723
+ ]),
1724
+ helperFn
1725
+ ]);
1502
1726
  }
1503
1727
  }
1504
1728
  },
1505
1729
  JSXElement(path3, state) {
1506
- const scope = path3.scope;
1507
- let cache = state._signalNamesCache;
1508
- if (!cache) cache = state._signalNamesCache = /* @__PURE__ */ new WeakMap();
1509
- let names = cache.get(scope);
1510
- if (!names) {
1511
- names = collectSignalNamesFromScope(path3);
1512
- cache.set(scope, names);
1513
- }
1514
- state.signalNames = names;
1515
- state._pendingSetup = [];
1516
- const transformed = transformElementFineGrained(path3, state);
1517
- const pending = state._pendingSetup;
1518
- state._pendingSetup = [];
1519
- if (pending.length > 0) {
1520
- let stmtPath = path3;
1521
- let crossedFunctionBoundary = false;
1522
- while (stmtPath && !stmtPath.isStatement()) {
1523
- if (stmtPath.isArrowFunctionExpression() || stmtPath.isFunctionExpression()) {
1524
- crossedFunctionBoundary = true;
1525
- }
1526
- stmtPath = stmtPath.parentPath;
1527
- }
1528
- const inStatementList = stmtPath && stmtPath.isStatement() && (stmtPath.listKey === "body" || stmtPath.listKey === "consequent") && Array.isArray(stmtPath.container);
1529
- if (inStatementList && !crossedFunctionBoundary) {
1530
- stmtPath.insertBefore(pending);
1531
- path3.replaceWith(transformed);
1532
- } else {
1533
- pending.push(t.returnStatement(transformed));
1534
- path3.replaceWith(
1535
- t.callExpression(
1536
- t.arrowFunctionExpression([], t.blockStatement(pending)),
1537
- []
1538
- )
1539
- );
1540
- }
1541
- } else {
1542
- path3.replaceWith(transformed);
1543
- }
1730
+ transformJsxRoot(path3, state, transformElementFineGrained);
1544
1731
  },
1545
1732
  JSXFragment(path3, state) {
1546
- const transformed = transformFragmentFineGrained(path3, state);
1547
- path3.replaceWith(transformed);
1733
+ transformJsxRoot(path3, state, transformFragmentFineGrained);
1548
1734
  }
1549
1735
  }
1550
1736
  };
@@ -2189,7 +2375,12 @@ function whatVitePlugin(options = {}) {
2189
2375
  // Pages directory (relative to project root)
2190
2376
  pages = "src/pages",
2191
2377
  // HMR: enabled by default in dev, disabled in production
2192
- hot = !production
2378
+ hot = !production,
2379
+ // Resolve the `production` exports condition (dist/*.min.js — pre-minified,
2380
+ // dev warnings compiled out) during `vite build`. Set to false to build
2381
+ // against package sources instead — needed e.g. in a monorepo where
2382
+ // workspace-linked dist/ output may be stale or absent. See config() below.
2383
+ prodBundles = true
2193
2384
  } = options;
2194
2385
  let rootDir = "";
2195
2386
  let pagesDir = "";
@@ -2244,6 +2435,13 @@ function whatVitePlugin(options = {}) {
2244
2435
  const result = transformSync(code, {
2245
2436
  filename: id,
2246
2437
  sourceMaps,
2438
+ // Hermetic transform (SPRINT v0.11 C7): never load the project's
2439
+ // babel.config.js/.babelrc. A user's React preset or unrelated
2440
+ // plugins corrupting What's JSX output is a debugging nightmare —
2441
+ // and scanning the disk for config files on every transform is
2442
+ // wasted I/O in dev.
2443
+ configFile: false,
2444
+ babelrc: false,
2247
2445
  plugins: [
2248
2446
  [whatBabelPlugin, { production }]
2249
2447
  ],
@@ -2287,8 +2485,10 @@ function whatVitePlugin(options = {}) {
2287
2485
  return;
2288
2486
  },
2289
2487
  // Configure for development
2290
- config(config, { mode }) {
2488
+ config(config, { mode, command }) {
2489
+ const useProdCondition = command === "build" && mode === "production" && prodBundles;
2291
2490
  return {
2491
+ ...useProdCondition ? { resolve: { conditions: ["production"] } } : {},
2292
2492
  esbuild: {
2293
2493
  // Preserve JSX so our babel plugin handles it -- don't let esbuild transform it
2294
2494
  jsx: "preserve"