-
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
Is it possible to make this plugin transpile files from outside the root of the package (f. ex. in a monorepo setup)? #216
Comments
Out of the box you could do something with separate rollup configs for each package and separate tsconfigs for each, that include only that package. You can still have most of ts configuration shared using base tsconfg. So instead of doing If it works and you nail down details, let me know I'll add a section to readme (or make a PR). Working example test repo would be ideal as a reference. |
Location of the leaf tsconfig is root of all relative paths for typescript (including for default include/exclude patterns). The plugin feeds tsconfig to typescript and gets list of files that typescript found and only processes them if rollup feeds them in (also affected by plugin's own include/exclude patterns). I guess I misunderstood what you want to do. Looks like you are including files from other packages directly. That effectively turns them from isolated packages into subfolders of the same package. I see two ways to structure it cleanly:
If first case you need separate tsconfigs. So when building, typescript and rollup only see source for the package being built. When another package is needed, it is built and build result is imported. In second case you need common tsconfig that sees all source files, and can use root rollup config with multiple bundles defined. In this case build artifacts are never used internally. Looks like you are going for the second case. I can't run your test repo ( To debug, set plugin verbosity to 3 and check if typescript finds all files you are expecting. If |
Thanks. Sorry, I updated the readme. After you |
Below is the full output with verbosity:3, when I try to bundle with rollup based on the single root tsconfig. Note that
<
log:
|
@ezolenko regarding the why of doing this
|
Do you get exactly the same error when using single tsconfig? I don't see error in your verbose output. For your reasons, the problem you might have is CI and release builds will be different from your dev builds. For example in case a package doesn't export something internal, but you imported and used it directly. Using different dependency chains for dev and production builds is a bad idea in general. Pure typescript (without rollup) can deal with it by building subprojects on demand. Doing the same with rollup based subprojects will involve some plumbing I expect... |
This works with the current version of rpt2!So I was investigating #295, which roughly duplicates this issue, and it turns out this is already possible with a newer version of rpt2 (the original issue uses 0.26.0). root cause is actually due to upstream
|
Here is a repo created just to show this issue
In a monorepo, where a root repository has a directory called packages with two npm packages in it, if each of the packages has a rollup config (that uses rollup-plugin-typescript2) and they both refer to a tsconfig at the root that defines paths so that the packages can import each other using absolute paths, how is it possible to build one of the packages without building the other (assuming the first one you build depends on the other?
Here is a SO question for this. I am posting it here as well because I think that as monorepos become more prevalent, this will become something important to add to either the capability of this plugin or its documentation.
The text was updated successfully, but these errors were encountered: