egoist / tsup

The simplest and fastest way to bundle your TypeScript libraries.
https://tsup.egoist.dev
MIT License
9.12k stars 219 forks source link

cannot recognize "extends" field inside tsconfig.json that will extends third-party as the base config #941

Open jaylenchan opened 1 year ago

jaylenchan commented 1 year ago

imagine there is a monorepo, the structure is below:

the server app uses the tsconfig.json file that will extends the local package named "tsconfig" inside packages folder. the code inside tsconfig.json file of server likes below:

 {
   "extends": tsconfig/base.json
 }

the package.json of server :

 "devDependencies": {
  "tsconfig": "workspace:*"
}

and then, I use the logger package in the server app with import logger from '@jeditor/logger' , by now ,everything is Ok, but when I use tsup to bundle my server app, it got an error shows "could not resolve @jeditor/logger"。

the base.json likes below:

"baseUrl": "../../",
"paths": {
   "@jeditor/*": ["packages/*/src"]
}

the baseUrl will point to monorepo root.

the tsup.config.ts likes below:

        entry: ['src'],
    splitting: true,
    clean: true,
    format: ['cjs'],
    platform: 'node',
    tsconfig: 'tsconfig.build.json',
    bundle: true,
    noExternal:["@jeditor/logger"],
    dts: process.env.NODE_ENV === 'production' ? false : true,
    sourcemap: process.env.NODE_ENV === 'production' ? false : true,
    minify: process.env.NODE_ENV === 'production' ? 'terser' : false,
    terserOptions: {
        compress: true,
        keep_classnames: false,
        keep_fnames: false,
        mangle: true,
        sourceMap: false,
    }

question: can tsup resolve the tsconfig that is the local pkg inside the monorepo? if tsup can resolved it, can tsup recognize the paths alias in the tsconfig/base.json?

error pic:

Screenshot 2023-06-30 at 17 12 17

Upvote & Fund

Fund with Polar

jaylenchan commented 1 year ago

I think there is not a mechanisms can read the third-party as the base config. I install the tsconfig package as the server dependency, but it also got the error likes above. but if I change the bundle option to false, and do not use the bundle feature , just use the compile feature like tsc ,everything goes well