Skip to content

Commit 538b903

Browse files
committed
feat: support pass prev source map 🍉
1 parent fa3e3a8 commit 538b903

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/interface.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type AllowTransformOpts = Omit<
1616
* @analyzeDependencies
1717
* @pseudoClasses
1818
* @unusedSymbols
19+
* @errorRecovery
1920
*/
2021
>
2122

@@ -30,18 +31,18 @@ export interface IMinifyPluginOpts extends AllowTransformOpts {
3031
// loader
3132
type AllowLoaderTransformOpts = Omit<
3233
TransformOptions,
33-
'filename' | 'code' | 'targets'
34+
'filename' | 'code' | 'targets' | 'inputSourceMap'
3435
/**
3536
* allow
3637
*
3738
* @cssModules
3839
* @minify
3940
* @sourceMap
40-
* @targets
4141
* @drafts
4242
* @analyzeDependencies
4343
* @pseudoClasses
4444
* @unusedSymbols
45+
* @errorRecovery
4546
*/
4647
>
4748

src/loader.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import { getTargets } from './utils'
77
const LOADER_NAME = `parcel-css-loader`
88
export async function ParcelCssLoader(
99
this: LoaderContext<IParcelCssLoaderConfig>,
10-
source: string
10+
source: string,
11+
prevMap?: Record<string, any>
1112
): Promise<void> {
1213
const done = this.async()
1314
const options = this.getOptions()
@@ -30,6 +31,8 @@ export async function ParcelCssLoader(
3031
code: Buffer.from(source),
3132
sourceMap: this.sourceMap,
3233
targets: getTargets({ default: userTargets, key: ECacheKey.loader }),
34+
inputSourceMap:
35+
this.sourceMap && prevMap ? JSON.stringify(prevMap) : undefined,
3336
...opts,
3437
})
3538
const codeAsString = code.toString()

0 commit comments

Comments
 (0)