solid-optimizer 1.0.0-next.2 → 1.0.0-next.4
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 +1 -1
- package/dist/{compile-sCZdwEKG.mjs → compile-Dx577-sp.mjs} +2 -2
- package/dist/{compile-sCZdwEKG.mjs.map → compile-Dx577-sp.mjs.map} +1 -1
- package/dist/index.mjs +1 -1
- package/dist/vite.mjs +15 -2
- package/dist/vite.mjs.map +1 -1
- package/package.json +1 -1
- package/src/inline.ts +2 -1
- package/src/vite/index.ts +22 -1
package/package.json
CHANGED
package/src/inline.ts
CHANGED
|
@@ -1900,7 +1900,8 @@ class Inliner {
|
|
|
1900
1900
|
}
|
|
1901
1901
|
if (children !== undefined) {
|
|
1902
1902
|
const opening = spread.element.openingElement;
|
|
1903
|
-
|
|
1903
|
+
// Read the tag from the copy, which holds the renamed locals.
|
|
1904
|
+
const tag = copy.slice(opening.name.start, opening.name.end);
|
|
1904
1905
|
const close = this.context.code.lastIndexOf('/>', opening.end);
|
|
1905
1906
|
copy.overwrite(close, opening.end, `>${children}</${tag}>`);
|
|
1906
1907
|
}
|
package/src/vite/index.ts
CHANGED
|
@@ -744,6 +744,27 @@ export default function solidOptimizer(options: Options = {}): Plugin[] {
|
|
|
744
744
|
return stripped.code;
|
|
745
745
|
}
|
|
746
746
|
|
|
747
|
+
/**
|
|
748
|
+
* The scripts a virtual entry runs, like the server entry `start` mode
|
|
749
|
+
* generates: the app's modules it imports. It has no file to read, and
|
|
750
|
+
* the server and client builds have to see the same uses of each export.
|
|
751
|
+
* `undefined` when the entry has not been loaded or imports none.
|
|
752
|
+
*/
|
|
753
|
+
function virtualEntryScripts(context: Rollup.PluginContext, id: string): string[] | undefined {
|
|
754
|
+
const info = context.getModuleInfo(id);
|
|
755
|
+
if (!info || info.code === null) {
|
|
756
|
+
return undefined;
|
|
757
|
+
}
|
|
758
|
+
const scripts: string[] = [];
|
|
759
|
+
for (const imported of [...info.importedIds, ...info.dynamicallyImportedIds]) {
|
|
760
|
+
// Packages and other virtual modules hold none of the app's components.
|
|
761
|
+
if (!imported.startsWith('\0') && !imported.includes('/node_modules/')) {
|
|
762
|
+
scripts.push(imported);
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
return scripts.length > 0 ? scripts : undefined;
|
|
766
|
+
}
|
|
767
|
+
|
|
747
768
|
/**
|
|
748
769
|
* The scripts an entry runs: the entry itself, or the module scripts of an
|
|
749
770
|
* HTML entry. `undefined` when an HTML entry has an inline module script,
|
|
@@ -760,7 +781,7 @@ export default function solidOptimizer(options: Options = {}): Plugin[] {
|
|
|
760
781
|
try {
|
|
761
782
|
html = await readFile(stripQuery(id), 'utf8');
|
|
762
783
|
} catch {
|
|
763
|
-
return
|
|
784
|
+
return virtualEntryScripts(context, id);
|
|
764
785
|
}
|
|
765
786
|
const scripts: string[] = [];
|
|
766
787
|
for (const [tag] of html.matchAll(/<script\b[^>]*>/gi)) {
|