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

fix: sourcemap generation for story files #11

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions packages/builder-rsbuild/src/loaders/export-order-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,17 @@ export default async function loader(
)
}

const generatedMap = magicString.generateMap({ hires: true })

return callback(null, magicString.toString(), generatedMap, meta)
return callback(
null,
magicString.toString(),
map ??
magicString.generateMap({
hires: true,
includeContent: true,
source: this.resourcePath,
}),
meta,
)
} catch (err) {
return callback(null, source, map, meta)
}
Expand Down
16 changes: 11 additions & 5 deletions packages/react-rsbuild/src/loaders/react-docgen-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ let matchPath: TsconfigPaths.MatchPath | undefined
export default async function reactDocgenLoader(
this: LoaderContext<{ debug: boolean }>,
source: string,
map: any,
) {
const callback = this.async()
// get options
Expand Down Expand Up @@ -149,11 +150,16 @@ export default async function reactDocgenLoader(
}
})

const map = magicString.generateMap({
includeContent: true,
source: this.resourcePath,
})
callback(null, magicString.toString(), map)
callback(
null,
magicString.toString(),
map ??
magicString.generateMap({
hires: true,
source: this.resourcePath,
includeContent: true,
}),
)
} catch (error: any) {
if (error.code === ERROR_CODES.MISSING_DEFINITION) {
callback(null, source)
Expand Down