Skip to content

Commit 80422ce

Browse files
committed
build(scripts): handle dynamic import() in .d.ts when fixing extensions
1 parent d15b1c2 commit 80422ce

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

packages/sdk/src/index.gen.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ import { Testv1 } from '@scaleway/sdk-test'
4545
import { Vpcv2 } from '@scaleway/sdk-vpc'
4646
import { Vpcgwv1, Vpcgwv2 } from '@scaleway/sdk-vpcgw'
4747
import { Webhostingv1 } from '@scaleway/sdk-webhosting'
48-
49-
export { createAdvancedClient, createClient } from '@scaleway/sdk-client'
48+
export { createClient, createAdvancedClient } from '@scaleway/sdk-client'
5049

5150
/**
5251
* @deprecated Direct version exports are deprecated. Use the 'Account' namespace instead (e.g., Account.v1).

scripts/fix-import-extensions.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,19 @@ function walk(dir: string, callback: (file: string) => void) {
1616

1717
function fixFile(file: string) {
1818
let content = fs.readFileSync(file, 'utf8')
19+
20+
// Fix regular imports (from, export *)
1921
content = content.replace(
2022
/((?:from|export \*)\s*['"])(\.{1,2}\/[^'"]+?)(?<!\.js|\.json|\.cjs|\.mjs|\.d\.ts)(['"])/g,
2123
'$1$2.js$3',
2224
)
25+
26+
// Fix dynamic imports in type expressions (import("./types.gen") -> import("./types.gen.js"))
27+
content = content.replace(
28+
/(import\(['"])(\.{1,2}\/[^'"]+?)(?<!\.js|\.json|\.cjs|\.mjs|\.d\.ts)(['"]\))/g,
29+
'$1$2.js$3',
30+
)
31+
2332
fs.writeFileSync(file, content, 'utf8')
2433
}
2534

0 commit comments

Comments
 (0)