https://github.com/vmlweb/ts-loader-declaration
Generates bundled Webpack Typescript declaration from exports.
https://github.com/vmlweb/ts-loader-declaration
bundler decleration merge ts-loader typescript webpack
Last synced: about 2 months ago
JSON representation
Generates bundled Webpack Typescript declaration from exports.
- Host: GitHub
- URL: https://github.com/vmlweb/ts-loader-declaration
- Owner: Vmlweb
- License: mit
- Created: 2017-03-22T17:03:36.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-12-01T08:29:29.000Z (over 8 years ago)
- Last Synced: 2024-05-13T04:20:29.624Z (about 2 years ago)
- Topics: bundler, decleration, merge, ts-loader, typescript, webpack
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/ts-loader-decleration
- Size: 26.4 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TS Loader Decleration
Generates bundled Webpack Typescript declarations from exports.
Inspired by [declaration-bundler-webpack-plugin](https://www.npmjs.com/package/declaration-bundler-webpack-plugin).
## Installation
You can grab the latest version via NPM.
```bash
npm install --save-dev ts-loader-decleration
```
## Configuration
First ensure `declaration: true` is set in your `tsconfig.json` for declaration files to be generated.
Finally include the plugin in your Webpack configuration.
```javascript
const path = require('path')
const webpack = require('webpack')
const JavaScriptObfuscator = require('webpack-obfuscator')
const nodeExternals = require('webpack-node-externals')
const { TSDeclerationsPlugin } = require('ts-loader-decleration')
module.exports = {
entry: {
main: './src/index.ts',
other: './src/other.ts'
},
target: 'node',
resolve: {
extensions: ['.ts', '.js']
},
externals: [
nodeExternals()
],
output: {
filename: './index.js',
libraryTarget: "commonjs"
},
plugins: [
new TSDeclerationsPlugin({
main: 'main'
}),
new webpack.optimize.UglifyJsPlugin(),
new JavaScriptObfuscator({
disableConsoleOutput: false
}),
],
module: {
rules: [{
test: /\.ts$/,
loader: 'ts-loader',
exclude: /(node_modules|bower_components)/
}]
}
}
```
Only modules exported from your entry file will be included in the bundled declaration.
## Awesome Typescript Loader
When using AWS there is an issue where imports will not be included in the declaration bundle unless it has been used literally. There is a loader included to patch this issue.
```javascript
{
test: /\.ts$/,
use: [{
loader: 'awesome-typescript-loader',
query: {
declaration: true,
//...
}
}, {
loader: 'ts-loader-decleration'
}]
}
```