Skip to content

Commit

Permalink
fix: sourcemap generation for story files
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinpalkovic committed May 24, 2024
1 parent 455db90 commit 4f5e1c0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
4 changes: 1 addition & 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,7 @@ export default async function loader(
)
}

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

return callback(null, magicString.toString(), generatedMap, meta)
return callback(null, magicString.toString(), map, 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

0 comments on commit 4f5e1c0

Please sign in to comment.