mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-11 19:04:30 +00:00
rewrite source code to point at correct files
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import relative from 'require-relative';
|
||||
import { mkdirp } from './fs_utils';
|
||||
|
||||
const svelte_pkg = relative('svelte/package.json', process.cwd());
|
||||
const match = /(\d+)\.(\d+)\.(\d+)/.exec(svelte_pkg.version);
|
||||
const legacy = match
|
||||
? ((+match[1] - 3) || (+match[2] - 4) || (+match[3] - 4)) <= 0
|
||||
: false; // ???
|
||||
|
||||
const runtime = [
|
||||
'app.mjs',
|
||||
'server.mjs',
|
||||
@@ -16,6 +23,8 @@ const runtime = [
|
||||
export function copy_runtime(output: string) {
|
||||
runtime.forEach(({ file, source }) => {
|
||||
mkdirp(path.dirname(`${output}/${file}`));
|
||||
|
||||
if (!legacy) source = source.replace(/svelte\/(.+)\.mjs/g, `svelte/$1/index.mjs`);
|
||||
fs.writeFileSync(`${output}/${file}`, source);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user