Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

SourceMap Not Linked When Enabled #1120

Open
jd-carroll opened this issue May 11, 2024 · 0 comments
Open

SourceMap Not Linked When Enabled #1120

jd-carroll opened this issue May 11, 2024 · 0 comments

Comments

@jd-carroll
Copy link

jd-carroll commented May 11, 2024

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],
});

Related Issues:
#775
#495

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@jd-carroll jd-carroll changed the title SourceMap Not Link When Enabled SourceMap Not Linked When Enabled May 12, 2024
jd-carroll added a commit to my-public-forks/tsup that referenced this issue May 13, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant