solid-optimizer 1.1.0 → 1.1.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.
- package/dist/{compile-D2f8eXFk.mjs → compile-DAmk1J8f.mjs} +20 -5
- package/dist/compile-DAmk1J8f.mjs.map +1 -0
- package/dist/index.mjs +1 -1
- package/dist/vite.d.mts.map +1 -1
- package/dist/vite.mjs +50 -6
- package/dist/vite.mjs.map +1 -1
- package/package.json +1 -1
- package/src/inline.ts +38 -4
- package/src/vite/index.ts +65 -5
- package/dist/compile-D2f8eXFk.mjs.map +0 -1
|
@@ -4094,11 +4094,23 @@ var Inliner = class {
|
|
|
4094
4094
|
const text = copy.slice(first.start, last.end);
|
|
4095
4095
|
statements.push(text.code.endsWith(";") ? text : joinText`${text};`);
|
|
4096
4096
|
}
|
|
4097
|
+
const { root } = component;
|
|
4098
|
+
const parent = this.context.parents.get(element);
|
|
4099
|
+
const spliceChildren = root.type === "JSXFragment" && (parent?.type === "JSXElement" || parent?.type === "JSXFragment");
|
|
4100
|
+
if (spliceChildren) {
|
|
4101
|
+
const edges = [root.children.at(0), root.children.at(-1)];
|
|
4102
|
+
const kept = (value) => /\S/.test(value) || value !== "" && !value.includes("\n");
|
|
4103
|
+
if (edges.some((child) => child?.type === "JSXText" && kept(child.value))) {
|
|
4104
|
+
this.reason = "fragment-text";
|
|
4105
|
+
return;
|
|
4106
|
+
}
|
|
4107
|
+
}
|
|
4097
4108
|
return {
|
|
4098
4109
|
element,
|
|
4099
4110
|
host,
|
|
4100
4111
|
statements,
|
|
4101
|
-
root: copy.slice(
|
|
4112
|
+
root: copy.slice(root.start, root.end),
|
|
4113
|
+
spliced: spliceChildren ? copy.slice(root.openingFragment.end, root.closingFragment.start) : void 0
|
|
4102
4114
|
};
|
|
4103
4115
|
}
|
|
4104
4116
|
/** Queues statements for a host. Each `return` gets its own, since their scopes can differ. */
|
|
@@ -4115,7 +4127,7 @@ var Inliner = class {
|
|
|
4115
4127
|
* Writes a prepared copy over its call site.
|
|
4116
4128
|
*/
|
|
4117
4129
|
commit(site) {
|
|
4118
|
-
this.context.s.overwrite(site.element.start, site.element.end, site.root);
|
|
4130
|
+
this.context.s.overwrite(site.element.start, site.element.end, site.spliced ?? site.root);
|
|
4119
4131
|
if (site.host) this.addToHost(site.host, site.statements);
|
|
4120
4132
|
}
|
|
4121
4133
|
/**
|
|
@@ -4698,13 +4710,16 @@ var Inliner = class {
|
|
|
4698
4710
|
const inlined = /* @__PURE__ */ new Map();
|
|
4699
4711
|
const changedBodies = new Set(this.findTransparentProviders(components, sites));
|
|
4700
4712
|
const worthwhile = this.worthwhileComponents(sites, changedBodies, otherUses);
|
|
4713
|
+
const pendingHosts = [];
|
|
4701
4714
|
for (const site of inBodyOrder(sites)) {
|
|
4702
|
-
const
|
|
4715
|
+
const holdsPendingHost = pendingHosts.some((host) => isWithin(host, site.element));
|
|
4716
|
+
const postponed = changedBodies.has(site.component) || holdsPendingHost;
|
|
4703
4717
|
const copy = postponed || !worthwhile.has(site.component) ? void 0 : this.prepare(site.component, site.element);
|
|
4704
4718
|
const done = copy !== void 0;
|
|
4705
4719
|
if (copy) {
|
|
4706
4720
|
this.commit(copy);
|
|
4707
4721
|
this.changed = true;
|
|
4722
|
+
if (copy.host) pendingHosts.push(copy.host.fn);
|
|
4708
4723
|
const elements = inlined.get(site.component) ?? [];
|
|
4709
4724
|
elements.push(site.element);
|
|
4710
4725
|
inlined.set(site.component, elements);
|
|
@@ -4761,7 +4776,7 @@ var Inliner = class {
|
|
|
4761
4776
|
const tag = element.openingElement.name;
|
|
4762
4777
|
if (tag.type === "JSXMemberExpression") return {
|
|
4763
4778
|
reason: "member-tag",
|
|
4764
|
-
name:
|
|
4779
|
+
name: this.context.code.slice(tag.start, tag.end)
|
|
4765
4780
|
};
|
|
4766
4781
|
if (tag.type !== "JSXIdentifier" || !isCapitalized(tag.name)) return;
|
|
4767
4782
|
const { name } = tag;
|
|
@@ -6289,4 +6304,4 @@ function readModuleConstants(code, options = {}) {
|
|
|
6289
6304
|
//#endregion
|
|
6290
6305
|
export { analyzeScopes as a, collectParents as c, parse$1 as d, unwrap as f, runtimeImportSources as i, forEachChild as l, readModuleConstants as n, lookup as o, CONTEXT_SAFE_PRIMITIVES as r, scopeAt as s, compile as t, isIntrinsicTag as u };
|
|
6291
6306
|
|
|
6292
|
-
//# sourceMappingURL=compile-
|
|
6307
|
+
//# sourceMappingURL=compile-DAmk1J8f.mjs.map
|