-
-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for TypeScript project references #647
Comments
I'd like to add some context and reproduction to this. I'm converting existing monorepos over to Goals:
Reproduction (errors):https://github.com/rosskevin/ts-esm-workspaces/tree/vite-tsup-project-references
~/p/t/p/shared ❯❯❯ yarn build
CLI Building entry: src/index.ts
CLI Using tsconfig: tsconfig.json
CLI tsup v6.2.3
CLI Using tsup config: /Users/kross/projects/ts-esm-workspaces/packages/tsup.common.ts
CLI Target: node14
CLI Cleaning output folder
ESM Build start
CJS Build start
ESM dist/index.js 143.00 B
ESM dist/index.js.map 379.00 B
ESM ⚡️ Build success in 37ms
CJS dist/index.cjs 639.00 B
CJS dist/index.cjs.map 556.00 B
CJS ⚡️ Build success in 35ms
DTS Build start
src/index.ts(1,15): error TS6307: File '/Users/kross/projects/ts-esm-workspaces/packages/shared/src/utils.ts' is not listed within the file list of project ''. Projects must list all files or use an 'include' pattern.
Error: error occured in dts build
at Worker.<anonymous> (/Users/kross/projects/ts-esm-workspaces/node_modules/tsup/dist/index.js:2157:26)
at Worker.emit (node:events:513:28)
at MessagePort.<anonymous> (node:internal/worker:233:53)
at [nodejs.internal.kHybridDispatch] (node:internal/event_target:731:20)
at exports.emitMessage (node:internal/per_context/messageport:23:28)
Error: Failed to compile. Check the logs above.
at error (/Users/kross/projects/ts-esm-workspaces/node_modules/tsup/node_modules/rollup/dist/shared/rollup.js:198:30)
at throwPluginError (/Users/kross/projects/ts-esm-workspaces/node_modules/tsup/node_modules/rollup/dist/shared/rollup.js:21718:12)
at Object.error (/Users/kross/projects/ts-esm-workspaces/node_modules/tsup/node_modules/rollup/dist/shared/rollup.js:22672:20)
at Object.error (/Users/kross/projects/ts-esm-workspaces/node_modules/tsup/node_modules/rollup/dist/shared/rollup.js:21895:42)
at Object.transform (/Users/kross/projects/ts-esm-workspaces/node_modules/tsup/dist/rollup.js:7217:20)
at /Users/kross/projects/ts-esm-workspaces/node_modules/tsup/node_modules/rollup/dist/shared/rollup.js:22879:40
DTS Build error Reproduction without project references (doesn't fulfill the IDE requirement):https://github.com/rosskevin/ts-esm-workspaces/tree/vite TL;DRDifferent tools require different setups. Does that make sense? |
Related #688 |
|
Ok, this workaround is awful, but it does work: "scripts": {
"build": "run-s clean build:ide pretsup build:tsup",
"build:ide": "echo 'tsc -b' && tsc -b",
"build:tsup": "lerna exec --stream --parallel -- yarn tsup --config ../../tsup.config.ts",
"pretsup": "echo 'removing js' && node ./scripts/pre-tsup.js",
}, 1: I do hope that my original comment serves as enough justification and provides a reproducible environment so that this is fixed at some point. |
+1, it would be amazing to have support for references in Update: Locking the |
+1, this would improve the DX significantly. |
I came across with the same problem. However I managed to workaround this using the onSuccess function. const { defineConfig } = require('tsup');
const fs = require('fs');
module.exports = defineConfig({
....,
async onSuccess() {
if (process.env.npm_lifecycle_event === 'dev') {
const time = new Date();
fs.utimes('../../path-to-the/app-needs-to-rebuild/src/index.tsx', time, time, () => {});
}
},
}); |
I have setup minimal reproduction monorepo that demonstrates this issue: https://github.com/toteto/example-monorepo |
Any news? |
Please add support for this. I am using Turbo repo and utilize project references between my apps. |
The vanilla TypeScript compiler has a feature called project references that makes it more convenient to work on composite/monorepo projects that would otherwise need multiple watch processes, and also for making sure they rebuild when a dependency changes.
It would be nice to have support for this in tsup.
Basically it might just need tsup to know how to correctly order the build of dependent project's d.ts.
https://www.typescriptlang.org/docs/handbook/project-references.html
Upvote & Fund
The text was updated successfully, but these errors were encountered: