lib/svelte/js/builder.js in actionview-svelte-handler-0.8.0 vs lib/svelte/js/builder.js in actionview-svelte-handler-0.8.1
- old
+ new
@@ -54,22 +54,18 @@
export default rendered;
`;
} else {
entry = `
import App from "${this.path}";
- import { hydrate } from "svelte";
+ import { hydrate, flushSync } from "svelte";
- function hydrateApp() {
- const app = hydrate(App, {
- target: document.getElementById("hydratee-${this.digest}"),
- props: JSON.parse('${JSON.stringify(this.props)}')
- })
-
- app.flushSync();
- }
+ hydrate(App, {
+ target: document.getElementById("hydratee-${this.digest}"),
+ props: JSON.parse('${JSON.stringify(this.props)}')
+ })
- export default hydrateApp;
+ flushSync();
`;
}
const bundle = (await (await rollup({
input: "entry",
output: {
@@ -131,35 +127,14 @@
bundle[0].map.sources = bundle[0].map.sources.map((el) => {
return path.relative(this.path, this.root) + "/" + path.relative(this.root, el);
});
return `//# sourceMappingURL=${bundle[0].map.toUrl()}
//# sourceURL=${path.relative(this.path, this.root) + "/" + path.relative(this.root, this.path)}
-${bundle[0].code}`.trim();
+${bundle[0].code}`.trim().replace(/\n.*$/, "");
}
async client() {
return this.compiled?.client || await this.bundle("dom");
}
- // standardizeClient (code: string): string {
- // const ast = recast.parse(code)
- // let name: string | undefined
- // recast.visit(ast, {
- // visitExportNamedDeclaration: (path) => {
- // const stagingName: any = path.node?.specifiers?.[0].local?.name
- // name = typeof stagingName !== 'string' ? '' : stagingName
- // path.prune()
- // return false
- // }
- // })
- // recast.visit(ast, {
- // visitIdentifier: (path) => {
- // if (path.node.name === name) {
- // path.node.name = 'App'
- // }
- // return false
- // }
- // })
- // return recast.print(ast).code
- // }s
async server() {
const output = this.compiled?.server || await this.bundle("ssr");
const { html, css, head } = importFromStringSync(output).default;
return { output, html, head, css: css?.code };
}