mirror of
https://github.com/danbulant/oxc
synced 2026-05-21 05:08:45 +00:00
fix(napi/transform): respect options.sourcemap for id (#7590)
Don't pass `source_map_path` if `options.sourcemap` is undefined or false; then, `IsolatedDeclarationsResult.map` should be undefined. Downstream issue https://github.com/unplugin/unplugin-isolated-decl/issues/42 --------- Co-authored-by: Boshen <boshenc@gmail.com>
This commit is contained in:
parent
b553d6ff9c
commit
be2293a1b5
2 changed files with 11 additions and 5 deletions
|
|
@ -39,11 +39,12 @@ pub fn isolated_declaration(
|
|||
)
|
||||
.build(&ret.program);
|
||||
|
||||
let source_map_path = match options.sourcemap {
|
||||
Some(true) => Some(source_path.to_path_buf()),
|
||||
_ => None,
|
||||
};
|
||||
let codegen_ret = CodeGenerator::new()
|
||||
.with_options(CodegenOptions {
|
||||
source_map_path: Some(source_path.to_path_buf()),
|
||||
..CodegenOptions::default()
|
||||
})
|
||||
.with_options(CodegenOptions { source_map_path, ..CodegenOptions::default() })
|
||||
.build(&transformed_ret.program);
|
||||
|
||||
let errors = ret.errors.into_iter().chain(transformed_ret.errors).collect();
|
||||
|
|
|
|||
|
|
@ -25,10 +25,15 @@ describe('simple', () => {
|
|||
assert.equal(ret.code, 'export class A {}\n');
|
||||
});
|
||||
|
||||
it('uses the `declaration option`', () => {
|
||||
it('uses the `declaration` option', () => {
|
||||
const ret = transform('test.ts', code, { typescript: { declaration: {} } });
|
||||
assert.equal(ret.declaration, 'export declare class A<T> {}\n');
|
||||
});
|
||||
|
||||
it('uses the `sourcemap` option', () => {
|
||||
const ret = transform('test.ts', code, { typescript: { declaration: {} }, sourcemap: true });
|
||||
assert(ret.declarationMap);
|
||||
});
|
||||
});
|
||||
|
||||
describe('transform', () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue