John Weisz
John Weisz

Reputation: 31934

Create concatenated .d.ts with webpack

I'd wish to build my TypeScript project (in Visual Studio) with the following automated steps:

  1. compile each .ts file as an AMD module, separately
  2. bundle each created .js file with webpack, into release/my-app.js

As part of step 1, .d.ts files are also created for each .ts file (in addition to the output Javascript files). How may I bundle these definition files together as well, so that they provide type definitions for what gets bundled into the my-app.js output file?


project layout

MyApp
|-- lib
|   |-- foo.ts
|   |-- foo.js
|   |-- foo.d.ts
|   `-- ...
|-- release
|   `-- my-app.js
|-- main.ts
|-- main.js
|-- main.d.ts
`-- webpack.config.js

webpack.config.js

module.exports = {
    context: __dirname,
    entry: './main.js',
    output: {
        path: path.join(__dirname, 'release'),
        filename: 'my-app.js'
    }
}

Upvotes: 5

Views: 1041

Answers (1)

Stef Heyenrath
Stef Heyenrath

Reputation: 9830

You could try https://www.npmjs.com/package/dts-bundle, but this is experimental and it does not work well with awesome-typescript-loader.

Upvotes: 2

Related Questions