Skip to content

Commit 7b121d0

Browse files
attempted to fix ci
1 parent 4e3803d commit 7b121d0

File tree

2 files changed

+57
-2
lines changed

2 files changed

+57
-2
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
},
3232
"scripts": {
3333
"typecheck": "tsc --noEmit",
34-
"build": "node scripts/generate-version.cjs && tsc && tsc-esm-fix",
34+
"build": "node scripts/generate-version.cjs && tsc && node scripts/fix-imports.cjs",
3535
"dev": "tsx src/index.ts",
3636
"test:build": "npm run build && node lib/index.js",
3737
"test:version": "npm run build && node lib/index.js --version",
@@ -63,7 +63,6 @@
6363
"eslint-plugin-prettier": "5.5.0",
6464
"jiti": "2.4.2",
6565
"prettier": "3.5.3",
66-
"tsc-esm-fix": "3.1.2",
6766
"tsx": "4.20.3",
6867
"typescript": "5.8.3",
6968
"vitest": "3.2.4"

scripts/fix-imports.cjs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env node
2+
3+
const fs = require('fs');
4+
const path = require('path');
5+
6+
function fixImportsInFile(filePath) {
7+
let content = fs.readFileSync(filePath, 'utf8');
8+
9+
// Fix relative imports to include .js extension
10+
content = content.replace(
11+
/from ['"](\.\/[^'"]*?)['"]/g,
12+
(match, importPath) => {
13+
if (!importPath.endsWith('.js')) {
14+
return `from '${importPath}.js'`;
15+
}
16+
return match;
17+
}
18+
);
19+
20+
// Fix relative imports with ../
21+
content = content.replace(
22+
/from ['"](\.\.\/[^'"]*?)['"]/g,
23+
(match, importPath) => {
24+
if (!importPath.endsWith('.js')) {
25+
return `from '${importPath}.js'`;
26+
}
27+
return match;
28+
}
29+
);
30+
31+
fs.writeFileSync(filePath, content);
32+
}
33+
34+
function processDirectory(dir) {
35+
const files = fs.readdirSync(dir);
36+
37+
for (const file of files) {
38+
const filePath = path.join(dir, file);
39+
const stat = fs.statSync(filePath);
40+
41+
if (stat.isDirectory()) {
42+
processDirectory(filePath);
43+
} else if (file.endsWith('.js')) {
44+
fixImportsInFile(filePath);
45+
}
46+
}
47+
}
48+
49+
// Process the lib directory
50+
const libDir = path.join(__dirname, '..', 'lib');
51+
if (fs.existsSync(libDir)) {
52+
processDirectory(libDir);
53+
console.log('✅ Fixed import extensions in compiled files');
54+
} else {
55+
console.log('❌ lib directory not found');
56+
}

0 commit comments

Comments
 (0)