Skip to content

Commit 184cec3

Browse files
authored
fix: recognize __exportAll with flags argument from rolldown 1.3 (#359)
1 parent 290309a commit 184cec3

6 files changed

Lines changed: 36 additions & 1 deletion

File tree

‎src/fake-js/patch.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ function getExportAllNamespace(
151151
node.declarations[0].init?.type !== 'CallExpression' ||
152152
node.declarations[0].init.callee.type !== 'Identifier' ||
153153
node.declarations[0].init.callee.name !== '__exportAll' ||
154-
node.declarations[0].init.arguments.length !== 1 ||
154+
// rolldown >= 1.3 passes a flags argument for modules with an external `export *`
155+
node.declarations[0].init.arguments.length < 1 ||
155156
node.declarations[0].init.arguments[0].type !== 'ObjectExpression'
156157
) {
157158
return false

‎tests/__snapshots__/index.test.ts.snap‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,17 @@ export interface Test {
375375
export {};"
376376
`;
377377
378+
exports[`namespace of a module re-exporting from lib 1`] = `
379+
"// index.d.ts
380+
declare namespace lib_d_exports {
381+
export { foo };
382+
}
383+
import * as import_stub_lib from "stub-lib";
384+
declare function foo(): void;
385+
export declare const version = "1.0.0";
386+
export { lib_d_exports as lib };"
387+
`;
388+
378389
exports[`re-export from lib > both 1`] = `
379390
"// a-B4zIqhFh.d.ts
380391
import * as import_stub_lib from "stub-lib";
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * as lib from './lib'
2+
export const version = '1.0.0'
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from 'stub-lib'
2+
export function foo(): void {}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"compilerOptions": {
3+
"strict": true,
4+
"typeRoots": ["../re-export-lib/typings"]
5+
},
6+
"include": ["./index.ts", "./lib.ts"]
7+
}

‎tests/index.test.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,18 @@ test('re-export from lib', async () => {
812812
expect(both).toMatchSnapshot('both')
813813
})
814814

815+
// #354
816+
test('namespace of a module re-exporting from lib', async () => {
817+
const cwd = path.resolve(dirname, 'fixtures/namespace-re-export-lib')
818+
const { snapshot } = await rolldownBuild(
819+
['index.ts'],
820+
[dts({ dtsOnly: true })],
821+
{ cwd },
822+
)
823+
expect(snapshot).toContain('declare namespace lib_d_exports')
824+
expect(snapshot).toMatchSnapshot()
825+
})
826+
815827
test('cyclic import', async () => {
816828
const cwd = path.resolve(dirname, 'fixtures/cyclic-import')
817829
const { snapshot } = await rolldownBuild(

0 commit comments

Comments
 (0)