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/dist/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { n as readModuleConstants, t as compile } from "./compile-sCZdwEKG.mjs";
1
+ import { n as readModuleConstants, t as compile } from "./compile-Dx577-sp.mjs";
2
2
  export { compile, readModuleConstants };
package/dist/vite.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { a as lookup, c as forEachChild, d as unwrap, i as analyzeScopes, l as isIntrinsicTag, n as readModuleConstants, o as scopeAt, r as CONTEXT_SAFE_PRIMITIVES, s as collectParents, t as compile, u as parse } from "./compile-sCZdwEKG.mjs";
1
+ import { a as lookup, c as forEachChild, d as unwrap, i as analyzeScopes, l as isIntrinsicTag, n as readModuleConstants, o as scopeAt, r as CONTEXT_SAFE_PRIMITIVES, s as collectParents, t as compile, u as parse } from "./compile-Dx577-sp.mjs";
2
2
  import { createRequire } from "node:module";
3
3
  import remapping from "@jridgewell/remapping";
4
4
  import MagicString from "magic-string";
@@ -1393,6 +1393,19 @@ function solidOptimizer(options = {}) {
1393
1393
  })).code;
1394
1394
  }
1395
1395
  /**
1396
+ * The scripts a virtual entry runs, like the server entry `start` mode
1397
+ * generates: the app's modules it imports. It has no file to read, and
1398
+ * the server and client builds have to see the same uses of each export.
1399
+ * `undefined` when the entry has not been loaded or imports none.
1400
+ */
1401
+ function virtualEntryScripts(context, id) {
1402
+ const info = context.getModuleInfo(id);
1403
+ if (!info || info.code === null) return;
1404
+ const scripts = [];
1405
+ for (const imported of [...info.importedIds, ...info.dynamicallyImportedIds]) if (!imported.startsWith("\0") && !imported.includes("/node_modules/")) scripts.push(imported);
1406
+ return scripts.length > 0 ? scripts : void 0;
1407
+ }
1408
+ /**
1396
1409
  * The scripts an entry runs: the entry itself, or the module scripts of an
1397
1410
  * HTML entry. `undefined` when an HTML entry has an inline module script,
1398
1411
  * whose imports the usage index cannot read.
@@ -1403,7 +1416,7 @@ function solidOptimizer(options = {}) {
1403
1416
  try {
1404
1417
  html = await readFile(stripQuery(id), "utf8");
1405
1418
  } catch {
1406
- return;
1419
+ return virtualEntryScripts(context, id);
1407
1420
  }
1408
1421
  const scripts = [];
1409
1422
  for (const [tag] of html.matchAll(/<script\b[^>]*>/gi)) {