esbuild-node-tsc
esbuild-node-tsc copied to clipboard
Support monorepo
Hello, I would love to use this package as ts-eager seems to have technical flaws, though it seems that this package fails to manage adjacent packages in the monorepo. Have you had any success with this? Thank you.
Could we start with support for a --cwd type flag?
User@DESKTOP-QRQIHPO MINGW64 /c/p/monorepo/apps/blah (master)
$ yarn esbuild-node-tsc --cwd .
yarn run v1.22.10
$ C:\p\monorepo\node_modules\.bin\esbuild-node-tsc --cwd .
Using default config
Error: tsconfig.json not found in the current directory! C:\p\monorepo
(note there is a tsconfig.json in the current directory, it's just that it extends from another one ../)
Note doing yarn esbuild-node-tsc --cwd apps/blah would also be good. Have to pick now though which scheme to use.
sure, could you raise a pr @binary64 ?
@a7ul How to use this inside a esbuild project? please help out,
Here is my esBuild config.
const { build } = require("esbuild");
const { dependencies, peerDependencies } = require("./package.json");
const esbuildPluginTsc = require("esbuild-plugin-tsc");
// Automatically exclude all node_modules from the bundled version
const { nodeExternalsPlugin } = require("esbuild-node-externals");
const args = process.argv.slice(2);
let watch;
if (args.includes("--watch" || "-w")) {
watch = {
onRebuild(error, result) {
if (error) console.error("watch build failed:", error);
else console.log("watch build succeeded:");
},
};
}
const shared = {
entryPoints: ["./src/index.tsx"],
plugins: [esbuildPluginTsc({ tsx: true }), nodeExternalsPlugin()],
bundle: true,
minify: true,
watch,
platform: "node",
target: ["esnext"],
sourcemap: true,
external: Object.keys(dependencies).concat(Object.keys(peerDependencies)),
};
try {
build({
...shared,
format: "esm",
outfile: "dist/index.esm.js",
});
build({
...shared,
outfile: "dist/index.js",
});
} catch (err) {
process.exit(1);
}