fix: keep loro-crdt sourcemap sources inside the package (#947)#987
Merged
Conversation
Rewrite rollup output `sources` so they resolve inside the published package and embed `sourcesContent`, removing the Vite/Vitest "source file outside its package" warning users see for loro-crdt. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
WASM Size Report
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
loro-crdtsourcemaps emitsources: ["../../index.ts"], which — resolved fromnode_modules/loro-crdt/<target>/index.js.map— escapes the package, so Vite/Vitest log: "Sourcemap for ... points to a source file outside its package: 'node_modules/index.ts'".@rollup/plugin-typescripthands rollup a map whosesourcesare relative to TS's intended JS output, but rollup resolves them against the.tssource directory, leaving an extra..segment in the published map. Separately,sourcesContentwasnullbecause the plugin only auto-enablesinlineSourceswhensourceMapis unset — but our tsconfig setsinlineSourceMap: true, which the plugin rewrites tosourceMap: truewhile leavinginlineSourcesoff.crates/loro-wasm/rollup.config.mjs:output.sourcemapPathTransformthat detects sources resolving outside the package and rewrites them to the real file inside the package (one less..).compilerOptions.inlineSources: trueon the TS plugin sosourcesContentis populated.After the fix, all four targets (
nodejs,bundler,web,browser) emitsources: ["../index.ts"]with 12 788 chars ofsourcesContent. Resolved from a publishednode_modules/loro-crdt/<target>/index.js.map, that lands onnode_modules/loro-crdt/index.ts— inside the package — silencing the Vite warning.Test plan
*/index.js.map'ssourcesresolves inside the packagesourcesContentis populated (nonull)loro-crdtin a Vite/Vitest project and confirm the warning is gone🤖 Generated with Claude Code