fix imports in *.d.ts files for esm

This commit is contained in:
Roland Kuhn 2023-02-15 13:39:28 +01:00
parent 888fbf3254
commit 4d418be23a

View File

@ -1,7 +1,7 @@
import FileHound from 'filehound';
import fs from 'fs';
const files = FileHound.create().paths('./lib').ext('js').find();
const files = FileHound.create().paths('./lib').ext(['js', 'ts']).find();
files.then((filePaths) => {
filePaths.forEach((filepath) => {
@ -22,6 +22,9 @@ files.then((filePaths) => {
"import * as Canvas from 'canvas';"
);
// Handle import("./x/y/z") syntax.
text = text.replace(/(import\s*\(\s*['"])(.*)(?=['"])/g, '$1$2.js');
fs.writeFile(filepath, text, function (err) {
if (err) {
throw err;