TypeStrong / dts-bundle

Export TypeScript .d.ts files as an external module definition
MIT License
308 stars 57 forks source link

Duplicated imports after bundle into single .d.ts file #60

Open nxddsnc opened 6 years ago

nxddsnc commented 6 years ago

I successfully bundle multiple .d.ts files into a single file. But in the bundle.d.ts file, there are duplicated imports. In Angular4, using the bundled .d.ts file seems to be ok. But Angular5, webpack shows a duplicated identifier error. Here's my dts-bundle options: { name: 'babylon-juyee-engine', main:rootDir + '/dist/index.d.ts', out: rootDir + '/babylon-juyee-engine.d.ts', removeSource: true, outputAsModuleFolder: true } And here's part of the .d.ts file with duplicated imports: import { BoundingBoxRenderer, Matrix, Scene, Engine, RenderTargetTexture, Vector3, Nullable } from 'babylonjs'; import { TargetCamera, Camera, Vector3, Vector2, AbstractMesh, Scene, Matrix, Collider } from "babylonjs"; import { Engine, Mesh, Scene, Vector3, Matrix, Node, SubMesh, _InstancesBatch, Material, Effect, Geometry, AbstractMesh, BoundingInfo, Ray, PickingInfo } from 'babylonjs'; import { Mesh, Scene, Vector3, Matrix, Node, Geometry, BoundingInfo, Ray, PickingInfo } from 'babylonjs'; There are several Vector3 and Scene imported. Is there any compile option can help me avoid duplicated imports?

chiefmc commented 6 years ago

Ran into same issue while working on a UMD module.

After concatenating .d.ts files, resulting file has a repeating declarations like: import ViewOptions = Backbone.ViewOptions;

These duplications needs to be dropped for the declaration to be valid

Borewit commented 6 years ago

Same issue.

In my case it was caused the normalization of the absolute full path of the same module ended up as:

  1. C:\Users\Borewit\code\github\music-metadata-browser\node_modules\music-metadata\lib\index.d.ts
  2. C:\Users\Borewit\code\github\music-metadata-browser\node_modules\music-metadata\lib
Borewit commented 6 years ago

It looks like one of my imports ./ instead of ./index maybe the source of the problem.