From 6c9a90e87d16a446f859edfba6585dc9766cb7bb Mon Sep 17 00:00:00 2001 From: Richard Harris Date: Sun, 9 Jun 2019 18:55:00 -0400 Subject: [PATCH] rewrite source code to point at correct files --- src/api/utils/copy_runtime.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/api/utils/copy_runtime.ts b/src/api/utils/copy_runtime.ts index 6f50815..c446460 100644 --- a/src/api/utils/copy_runtime.ts +++ b/src/api/utils/copy_runtime.ts @@ -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); }); } \ No newline at end of file