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