body-builder / typescript-cp

Copy non-typescript files to outDir

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Handle two output directories

ungarson opened this issue · comments

commented

I have this in tsconfig

"main": "./lib/cjs/index.js",
"module": "./lib/esm/index.js",

So, I have two folders with built typescript:
lib/cjs/ and lib/esm/

The first one is for when my package is used on server with commonjs' require(),
second is when it's used with import()

Right now tscp only adds files to esm folder.

My scripts in package.json:

"build": "npm run build:ts && npm run build:cjs",
"build:ts": "tsc && tscp",
"build:cjs": "tsc --module commonjs --outDir lib/cjs && tscp"

Could you please create a minimal example repo? I would be happy to work on this, but I would like to make sure about the exact setup.

In the meantime, as a workaround, you might create a second tsconfig, that is responsible for the commonjs folder. This can be passed to tscp.

"build:cjs": "tsc --module commonjs --outDir lib/cjs && tscp -p tsconfig.cjs.json"

@ungarson Just a friendly ping, to keep the ticket active. It might be also enough if you share your tsconfig.json so I can find a good solution.

commented

@bencergazda hello, I think I can't give you the example repo anymore, I switched to using some other instruments, thanks!