mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-09-27 02:43:48 +02:00
Add .js extension even in declaration files
This commit is contained in:
@@ -13,7 +13,7 @@ const walkDir = (dir: string) => {
|
|||||||
|
|
||||||
if (stat.isDirectory()) {
|
if (stat.isDirectory()) {
|
||||||
files.push(...walkDir(fullPath));
|
files.push(...walkDir(fullPath));
|
||||||
} else if (item.endsWith('.js')) {
|
} else if (item.endsWith('.js') || item.endsWith('.ts')) {
|
||||||
files.push(fullPath);
|
files.push(fullPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23,8 +23,13 @@ const walkDir = (dir: string) => {
|
|||||||
|
|
||||||
const fixFile = (filePath: string) => {
|
const fixFile = (filePath: string) => {
|
||||||
const content = fs.readFileSync(filePath, 'utf8');
|
const content = fs.readFileSync(filePath, 'utf8');
|
||||||
const fixed = content.replace(
|
// We only match relative imports
|
||||||
/(\s+from\s+['"])(\.[^'"]*)(['"])/g, // This only matches relative imports
|
let fixed = content.replace(
|
||||||
|
/(\s+from\s+['"])(\.[^'"]*)(['"])/g, // This matches static imports
|
||||||
|
'$1$2.js$3',
|
||||||
|
);
|
||||||
|
fixed = fixed.replace(
|
||||||
|
/(import\s*\(\s*['"])(\.[^'"]*)(['"]\s*\))/g, // This matches dynamic imports
|
||||||
'$1$2.js$3',
|
'$1$2.js$3',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user