-
Notifications
You must be signed in to change notification settings - Fork 71
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
Typings directory when in-lining project references #454
Typings directory when in-lining project references #454
Comments
This comment was marked as resolved.
This comment was marked as resolved.
Oh there are indeed some complications in your case. I see you have configured TS Unfortunately, aliases are not truly supported by TS. #201 has pretty significant details and several workarounds to support aliases. IIRC, there are some related issues on monorepos specifically that I might be able to pull up as well (#237 is one) Using one of those workarounds can probably fix your issue. Also not sure if |
This comment was marked as resolved.
This comment was marked as resolved.
Thanks for this workarounds: But in my opinion my example highlight another kind of problem. I try to process resulting declarations, but it's hard, because located in strange directories (also located strange dir when i set declarationDir, but also copied into declaration dir with I guess it's not reliable behaviour (i may be wrong). I am trying to find a consistent solution to avoid problems in the future. In my example with rollup, shared workspace sources are inlined into the resulting sdk perfectly. But types have some problems, because previously when i have used |
@agilgur5 could you help me with one more advice for avoiding excess .d.ts files generation in <workspace_dir_name/src/**/*.d.ts dirs? Workarounds from previous message related to other issues or not working in this case i guess |
This comment was marked as resolved.
This comment was marked as resolved.
goal? in-lining?
Ah ok, so you are trying to in-line the JS without in-lining the types? Or in-line both? In your repro example, you might notice that // create.js
import { test } from "@shared/test/util";
export function create(user) {
console.log(`user = ${user}`);
test(() => { });
}
With Rollup, you can mark root cause analysis
EDIT: It actually was due to the
|
OH. I got it to work.
It seems like it may indeed be "paths": {
"@shared/*": [
- "../../shared/src/*"
+ "../../shared/build/*"
]
} and then it worked with no other changes needed 😮 adding EDIT: sent a PR with fixes: lavcraft/rollup-typescript-project-references-example-problems#1 |
@agilgur5 yes, main purpose is inlining both - js and .d.ts. But secondary - simply build and make it more reliable (across versions and updates). That mean, i wan't to use ts project reference for use rollup I believe - separate code into sub projects — provide more understandable project structure without limits |
In my opinion, current behaviour in my example contain only one thing, that should be fixed for purposes. And how it can be achieved in manual way:
|
This problem looks like rpt2 plugin doesn't add sources from referenced projects into rootDirs set, however compile and build related files |
So I responded in lavcraft/rollup-typescript-project-references-example-problems#1 (comment), but this was working fine for me.
Not sure what you meant by this, but Rollup can't really process project references the same way
So in this case, the current behavior is correct. The common
I'm not sure what you mean by this. As far as I know, TS itself does not add project references into
Sorry, what is the "one" problem that remains? It seems like everything is working as intended in your list |
It works only if shared project builded. In this way, i need to run independent process for building shared project, and then — rebuild sdk project when build/*js was changed. I want to simplify project build with ts project reference, but this thing with src -> build in paths nullifies efforts
Sure. It's main goal — avoid complex build with multiple process, and replace it with project references. I use comparison with tsc only for d.ts generating, because:
Sorry, i mean problem with types :) And if i try to fix it with your workaround, unfortunately, nullifies profit from typescript project reference and need to run two rollup process for each project and manage it manually (because in paths i must reference into build dir instead of src) |
Try to a new way: I can adopt to new types structure with next package.json types: "typesVersions": {
"*": {
"*": [
"build/sdk/src/*",
"build/shared/src/*",
"build/sdk/src/*/index.d.ts",
"build/shared/src/*/index.d.ts"
]
}
} @agilgur5 could you advice, how process types in Found this solution — #201 (comment)
|
Troubleshooting
My reproducible example - https://github.com/lavcraft/rollup-typescript-project-references-example-problems
You need
Follow to next instructions
tsc
have the same output? If so, please explain why this is incorrect behaviorRun
npm run -w @project/sdk build
- tsc variant works fine and generate d.ts files into correct directoriesI guess order is correct:
My example - https://github.com/lavcraft/rollup-typescript-project-references-example-problems
Follow to README or read next lines:
Two commands for feel difference between tsc and rollup in my case:
TSC baseline
npm run -w @project/sdk build
- tsc variantAll d.ts files existed in right location (except d.ts from project from project reference, but it is ok for tsc i guess)
Rollup variant
rm -rf packages/sdk/build && npm run -w @project/sdk rollup
Created to excess directories with typings - sdk and shared
Please help me to explain right behaviour or workaround. Because my next step is apply dts plugin for obtain valid d.ts files without internal paths. But some difficulties happened when all this d.ts located in strange directories :)
Environment
Versions
:rollup.config.js
The text was updated successfully, but these errors were encountered: