diff --git a/src/files/handler.js b/src/files/handler.js index 4d4fd86..61a5941 100644 --- a/src/files/handler.js +++ b/src/files/handler.js @@ -1,5 +1,3 @@ -import '@sveltejs/kit/install-fetch'; // eslint-disable-line import/no-unassigned-import - // TODO: hardcoding the relative location makes this brittle import {init, render} from '../output/server/app.js'; diff --git a/src/files/shims.js b/src/files/shims.js new file mode 100644 index 0000000..29d9c09 --- /dev/null +++ b/src/files/shims.js @@ -0,0 +1 @@ +export {fetch, Response, Request, Headers} from '@sveltejs/kit/install-fetch'; diff --git a/src/index.js b/src/index.js index a066bb7..8c9bb50 100644 --- a/src/index.js +++ b/src/index.js @@ -158,7 +158,8 @@ async function prepareEntrypoint({utils, serverOutputDir}) { utils.rimraf(temporaryDir); utils.rimraf(serverOutputDir); - const handlerSource = path.join(fileURLToPath(new URL('./files', import.meta.url)), 'handler.js'); + const files = fileURLToPath(new URL('./files', import.meta.url)); + const handlerSource = path.join(files, 'handler.js'); const handlerDest = path.join(temporaryDir, 'handler.js'); utils.copy(handlerSource, handlerDest); @@ -166,6 +167,7 @@ async function prepareEntrypoint({utils, serverOutputDir}) { entryPoints: [path.join(temporaryDir, 'handler.js')], outfile: path.join(serverOutputDir, 'index.js'), bundle: true, + inject: [path.join(files, 'shims.js')], platform: 'node', target: ['node12'] });