Under a very specific circumstance, the generated output from esbuild
does not contain the //# sourceMappingURL=
reference.
If you write a simple plugin to rename the files on end, example below, the output does not contain the source map link.
However, if I go into node_modules
and force the esbuild
sourcemap input to be:
sourcemap: 'linked',
It will work as expected.
Please update the types of sourcemap to be:
sourcemap?: boolean | 'inline' | 'linked';
With an implementation of:
sourcemap: options.sourcemap === true
? "external"
: typeof options.sourcemap === 'string'
? options.sourcemap
: false,
Here is an example plugin (you'll need to adapt for a working example):
const RenameOnEnd: Plugin = {
name: 'rename-on-end',
setup(build) {
build.onEnd((result) => {
for (const file of result.outputFiles || []) {
if (file.path.endsWith('.js.map')) {
continue;
}
file.path = file.path + '.special.js';
}
});
}
};
export default defineConfig({
entry: ['lambdas/*/*-handler.ts'],
splitting: true,
target: 'esnext',
sourcemap: true,
format: ['esm'],
clean: true,
outDir: 'dist/lambdas',
esbuildPlugins: [RenameOnEnd],
});
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too