@happyvertical/smrt-core 0.57.41 → 0.57.42
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/agents/build-knowledge.md +27 -0
- package/dist/consumer-plugin/index.d.ts.map +1 -1
- package/dist/consumer-plugin/index.js +30 -5
- package/dist/consumer-plugin/index.js.map +1 -1
- package/dist/manifest/static-manifest.js +1 -1
- package/dist/manifest/static-manifest.js.map +1 -1
- package/dist/manifest/store.js +1 -1
- package/dist/manifest.json +1 -1
- package/dist/smrt-knowledge.json +5 -5
- package/dist/vite-plugin/plugin-contract.d.ts +8 -0
- package/dist/vite-plugin/plugin-contract.d.ts.map +1 -1
- package/dist/vite-plugin/resources-route.d.ts +7 -3
- package/dist/vite-plugin/resources-route.d.ts.map +1 -1
- package/dist/vite-plugin/resources-route.js +11 -8
- package/dist/vite-plugin/resources-route.js.map +1 -1
- package/dist/vite-plugin/sveltekit-generator.d.ts.map +1 -1
- package/dist/vite-plugin/sveltekit-generator.js +5 -5
- package/dist/vite-plugin/sveltekit-generator.js.map +1 -1
- package/package.json +4 -4
|
@@ -129,6 +129,21 @@ map and root together, preserving exact target matching. Plain server entries
|
|
|
129
129
|
remain external; do not fix peer-context resolution by deduplicating app
|
|
130
130
|
packages or bundling every server export (#4318).
|
|
131
131
|
|
|
132
|
+
The same server/component split applies to consumer development SSR (#4475).
|
|
133
|
+
Vite's dev import analysis ignores a resolver's `external` flag, so broad
|
|
134
|
+
`noExternal` alone creates another module instance even when native Node and
|
|
135
|
+
Vite resolve the identical file. That duplicates module-local enablement and
|
|
136
|
+
interceptors while an AsyncLocalStorage singleton can still appear shared.
|
|
137
|
+
The consumer resolver records only exact server entry files selected through
|
|
138
|
+
the importer's installed export map. Its dev SSR environment `fetchModule`
|
|
139
|
+
transport returns those files as native external modules; component barrels,
|
|
140
|
+
Svelte and CSS continue through Vite. Production keeps bare external imports.
|
|
141
|
+
Never externalize the complete component-bearing package or switch its mutable
|
|
142
|
+
runtime flags to globals to mask duplicate execution. The real `createServer` /
|
|
143
|
+
`ssrLoadModule` regression in `selective-ssr-dev.test.ts` initializes native
|
|
144
|
+
server state and verifies root/subpath reads plus direct and transitive peer
|
|
145
|
+
Svelte/CSS compilation in one dev request.
|
|
146
|
+
|
|
132
147
|
Not covered by contract: a package whose root is a Svelte entry AND whose
|
|
133
148
|
`@smrt()` objects are exported only from that root. The object loop must then
|
|
134
149
|
import the root (it is the only module exporting the constructors) — statically
|
|
@@ -266,6 +281,18 @@ admin auth.
|
|
|
266
281
|
|
|
267
282
|
## Vite Plugin
|
|
268
283
|
|
|
284
|
+
`_resources` and application-runtime config detection resolve their exact
|
|
285
|
+
`@happyvertical/smrt-users/sveltekit` and `@happyvertical/smrt-app-runtime/sveltekit`
|
|
286
|
+
imports with ESM import conditions anchored
|
|
287
|
+
to the consumer package URL, using `import-meta-resolve`. A `types`/`import`-only
|
|
288
|
+
export is valid; a CommonJS `createRequire.resolve` probe would falsely skip it.
|
|
289
|
+
Verify the selected target is an existing file because import-meta resolution
|
|
290
|
+
can return URLs for missing files/directories. Missing/unexported dependencies
|
|
291
|
+
remain skipped, ancestor-hoisted installs resolve normally, and handwritten
|
|
292
|
+
`+server.ts`/`+server.js` ownership and explicit disablement remain unchanged.
|
|
293
|
+
Do not change a package's export map to accommodate a mismatched detector.
|
|
294
|
+
|
|
295
|
+
|
|
269
296
|
`src/vite-preset/` (`@happyvertical/smrt-core/vite`, `smrt()`) composes the Oxc
|
|
270
297
|
decorator block, `smrtConsumer`, then `smrtPlugin` with the template path
|
|
271
298
|
conventions. Its package list comes only from the `smrt({ packages })` option, or
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/consumer-plugin/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/consumer-plugin/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;A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ACrB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,6BAA6B,CAAC;IACnD;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,GAAG,4BAA4B,CAAC;IACnD;;;;;OAKG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,oDAAoD;IACpD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,4BAA4B;IAC5B,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAmXD;;GAEG;AACH,wBAAgB,YAAY,CAC1B,OAAO,GAAE,mBAAwB,GAChC,cAAc,CAioBhB"}
|
|
@@ -12,6 +12,7 @@ import { activeProducerKnowledgeRoutePaths, activeSvelteKitRouteParticipants, as
|
|
|
12
12
|
import { generateDeclarations } from "../prebuild/index.js";
|
|
13
13
|
import { separateHostedStiCollections } from "./hosted-sti-collections.js";
|
|
14
14
|
import * as path$1 from "node:path";
|
|
15
|
+
import { pathToFileURL } from "node:url";
|
|
15
16
|
import * as fs$1 from "node:fs";
|
|
16
17
|
//#region src/consumer-plugin/index.ts
|
|
17
18
|
/**
|
|
@@ -282,6 +283,8 @@ function smrtConsumer(options = {}) {
|
|
|
282
283
|
let producerApi;
|
|
283
284
|
let routeLifecycleConfig;
|
|
284
285
|
let isBuild = false;
|
|
286
|
+
let devServerRoot = projectRoot;
|
|
287
|
+
const devNativeSsrModules = /* @__PURE__ */ new Map();
|
|
285
288
|
let selectiveSsrPackages = /* @__PURE__ */ new Map();
|
|
286
289
|
function loadGenerationSnapshot() {
|
|
287
290
|
if (!generationSnapshot) throw new Error("[smrt:consumer] Generation snapshot is not configured");
|
|
@@ -482,6 +485,15 @@ function smrtConsumer(options = {}) {
|
|
|
482
485
|
if (consumerSvelteKit && routeLifecycleConfig) assertSvelteKitRouteCoordinationComplete(routeLifecycleConfig);
|
|
483
486
|
producerApi = (resolvedConfig.plugins ?? []).find((plugin) => plugin?.name === "smrt-auto-service")?.api;
|
|
484
487
|
},
|
|
488
|
+
configureServer(server) {
|
|
489
|
+
devServerRoot = server.config.root;
|
|
490
|
+
const ssr = server.environments?.ssr;
|
|
491
|
+
if (!ssr?.fetchModule) return;
|
|
492
|
+
const fetchModule = ssr.fetchModule.bind(ssr);
|
|
493
|
+
ssr.fetchModule = async (id, importer, options) => {
|
|
494
|
+
return devNativeSsrModules.get(id.split("?")[0]) ?? fetchModule(id, importer, options);
|
|
495
|
+
};
|
|
496
|
+
},
|
|
485
497
|
async buildStart() {
|
|
486
498
|
console.log("[smrt:consumer] Initializing SMRT consumer plugin");
|
|
487
499
|
if (generationSnapshot) {
|
|
@@ -516,7 +528,7 @@ function smrtConsumer(options = {}) {
|
|
|
516
528
|
}
|
|
517
529
|
},
|
|
518
530
|
async resolveId(id, importer, resolveOptions) {
|
|
519
|
-
if (
|
|
531
|
+
if (resolveOptions?.ssr) for (const [packageName, selectivePackage] of selectiveSsrPackages) {
|
|
520
532
|
if (id !== packageName && !id.startsWith(`${packageName}/`)) continue;
|
|
521
533
|
const resolved = await this.resolve(id, importer, {
|
|
522
534
|
...resolveOptions,
|
|
@@ -527,10 +539,23 @@ function smrtConsumer(options = {}) {
|
|
|
527
539
|
const packageJsonPath = importerPath && path$1.isAbsolute(importerPath) ? findInstalledPackageJson(packageName, path$1.dirname(importerPath)) : void 0;
|
|
528
540
|
const packageJson = packageJsonPath ? readInstalledPackageJson(packageJsonPath) : selectivePackage.packageJson;
|
|
529
541
|
const compileSvelteBarrel = packageJson && resolvesToSvelteCondition(packageName, packageJson, packageJsonPath ? path$1.dirname(packageJsonPath) : selectivePackage.packageRoot, id, resolved?.id);
|
|
530
|
-
if (!compile && !compileSvelteBarrel)
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
542
|
+
if (!compile && !compileSvelteBarrel) {
|
|
543
|
+
if (isBuild) return {
|
|
544
|
+
id,
|
|
545
|
+
external: true
|
|
546
|
+
};
|
|
547
|
+
if (!resolved) return;
|
|
548
|
+
const filename = resolved.id.split("?")[0];
|
|
549
|
+
if (!path$1.isAbsolute(filename)) return resolved;
|
|
550
|
+
const native = {
|
|
551
|
+
externalize: pathToFileURL(filename).href,
|
|
552
|
+
type: filename.endsWith(".mjs") || !filename.endsWith(".cjs") && packageJson?.type === "module" ? "module" : "commonjs"
|
|
553
|
+
};
|
|
554
|
+
devNativeSsrModules.set(filename, native);
|
|
555
|
+
devNativeSsrModules.set(path$1.posix.join("/@fs/", filename), native);
|
|
556
|
+
if (filename.startsWith(`${devServerRoot}/`)) devNativeSsrModules.set(filename.slice(devServerRoot.length), native);
|
|
557
|
+
return resolved;
|
|
558
|
+
}
|
|
534
559
|
break;
|
|
535
560
|
}
|
|
536
561
|
if (id in VIRTUAL_MODULES) {
|