@primate/svelte 0.6.1 → 0.7.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/package.json +6 -5
- package/src/module.js +11 -15
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primate/svelte",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Primate Svelte module",
|
|
5
|
-
"
|
|
5
|
+
"homepage": "https://primatejs.com/modules/svelte",
|
|
6
|
+
"bugs": "https://github.com/primatejs/primate/issues",
|
|
6
7
|
"license": "MIT",
|
|
7
8
|
"files": [
|
|
8
9
|
"src/**",
|
|
@@ -10,15 +11,15 @@
|
|
|
10
11
|
],
|
|
11
12
|
"repository": {
|
|
12
13
|
"type": "git",
|
|
13
|
-
"url": "https://github.com/primatejs/
|
|
14
|
+
"url": "https://github.com/primatejs/primate",
|
|
14
15
|
"directory": "packages/svelte"
|
|
15
16
|
},
|
|
16
17
|
"dependencies": {
|
|
17
|
-
"runtime-compat": "^0.
|
|
18
|
+
"runtime-compat": "^0.16.3",
|
|
18
19
|
"svelte": "^3.58.0"
|
|
19
20
|
},
|
|
20
21
|
"peerDependencies": {
|
|
21
|
-
"primate": "0.
|
|
22
|
+
"primate": "0.16"
|
|
22
23
|
},
|
|
23
24
|
"type": "module",
|
|
24
25
|
"exports": "./src/exports.js"
|
package/src/module.js
CHANGED
|
@@ -14,8 +14,10 @@ const handler = path => (component, props = {}, {status = 200} = {}) =>
|
|
|
14
14
|
.default.render(props);
|
|
15
15
|
|
|
16
16
|
const name = component.slice(0, -endings.svelte.length);
|
|
17
|
+
|
|
18
|
+
const src = new Path(app.config.http.static.root, app.config.dist);
|
|
17
19
|
// create an entry point
|
|
18
|
-
const entry = `import {${name} as Component} from "
|
|
20
|
+
const entry = `import {${name} as Component} from "${src}.js";
|
|
19
21
|
const props = JSON.parse(${JSON.stringify(JSON.stringify(props))});
|
|
20
22
|
new Component({
|
|
21
23
|
target: document.body,
|
|
@@ -56,30 +58,23 @@ export default ({directory, entryPoints} = {}) => ({
|
|
|
56
58
|
return next(app);
|
|
57
59
|
},
|
|
58
60
|
async publish(app, next) {
|
|
61
|
+
const _path = ["node_modules", "svelte", "package.json"];
|
|
62
|
+
const j = await Path.resolve().join(..._path).json();
|
|
63
|
+
app.resolve(j, "svelte");
|
|
64
|
+
|
|
59
65
|
const path = directory ?? app.paths.components;
|
|
60
66
|
const options = {
|
|
61
67
|
generate: "dom",
|
|
62
68
|
hydratable: true,
|
|
63
|
-
sveltePath: "./svelte",
|
|
64
69
|
};
|
|
65
70
|
const components = await path.list(filename => filename.endsWith(svelte));
|
|
66
|
-
|
|
67
|
-
const scriptPath = ["node_modules", "svelte", "internal", "index.mjs"];
|
|
68
|
-
// import.meta.resolve is more reliable, use it if available
|
|
69
|
-
const _path = import.meta.resolve === undefined
|
|
70
|
-
? await Path.resolve().join(...scriptPath)
|
|
71
|
-
: new Path(await import.meta.resolve("svelte/internal"));
|
|
72
|
-
// publish svelte itself
|
|
73
|
-
const code = await _path.file.read();
|
|
74
|
-
await app.publish({src: "svelte/internal.js", code, type});
|
|
75
|
-
}
|
|
71
|
+
|
|
76
72
|
await Promise.all(components.map(async component => {
|
|
77
73
|
const file = await component.file.read();
|
|
78
74
|
const client = compiler.compile(file, options);
|
|
79
75
|
const css = client.css.code;
|
|
80
|
-
const compiled = client.js.code
|
|
81
|
-
|
|
82
|
-
.replace("./svelte/internal", "./svelte/internal.js");
|
|
76
|
+
const compiled = client.js.code.replaceAll(svelte, js);
|
|
77
|
+
|
|
83
78
|
await app.publish({src: `${component.name}.js`, code: compiled, type});
|
|
84
79
|
if (css !== null) {
|
|
85
80
|
const name = `${component.name}.css`;
|
|
@@ -87,6 +82,7 @@ export default ({directory, entryPoints} = {}) => ({
|
|
|
87
82
|
app.bootstrap({type: "style", code: `import "./${name}";`});
|
|
88
83
|
}
|
|
89
84
|
}));
|
|
85
|
+
|
|
90
86
|
if (entryPoints !== undefined) {
|
|
91
87
|
entryPoints.forEach(entry => {
|
|
92
88
|
const name = entry.slice(0, -endings.svelte.length);
|