Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

feat: add support for generating sourcemaps #276

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bryan-hoang
Copy link

@bryan-hoang bryan-hoang commented Dec 20, 2024

Resolves #164

The CLI now accepts a --sourcemap option that should match the behaviour of esbuild's --sourcemap option. The programmatic API's esbuild.sourcemap option should now also match with esbuild's sourcemap option for the Build API.

The sourcemap: 'linked' option is special cased in the implementation, since esbuild doesn't support the option under the Transform API that mkdist uses 1.

Refs: https://esbuild.github.io/api/#sourcemap
Refs: https://sourcemaps.info/spec.html

Footnotes

  1. https://github.com/evanw/esbuild/blob/745abd9f0c06f73ca40fbe198546a9bc36c23b81/pkg/api/api_impl.go#L1749

Comment on lines +291 to +295
"dist/components/script-multi-block.vue.mjs.map",
"dist/components/script-setup-ts.vue",
"dist/components/script-setup-ts.vue.mjs.map",
"dist/components/ts.vue",
"dist/components/ts.vue.mjs.map",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure about the generation of the *.vue.mjs.map files, as I haven't worked with .vue files before.

const { writtenFiles } = await mkdist({
rootDir,
esbuild: {
sourcemap: "linked",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only added a test case with the "linked" option since that's what I'm personally interested in, and I wasn't sure how the option would change if esbuild were to be swapped out with rolldown. I'd be happy to add test cases for the other modes if deemed necessary.

The CLI now accepts a `--sourcemap` option that should match the
behaviour of `esbuild`'s `--sourcemap` option. The programmatic API's
`esbuild.sourcemap` option should now also match with `esbuild`'s
`sourcemap` option for the Build API.

The `sourcemap: 'linked'` option is special cased in the implementation,
since `esbuild` doesn't support the option under the Transform API that
`mkdist` uses [^1].

Refs: https://esbuild.github.io/api/#sourcemap
Refs: https://sourcemaps.info/spec.html

[^1]: https://github.com/evanw/esbuild/blob/745abd9f0c06f73ca40fbe198546a9bc36c23b81/pkg/api/api_impl.go#L1749
@bryan-hoang bryan-hoang force-pushed the feature/sourcemap-generation branch from f9d2746 to 40bded1 Compare December 20, 2024 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sourcemap generation support
1 participant