# ts-loader-decleration

> Enables bundled Webpack Typescript declarations from exports.

Latest version **0.10.4** (published 2017-11-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install ts-loader-decleration
pnpm add ts-loader-decleration
yarn add ts-loader-decleration
bun add ts-loader-decleration
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.10.4 |
| Published | 2017-11-30 |
| First published | 2017-03-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Vmlweb |
| Maintainers | victor96 |
| Keywords | ts, loader, webpack, plugin, decleration, typescript, export, single, bundle |

## Links

- npm: https://www.npmjs.com/package/ts-loader-decleration
- Repository: https://github.com/Vmlweb/TS-Loader-Decleration
- Homepage: https://github.com/Vmlweb/TS-Loader-Decleration#readme
- Issues: https://github.com/Vmlweb/TS-Loader-Decleration/issues
- npm.io page: https://npm.io/package/ts-loader-decleration

## Dependencies (4)

- [esprima](https://npm.io/package/esprima.md) ^3.1.3
- [dts-bundle](https://npm.io/package/dts-bundle.md) ^0.7.2
- [proxyquire](https://npm.io/package/proxyquire.md) ^1.8.0
- [js-beautify](https://npm.io/package/js-beautify.md) ^1.6.12

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 0.10.4 (latest) — 2017-11-30
- 0.10.3 — 2017-11-21
- 0.10.2 — 2017-11-20
- 0.10.1 — 2017-11-20
- 0.10.0 — 2017-11-10
- 0.9.13 — 2017-11-06
- 0.9.12 — 2017-11-06
- 0.9.11 — 2017-11-06
- 0.9.10 — 2017-11-06
- 0.9.9 — 2017-10-19
- 0.9.8 — 2017-10-19
- 0.9.7 — 2017-10-19
- 0.9.5 — 2017-09-15
- 0.9.4 — 2017-07-03
- 0.9.3 — 2017-06-08
- … 29 more at https://npm.io/package/ts-loader-decleration/versions

## 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: './src/index.d.ts'
		}),
		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'
	}]
}
```

---
_Source: https://npm.io/package/ts-loader-decleration · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
