This commit is contained in:
Rich Harris
2018-12-20 23:16:03 -05:00
parent 02cef046aa
commit 82a023c302
8 changed files with 59 additions and 58 deletions

View File

@@ -151,11 +151,11 @@ function generate_client(
}
return `// This file is generated by Sapper — do not edit it!\n` + template
.replace('__ROOT__', stringify(get_file(path_to_routes, manifest_data.root), false))
.replace('__ERROR__', stringify(posixify(`${path_to_routes}/_error.html`), false))
.replace('__IGNORE__', `[${server_routes_to_ignore.map(route => route.pattern).join(', ')}]`)
.replace('__COMPONENTS__', components)
.replace('__PAGES__', pages) +
.replace(/__ROOT__/g, stringify(get_file(path_to_routes, manifest_data.root), false))
.replace(/__ERROR__/g, stringify(posixify(`${path_to_routes}/_error.html`), false))
.replace(/__IGNORE__/g, `[${server_routes_to_ignore.map(route => route.pattern).join(', ')}]`)
.replace(/__COMPONENTS__/g, components)
.replace(/__PAGES__/g, pages) +
footer;
}
@@ -174,8 +174,8 @@ function generate_server(
manifest_data.server_routes.map(route =>
`import * as __${route.name} from ${stringify(posixify(`${path_to_routes}/${route.file}`))};`),
manifest_data.components.map(component =>
`import __${component.name} from ${stringify(get_file(path_to_routes, component))};`),
`import root from ${stringify(get_file(path_to_routes, manifest_data.root))};`,
`import __${component.name}, * as __${component.name}_static from ${stringify(get_file(path_to_routes, component))};`),
`import root, * as root_static from ${stringify(get_file(path_to_routes, manifest_data.root))};`,
`import error from ${stringify(posixify(`${path_to_routes}/_error.html`))};`
);
@@ -207,7 +207,8 @@ function generate_server(
const props = [
`name: "${part.component.name}"`,
`file: ${stringify(part.component.file)}`,
`component: __${part.component.name}`
`component: __${part.component.name}`,
`preload: __${part.component.name}_static.preload`
];
if (part.params.length > 0) {
@@ -222,6 +223,7 @@ function generate_server(
],
root,
root_preload: root_static['pre' + 'load'],
error
};`.replace(/^\t\t/gm, '').trim();