Skip to content

Commit cde3afd

Browse files
committed
fix: bun compatibility
- explicitly pass "types": [] to tsconfig to avoid bun compilation errors - detect bun as package manager fixes Error compiling generated code #2124
1 parent 47be505 commit cde3afd

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

packages/schema/src/utils/pkg-utils.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export function findNodeModulesFile(name: string, cwd: string = process.cwd()) {
6767
}
6868

6969
export function getPackageManager(searchStartPath = '.') {
70-
const lockFile = findUp(['yarn.lock', 'pnpm-lock.yaml', 'package-lock.json'], searchStartPath);
70+
const lockFile = findUp(['yarn.lock', 'bun.lock', 'pnpm-lock.yaml', 'package-lock.json'], searchStartPath);
7171

7272
if (!lockFile) {
7373
// default use npm
@@ -77,6 +77,7 @@ export function getPackageManager(searchStartPath = '.') {
7777
const packageManager = match(path.basename(lockFile))
7878
.with('yarn.lock', () => 'yarn')
7979
.with('pnpm-lock.yaml', () => 'pnpm')
80+
.with('bun.lock', () => 'bun')
8081
.otherwise(() => 'npm');
8182

8283
return { packageManager, lockFile, projectRoot: path.dirname(lockFile) };
@@ -99,6 +100,14 @@ export function installPackage(
99100
);
100101
break;
101102

103+
case 'bun':
104+
execSync(
105+
`bun install --cwd "${projectPath}" ${exactVersion ? '--exact' : ''} ${
106+
dev ? ' --dev' : ''
107+
} ${pkg}@${tag}`
108+
);
109+
break;
110+
102111
case 'pnpm':
103112
execSync(
104113
`pnpm add -C "${projectPath}" ${exactVersion ? '--save-exact' : ''} ${

packages/sdk/src/code-gen.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ export function createProject(options?: CompilerOptions) {
1515
skipLibCheck: true,
1616
noEmitOnError: true,
1717
noImplicitAny: false,
18+
skipDefaultLibCheck: true,
19+
types: [],
1820
...options,
1921
},
2022
});

0 commit comments

Comments
 (0)