evolit 0.4.3 → 0.4.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 +6 -0
- package/package.json +3 -2
- package/src/build.js +1 -1
- package/src/client-assets.js +28 -5
- package/src/deployment-runtime.js +1 -1
- package/src/urql-ssr.js +26 -8
package/README.md
CHANGED
|
@@ -444,6 +444,12 @@ configuration therefore stays isolated per render, extracted SSR data is read
|
|
|
444
444
|
before the scope closes, and integration response headers are included before
|
|
445
445
|
the response is cached.
|
|
446
446
|
|
|
447
|
+
The supported SSR combination is `evolit@0.4.4` or newer,
|
|
448
|
+
`@litsx/core@1.0.0-next.8` or newer, and `@litsx/urql@0.4.2` or newer. Evolit
|
|
449
|
+
resolves the server-conditioned URQL adapter from the application project and
|
|
450
|
+
uses that same module instance for setup, request resources, route rendering,
|
|
451
|
+
SSR extraction, and cleanup.
|
|
452
|
+
|
|
447
453
|
## Extensions
|
|
448
454
|
|
|
449
455
|
Optional integrations are configured explicitly in `evolit.config.js`. Core only coordinates their
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "evolit",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "A convention-driven application framework for LitSX and web components.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"packageManager": "yarn@4.10.3",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"ws": "^8.18.3"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
|
-
"@litsx/urql": "^0.4.
|
|
78
|
+
"@litsx/urql": "^0.4.2"
|
|
79
79
|
},
|
|
80
80
|
"peerDependenciesMeta": {
|
|
81
81
|
"@litsx/urql": {
|
|
@@ -85,6 +85,7 @@
|
|
|
85
85
|
"devDependencies": {
|
|
86
86
|
"@litsx/tailwind": "1.0.0-next.8",
|
|
87
87
|
"@litsx/unocss": "1.0.0-next.8",
|
|
88
|
+
"@litsx/urql": "^0.4.2",
|
|
88
89
|
"@playwright/test": "^1.62.0",
|
|
89
90
|
"@webcomponents/scoped-custom-element-registry": "^0.0.10",
|
|
90
91
|
"unocss": "66.8.1",
|
package/src/build.js
CHANGED
package/src/client-assets.js
CHANGED
|
@@ -581,7 +581,22 @@ function createSharedChunkGroup(id) {
|
|
|
581
581
|
return "vendor-litsx";
|
|
582
582
|
}
|
|
583
583
|
|
|
584
|
-
return
|
|
584
|
+
return undefined;
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
function createBrowserEnvironmentPlugin(mode) {
|
|
588
|
+
const nodeEnvironment = mode === "production" ? "production" : "development";
|
|
589
|
+
const replacement = JSON.stringify(nodeEnvironment);
|
|
590
|
+
return {
|
|
591
|
+
name: "evolit-browser-environment",
|
|
592
|
+
transform(code) {
|
|
593
|
+
if (!code.includes("process.env.NODE_ENV")) return null;
|
|
594
|
+
return {
|
|
595
|
+
code: code.replaceAll("process.env.NODE_ENV", replacement),
|
|
596
|
+
map: null,
|
|
597
|
+
};
|
|
598
|
+
},
|
|
599
|
+
};
|
|
585
600
|
}
|
|
586
601
|
|
|
587
602
|
function isClientAssetStubModule(relativePath) {
|
|
@@ -746,6 +761,7 @@ export async function buildSharedVendorRuntime(
|
|
|
746
761
|
.map((group) => buildSharedVendorRuntime(projectRoot, mode, {
|
|
747
762
|
...options,
|
|
748
763
|
additionalEntrySpecifiers: group.specifiers,
|
|
764
|
+
externalSpecifiers: developmentGroups.baseSpecifiers,
|
|
749
765
|
vendorGroup: group.vendorGroup,
|
|
750
766
|
includeBase: false,
|
|
751
767
|
})),
|
|
@@ -790,9 +806,16 @@ export async function buildSharedVendorRuntime(
|
|
|
790
806
|
const specifierByEntryName = new Map(
|
|
791
807
|
specifiers.map((specifier) => [createSharedEntryName(specifier), specifier]),
|
|
792
808
|
);
|
|
809
|
+
const externalSpecifiers = new Set(
|
|
810
|
+
Array.isArray(options.externalSpecifiers) ? options.externalSpecifiers : [],
|
|
811
|
+
);
|
|
793
812
|
const bundle = await rollup({
|
|
794
813
|
input: inputEntries,
|
|
814
|
+
external(source) {
|
|
815
|
+
return externalSpecifiers.has(source);
|
|
816
|
+
},
|
|
795
817
|
plugins: [
|
|
818
|
+
createBrowserEnvironmentPlugin(mode),
|
|
796
819
|
{
|
|
797
820
|
name: "evolit-browser-exports",
|
|
798
821
|
resolveId(source) {
|
|
@@ -814,10 +837,6 @@ export async function buildSharedVendorRuntime(
|
|
|
814
837
|
],
|
|
815
838
|
preserveEntrySignatures: "strict",
|
|
816
839
|
onwarn(warning, warn) {
|
|
817
|
-
if (warning.code === "CIRCULAR_DEPENDENCY") {
|
|
818
|
-
return;
|
|
819
|
-
}
|
|
820
|
-
|
|
821
840
|
warn(warning);
|
|
822
841
|
},
|
|
823
842
|
});
|
|
@@ -836,6 +855,10 @@ export async function buildSharedVendorRuntime(
|
|
|
836
855
|
manualChunks(id) {
|
|
837
856
|
return createSharedChunkGroup(id);
|
|
838
857
|
},
|
|
858
|
+
paths(id) {
|
|
859
|
+
if (!externalSpecifiers.has(id)) return id;
|
|
860
|
+
return `/_evolit/shared/base/${createSharedEntryName(id)}.mjs`;
|
|
861
|
+
},
|
|
839
862
|
});
|
|
840
863
|
|
|
841
864
|
const imports = {};
|
package/src/urql-ssr.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
|
|
5
|
+
const adapterPromisesByModuleUrl = new Map();
|
|
2
6
|
|
|
3
7
|
function isMissingUrqlAdapter(error) {
|
|
4
|
-
return error?.code === "ERR_MODULE_NOT_FOUND"
|
|
8
|
+
return (error?.code === "ERR_MODULE_NOT_FOUND" || error?.code === "MODULE_NOT_FOUND")
|
|
5
9
|
&& String(error.message).includes("@litsx/urql");
|
|
6
10
|
}
|
|
7
11
|
|
|
8
|
-
|
|
12
|
+
function resolveSsrUrqlAdapterUrl(projectRoot) {
|
|
9
13
|
try {
|
|
10
|
-
|
|
14
|
+
const requireFromProject = createRequire(path.join(path.resolve(projectRoot), "package.json"));
|
|
15
|
+
return pathToFileURL(requireFromProject.resolve("@litsx/urql")).href;
|
|
11
16
|
} catch (error) {
|
|
12
17
|
if (isMissingUrqlAdapter(error)) {
|
|
13
18
|
return null;
|
|
@@ -16,9 +21,22 @@ async function loadSsrUrqlAdapter() {
|
|
|
16
21
|
}
|
|
17
22
|
}
|
|
18
23
|
|
|
19
|
-
export async function getSsrUrqlAdapter() {
|
|
20
|
-
|
|
21
|
-
return
|
|
24
|
+
export async function getSsrUrqlAdapter(projectRoot = process.cwd()) {
|
|
25
|
+
const moduleUrl = resolveSsrUrqlAdapterUrl(projectRoot);
|
|
26
|
+
if (!moduleUrl) return null;
|
|
27
|
+
let adapterPromise = adapterPromisesByModuleUrl.get(moduleUrl);
|
|
28
|
+
if (!adapterPromise) {
|
|
29
|
+
adapterPromise = import(moduleUrl);
|
|
30
|
+
adapterPromisesByModuleUrl.set(moduleUrl, adapterPromise);
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
return await adapterPromise;
|
|
34
|
+
} catch (error) {
|
|
35
|
+
if (adapterPromisesByModuleUrl.get(moduleUrl) === adapterPromise) {
|
|
36
|
+
adapterPromisesByModuleUrl.delete(moduleUrl);
|
|
37
|
+
}
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
22
40
|
}
|
|
23
41
|
|
|
24
42
|
/**
|
|
@@ -40,7 +58,7 @@ export async function runWithOptionalSsrUrqlScope(
|
|
|
40
58
|
}
|
|
41
59
|
const adapter = Object.hasOwn(options, "adapter")
|
|
42
60
|
? options.adapter
|
|
43
|
-
: await getSsrUrqlAdapter();
|
|
61
|
+
: await getSsrUrqlAdapter(options.projectRoot);
|
|
44
62
|
if (!adapter) {
|
|
45
63
|
return callback(null);
|
|
46
64
|
}
|