@samva/vite 0.2.0 → 0.3.0
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/email.d.ts +5 -3
- package/dist/email.js +11 -1
- package/package.json +2 -2
package/dist/email.d.ts
CHANGED
|
@@ -28,9 +28,11 @@ interface EmailRenderer {
|
|
|
28
28
|
* times; nothing here renders on its own.
|
|
29
29
|
*
|
|
30
30
|
* `namespace` names the id space the entry's modules occupy. Reusing one
|
|
31
|
-
* keeps a watch session's ids stable across reloads
|
|
32
|
-
*
|
|
33
|
-
*
|
|
31
|
+
* keeps a watch session's ids stable across reloads, while a fresh one
|
|
32
|
+
* isolates an unrelated project. Omitting it takes a new namespace each time.
|
|
33
|
+
* Every load re-evaluates the namespace's own modules, so the wrapper binds
|
|
34
|
+
* the sheets its imports registered; `invalidate` reaches the modules shared
|
|
35
|
+
* between namespaces.
|
|
34
36
|
*/
|
|
35
37
|
readonly load: (source: EmailProjectSource, entryPoint: string, namespace?: string) => Promise<LoadedEmailEntry>;
|
|
36
38
|
/**
|
package/dist/email.js
CHANGED
|
@@ -40,6 +40,12 @@ const createEmailRenderer = async (options, ssrExternal = []) => {
|
|
|
40
40
|
if (vite === void 0) throw new Error("`vite` is required to render an email project locally.");
|
|
41
41
|
const graphs = /* @__PURE__ */ new Map();
|
|
42
42
|
let anonymous = 0;
|
|
43
|
+
let evaluating = Promise.resolve();
|
|
44
|
+
const evaluate = (operation) => {
|
|
45
|
+
const running = evaluating.then(operation, operation);
|
|
46
|
+
evaluating = running.catch(() => void 0);
|
|
47
|
+
return running;
|
|
48
|
+
};
|
|
43
49
|
const graphFor = (id) => id === void 0 ? void 0 : [...graphs.values()].find((graph) => id.startsWith(graph.prefix));
|
|
44
50
|
const server = await vite.createServer({
|
|
45
51
|
root: RESOLUTION_ROOT,
|
|
@@ -80,7 +86,11 @@ const createEmailRenderer = async (options, ssrExternal = []) => {
|
|
|
80
86
|
graphs.set(key, graph);
|
|
81
87
|
const compiled = await compileEmailProject(source, entryPoint, options);
|
|
82
88
|
graph.files = compiled.files;
|
|
83
|
-
const module = await
|
|
89
|
+
const module = await evaluate(async () => {
|
|
90
|
+
const ssr = server.environments.ssr;
|
|
91
|
+
for (const node of ssr.moduleGraph.idToModuleMap.values()) if (node.id?.startsWith(graph.prefix) === true) ssr.moduleGraph.invalidateModule(node);
|
|
92
|
+
return await server.ssrLoadModule(`${graph.prefix}${qualify(compiled.entryPoint)}`);
|
|
93
|
+
});
|
|
84
94
|
return {
|
|
85
95
|
template: module.template,
|
|
86
96
|
renderEmail: module.renderEmail,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@samva/vite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Unified Vite editor for Samva email, SMS, and WhatsApp templates",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"email",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"@babel/parser": "^8.0.4",
|
|
73
|
-
"@samva/markup": "^0.
|
|
73
|
+
"@samva/markup": "^0.3.0",
|
|
74
74
|
"caniemail": "2.0.2",
|
|
75
75
|
"css-tree": "3.2.1",
|
|
76
76
|
"effect": "4.0.0-rc.112",
|