Skip to content
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

Inlined imports do not contain import statement from dependencies #199

Closed
nsamsonov opened this issue Apr 26, 2022 · 6 comments · Fixed by #200
Closed

Inlined imports do not contain import statement from dependencies #199

nsamsonov opened this issue Apr 26, 2022 · 6 comments · Fixed by #200
Assignees
Labels
Milestone

Comments

@nsamsonov
Copy link

nsamsonov commented Apr 26, 2022

Bug report
I have my file and two libraries (libA and libB). libA imports some stuff from libB. I want libA to be inlined, while keeping import statements from libB.

Input code

myFile.ts

import { InlinedType } from "libA";

export interface MyType {
    prop: InlinedType;
}

node_modules/libA/index.d.ts

import { ImportedType } from 'libB';

export interface InlinedType {
    prop: ImportedType;
}

node_modules/libB/index.d.ts

export interface ImportedType {
    prop: number;
}

Expected output

import { ImportedType } from 'libB';

export interface InlinedType {
    prop: ImportedType;
}

export interface MyType {
    prop: InlinedType;
}

Actual output

export interface InlinedType {
    prop: ImportedType;
}

export interface MyType {
    prop: InlinedType;
}

Additional context
The import is generated using dts-bundle-generator --external-inlines=libA myFile.ts
Since the import statement is missing, the generated code is invalid. Adding --external-inlines=libB correctly inlines libB, but this is undesired behavior. Adding --external-imports=libB has no effect.

@nsamsonov
Copy link
Author

It appears this is happening because of these lines:

if (symbolsDeclarations.length === 0 || symbolsDeclarations.every(isDeclarationFromExternalModule)) {
return false;
}

Even though the declaration will eventually be inlined, it's still considered a part of the external lib

@timocov
Copy link
Owner

timocov commented Apr 26, 2022

@nsamsonov have you tried a previous versions? I guess it could be broken in one of the recent versions...

@timocov timocov added the Bug label Apr 26, 2022
@nsamsonov
Copy link
Author

the earliest I tried was 5.0.0 and it still didn't work

@timocov
Copy link
Owner

timocov commented Apr 26, 2022

@nsamsonov got it, thanks! I'll try to fix soon.

@timocov timocov self-assigned this Apr 26, 2022
@timocov timocov added this to the 6.9 milestone Apr 26, 2022
timocov added a commit that referenced this issue Apr 26, 2022
@timocov
Copy link
Owner

timocov commented Apr 26, 2022

@nsamsonov
Copy link
Author

thanks a lot, it works great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants