You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, apologies if you're getting tired of this repeated topic.
We're trying to get this tool to work in a monorepo. We have two packages, A and B. A is a server, B is a client for it. A will never be published as a package (it wouldn't make sense, it's a server). B is to be published internally as a package. B uses types imported from A. Our goal is to use dts-bundle-generator as part of publishing B, the entry point of the bundling being B/src/index.ts.
Normally we'd import the types simply using an import such as import type { X } from "A/src/One.js", which is also the way e.g. vscode auto-imports X. When we tried running dts-bundle-generator, depending on the truthiness of followSymlinks, we either saw that
(followSymlinks: false): While the initial import was seemingly followed correctly (into One.ts), it would fail when following the imports inside that file. If One.ts from package A has import { f } from './models.js', this results in the error ../A/src/One.ts(2,31): error TS2307: Cannot find module './models.js' or its corresponding type declarations.
(followSymlinks: true): It would fail to resolve the things imported by A from external packages. E.g. if A/src/One.ts has import { Kysely } from 'kysely', it would give an error such as ../A/src/One.ts(52,31): error TS2339: Property 'init' does not exist on type 'Kysely' even though it does exist, and tsc/language server compile without errors).
Maybe we were just doing something wrong here? Not sure.
Possible questions:
Why don't you just compile your server package?
The server part will never be published as a package anywhere, it's a server for internal use, so there's no point.
It means that to reflect any updated types in the client when developing, we need to recompile the server, which adds another step to remember and added complexity
Despite the above, we gave compiling A a try. Unfortunately, this did not make it work out of the box, though it did provide a workaround. It appears that to make dts-bundle-generator work, we have to manually change the import path in our files, like so: import type { X } from "A/src/One.js --> import type { X } from "A/dist/One.d.ts.
This does make things work, but isn't great - we now both 1. Have to introduce a compilation step for A and 2. Can no longer auto-import, having to manually rewrite them to A/dist/.../__.d.ts.
We'd like to know if this is the expected behavior or caused by us doing something wrong, and whether there is any better workaround.
Thank you for making this tool!
The text was updated successfully, but these errors were encountered:
Hi, apologies if you're getting tired of this repeated topic.
We're trying to get this tool to work in a monorepo. We have two packages, A and B. A is a server, B is a client for it. A will never be published as a package (it wouldn't make sense, it's a server). B is to be published internally as a package. B uses types imported from A. Our goal is to use
dts-bundle-generator
as part of publishing B, the entry point of the bundling beingB/src/index.ts
.Normally we'd import the types simply using an import such as
import type { X } from "A/src/One.js"
, which is also the way e.g. vscode auto-imports X. When we tried running dts-bundle-generator, depending on the truthiness offollowSymlinks
, we either saw thatfollowSymlinks: false
): While the initial import was seemingly followed correctly (intoOne.ts
), it would fail when following the imports inside that file. IfOne.ts
from package A hasimport { f } from './models.js'
, this results in the error../A/src/One.ts(2,31): error TS2307: Cannot find module './models.js' or its corresponding type declarations.
followSymlinks: true
): It would fail to resolve the things imported by A from external packages. E.g. ifA/src/One.ts
hasimport { Kysely } from 'kysely'
, it would give an error such as../A/src/One.ts(52,31): error TS2339: Property 'init' does not exist on type 'Kysely'
even though it does exist, and tsc/language server compile without errors).Maybe we were just doing something wrong here? Not sure.
Possible questions:
Despite the above, we gave compiling A a try. Unfortunately, this did not make it work out of the box, though it did provide a workaround. It appears that to make
dts-bundle-generator
work, we have to manually change the import path in our files, like so:import type { X } from "A/src/One.js
-->import type { X } from "A/dist/One.d.ts
.This does make things work, but isn't great - we now both 1. Have to introduce a compilation step for A and 2. Can no longer auto-import, having to manually rewrite them to
A/dist/.../__.d.ts
.We'd like to know if this is the expected behavior or caused by us doing something wrong, and whether there is any better workaround.
Thank you for making this tool!
The text was updated successfully, but these errors were encountered: