@farm.js/react 0.1.0-beta.35 → 0.1.0-beta.36
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.
- package/README.md +16 -0
- package/dist/compiler-runtime.cjs +28 -17
- package/dist/compiler-runtime.cjs.map +1 -1
- package/dist/compiler-runtime.d.mts +8 -1
- package/dist/compiler-runtime.d.ts +8 -1
- package/dist/compiler-runtime.mjs +28 -18
- package/dist/compiler-runtime.mjs.map +1 -1
- package/dist/vite.cjs +37 -11
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +37 -11
- package/dist/vite.mjs.map +1 -1
- package/package.json +2 -2
package/dist/vite.mjs
CHANGED
|
@@ -3286,7 +3286,6 @@ function stabilizeDeferredEventCurrentTargets(root, compilerSetters) {
|
|
|
3286
3286
|
const expression = file.program.body[0].expression;
|
|
3287
3287
|
return types.isJSXElement(expression) ? expression : types.cloneNode(root, true);
|
|
3288
3288
|
}
|
|
3289
|
-
var foreignContentElements = /* @__PURE__ */ new WeakSet();
|
|
3290
3289
|
var FOREIGN_ELEMENT_NAMES = new Set(
|
|
3291
3290
|
[
|
|
3292
3291
|
"animate animateMotion animateTransform circle clipPath defs desc ellipse",
|
|
@@ -3303,21 +3302,24 @@ var FOREIGN_ELEMENT_NAMES = new Set(
|
|
|
3303
3302
|
].join(" ").split(" ")
|
|
3304
3303
|
);
|
|
3305
3304
|
function markForeignContent(programPath) {
|
|
3305
|
+
let depth = 0;
|
|
3306
3306
|
programPath.traverse({
|
|
3307
|
-
JSXElement
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3307
|
+
JSXElement: {
|
|
3308
|
+
enter(path) {
|
|
3309
|
+
if (depth > 0) path.node.extra = { ...path.node.extra, farmForeignContent: true };
|
|
3310
|
+
const name = path.node.openingElement.name;
|
|
3311
|
+
if (types.isJSXIdentifier(name) && (name.name === "svg" || name.name === "math")) depth++;
|
|
3312
|
+
},
|
|
3313
|
+
exit(path) {
|
|
3314
|
+
const name = path.node.openingElement.name;
|
|
3315
|
+
if (types.isJSXIdentifier(name) && (name.name === "svg" || name.name === "math")) depth--;
|
|
3316
|
+
}
|
|
3315
3317
|
}
|
|
3316
3318
|
});
|
|
3317
3319
|
}
|
|
3318
3320
|
function isForeignContent(element) {
|
|
3319
3321
|
const name = element.openingElement.name;
|
|
3320
|
-
return
|
|
3322
|
+
return element.extra?.farmForeignContent === true || types.isJSXIdentifier(name) && FOREIGN_ELEMENT_NAMES.has(name.name);
|
|
3321
3323
|
}
|
|
3322
3324
|
function reactOwnedAttribute(name, attribute) {
|
|
3323
3325
|
if (name === "defaultValue" || name === "defaultChecked") return true;
|
|
@@ -7606,6 +7608,10 @@ async function compileReactModule(code, id, options) {
|
|
|
7606
7608
|
}
|
|
7607
7609
|
const candidates = collectCandidates(programPath);
|
|
7608
7610
|
const createComponentIdentifier = programPath.scope.generateUidIdentifier("createCompiledComponent");
|
|
7611
|
+
const createRefreshComponentIdentifier = programPath.scope.generateUidIdentifier("createRefreshComponent");
|
|
7612
|
+
const createProductionComponentIdentifier = programPath.scope.generateUidIdentifier(
|
|
7613
|
+
"createProductionComponent"
|
|
7614
|
+
);
|
|
7609
7615
|
const keyedMapUpdateIdentifier = programPath.scope.generateUidIdentifier(
|
|
7610
7616
|
"createCompilerKeyedMapUpdate"
|
|
7611
7617
|
);
|
|
@@ -7750,14 +7756,34 @@ async function compileReactModule(code, id, options) {
|
|
|
7750
7756
|
const hasKeyedArrayStructuralPrependHints = optimizationCounts.keyedArrayPrependHints > 0 && (optimizationCounts.keyedArrayFilterHints > 0 || optimizationCounts.keyedArraySliceHints > 0);
|
|
7751
7757
|
const hasUnmappedKeyedArrayPrependHints = optimizationCounts.keyedArrayPrependHints > compilerUsage.keyedArrayMappedStructuralPrependHints;
|
|
7752
7758
|
if (compiled.length > 0) {
|
|
7759
|
+
programPath.unshiftContainer(
|
|
7760
|
+
"body",
|
|
7761
|
+
types.variableDeclaration("const", [
|
|
7762
|
+
types.variableDeclarator(
|
|
7763
|
+
types.cloneNode(createComponentIdentifier),
|
|
7764
|
+
types.conditionalExpression(
|
|
7765
|
+
types.memberExpression(
|
|
7766
|
+
types.metaProperty(types.identifier("import"), types.identifier("meta")),
|
|
7767
|
+
types.identifier("hot")
|
|
7768
|
+
),
|
|
7769
|
+
types.cloneNode(createRefreshComponentIdentifier),
|
|
7770
|
+
types.cloneNode(createProductionComponentIdentifier)
|
|
7771
|
+
)
|
|
7772
|
+
)
|
|
7773
|
+
])
|
|
7774
|
+
);
|
|
7753
7775
|
programPath.unshiftContainer(
|
|
7754
7776
|
"body",
|
|
7755
7777
|
types.importDeclaration(
|
|
7756
7778
|
[
|
|
7757
7779
|
types.importSpecifier(
|
|
7758
|
-
|
|
7780
|
+
createRefreshComponentIdentifier,
|
|
7759
7781
|
types.identifier("createCompiledComponentWithFeatures")
|
|
7760
7782
|
),
|
|
7783
|
+
types.importSpecifier(
|
|
7784
|
+
createProductionComponentIdentifier,
|
|
7785
|
+
types.identifier("createCompiledComponentWithoutRefresh")
|
|
7786
|
+
),
|
|
7761
7787
|
...optimizationCounts.keyedMapUpdateHints > compilerUsage.keyedArrayMapUpdateHints ? [
|
|
7762
7788
|
types.importSpecifier(
|
|
7763
7789
|
keyedMapUpdateIdentifier,
|