(config, output)
| 99 | * @param {string} output |
| 100 | */ |
| 101 | export function write_server(config, output) { |
| 102 | const server_hooks_file = resolve_entry(config.kit.files.hooks.server); |
| 103 | const universal_hooks_file = resolve_entry(config.kit.files.hooks.universal); |
| 104 | |
| 105 | const typo = resolve_entry('src/+hooks.server'); |
| 106 | if (typo) { |
| 107 | console.log( |
| 108 | colors |
| 109 | .bold() |
| 110 | .yellow( |
| 111 | `Unexpected + prefix. Did you mean ${typo.split('/').at(-1)?.slice(1)}?` + |
| 112 | ` at ${path.resolve(typo)}` |
| 113 | ) |
| 114 | ); |
| 115 | } |
| 116 | |
| 117 | /** @param {string} file */ |
| 118 | function relative(file) { |
| 119 | return posixify(path.relative(`${output}/server`, file)); |
| 120 | } |
| 121 | |
| 122 | // Contains the stringified version of |
| 123 | /** @type {import('types').SSROptions} */ |
| 124 | write_if_changed( |
| 125 | `${output}/server/internal.js`, |
| 126 | server_template({ |
| 127 | config, |
| 128 | server_hooks: server_hooks_file ? relative(server_hooks_file) : null, |
| 129 | universal_hooks: universal_hooks_file ? relative(universal_hooks_file) : null, |
| 130 | has_service_worker: |
| 131 | config.kit.serviceWorker.register && !!resolve_entry(config.kit.files.serviceWorker), |
| 132 | runtime_directory: relative(runtime_directory), |
| 133 | template: load_template(process.cwd(), config), |
| 134 | error_page: load_error_page(config) |
| 135 | }) |
| 136 | ); |
| 137 | } |
no test coverage detected