We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
#525
So I just use script to turn it to esm ( add .js to the import path as extension )
.js
import { open,lstat, readFile, readdir, writeFile } from "node:fs/promises"; import { extname, join } from "node:path"; const regexpNames = /(from\s+)(["'])(?!.*\.js)(((\.?\.\/)|antlr4ts\/).*)(["'])/gm async function addJsExt(path: string) { const files = await readdir(path, 'utf-8') for (const fileName of files) { const pathNew = join(path, fileName) const stat = await lstat(pathNew) if (stat.isDirectory()) { await addJsExt(pathNew) } else if (stat.isFile() && extname(fileName) == ".ts") { const codes = await readFile(pathNew, { encoding: 'utf-8' }).catch(err=>{throw err}) await writeFile(pathNew, codes.replace(regexpNames,"$1$2$3.js$6"), {encoding: "utf8"}).catch(err=>{throw err}) } } } const path = join(process.cwd(), process.argv[2]) await addJsExt(path) export {}
usage: "scripts": { "convert-to-esm": " ts-node-esm ./src/lib/JSExtUtils.ts ./src/antlr" }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
#525
So I just use script to turn it to esm ( add
.js
to the import path as extension )usage:
"scripts": {
"convert-to-esm": " ts-node-esm ./src/lib/JSExtUtils.ts ./src/antlr"
}
The text was updated successfully, but these errors were encountered: