esbuild-node-tsc icon indicating copy to clipboard operation
esbuild-node-tsc copied to clipboard

Support monorepo

Open HexaField opened this issue 4 years ago • 3 comments

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.

HexaField avatar Jul 13 '21 00:07 HexaField

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.

binary64 avatar Jul 20 '21 18:07 binary64

sure, could you raise a pr @binary64 ?

a7ul avatar Jul 21 '21 07:07 a7ul

@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);
}

sidwebworks avatar Sep 03 '21 14:09 sidwebworks