@primate/svelte 0.4.2 → 0.5.1
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 +3 -3
- package/src/module.js +14 -5
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primate/svelte",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"bugs": "https://github.com/primatejs/svelte/issues",
|
|
5
5
|
"repository": "https://github.com/primatejs/svelte",
|
|
6
6
|
"description": "Primate Svelte module",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"runtime-compat": "^0.
|
|
9
|
+
"runtime-compat": "^0.15.0",
|
|
10
10
|
"svelte": "^3.58.0"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
13
|
"maximin": "^0.1.2"
|
|
14
14
|
},
|
|
15
15
|
"peerDependencies": {
|
|
16
|
-
"primate": "0.
|
|
16
|
+
"primate": "0.15"
|
|
17
17
|
},
|
|
18
18
|
"type": "module",
|
|
19
19
|
"exports": "./exports.js"
|
package/src/module.js
CHANGED
|
@@ -10,14 +10,14 @@ const type = "module";
|
|
|
10
10
|
|
|
11
11
|
const handler = path => (component, props = {}, {status = 200} = {}) =>
|
|
12
12
|
async (env, headers) => {
|
|
13
|
-
const {
|
|
14
|
-
const {html: body} = (await import(`${path.join(`${component}${js}`)}`))
|
|
13
|
+
const {html: body} = (await import(`${path.join(`${component}.js`)}`))
|
|
15
14
|
.default.render(props);
|
|
16
15
|
|
|
16
|
+
const name = component.slice(0, -endings.svelte.length);
|
|
17
17
|
// create an entry point
|
|
18
|
-
const entry = `import ${
|
|
18
|
+
const entry = `import {${name} as Component} from "./dist.js";
|
|
19
19
|
const props = JSON.parse(${JSON.stringify(JSON.stringify(props))});
|
|
20
|
-
new
|
|
20
|
+
new Component({
|
|
21
21
|
target: document.body,
|
|
22
22
|
hydrate: true,
|
|
23
23
|
props,
|
|
@@ -37,7 +37,7 @@ const handler = path => (component, props = {}, {status = 200} = {}) =>
|
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
const {svelte, js} = endings;
|
|
40
|
-
export default directory => ({
|
|
40
|
+
export default ({directory, entryPoints}) => ({
|
|
41
41
|
register(env, next) {
|
|
42
42
|
env.register("svelte", handler(directory ?? env.paths.components));
|
|
43
43
|
return next(env);
|
|
@@ -76,6 +76,15 @@ export default directory => ({
|
|
|
76
76
|
.replace("./svelte/internal", "./svelte/internal.js");
|
|
77
77
|
await env.publish({src: `${component.name}.js`, code: compiled, type});
|
|
78
78
|
}));
|
|
79
|
+
// create a pseudo entry to allow bundlers to bundle relevant code until
|
|
80
|
+
// proper path-splitting has been implemented
|
|
81
|
+
if (entryPoints !== undefined) {
|
|
82
|
+
const code = entryPoints.map(entry => {
|
|
83
|
+
const name = entry.slice(0, -endings.svelte.length);
|
|
84
|
+
return `export {default as ${name}} from "./${entry}.js";`
|
|
85
|
+
}).join("");
|
|
86
|
+
await env.publish({src: "dist.js", code, type, main: true});
|
|
87
|
+
}
|
|
79
88
|
return next(env);
|
|
80
89
|
},
|
|
81
90
|
});
|