From 90e9800351d37a1458cac251e1b82538f0eaaee6 Mon Sep 17 00:00:00 2001 From: Ping Chen Date: Tue, 21 Nov 2023 17:31:43 +0900 Subject: [PATCH] make sure processor.ts exists in sourcemap --- src/esbuild/index.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/esbuild/index.ts b/src/esbuild/index.ts index 9b07f24e9..96a6166c7 100644 --- a/src/esbuild/index.ts +++ b/src/esbuild/index.ts @@ -119,6 +119,21 @@ export async function runEsbuild( await pluginContainer.buildStarted() const esbuildPlugins: Array = [ + { + name: 'sentio-processor', + setup(build) { + // Make sure src/**/*.ts exists in sourcemap. + build.onLoad({ filter: /\/src\/(.+\/)*.+\.ts$/ }, async (args) => { + const content = await fs.promises.readFile(args.path, 'utf8') + return { + loader: 'ts', + contents: + content + + ';import("node:process").then((p) => p.stdout.write(""));', + } + }) + }, + }, format === 'cjs' && options.removeNodeProtocol && nodeProtocolPlugin(), { name: 'modify-options',