Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/januswel/typescript-plugin-unassert
TypeScript plugin to remove assert in production mode of webpack
https://github.com/januswel/typescript-plugin-unassert
plugin typescript webpack
Last synced: 14 days ago
JSON representation
TypeScript plugin to remove assert in production mode of webpack
- Host: GitHub
- URL: https://github.com/januswel/typescript-plugin-unassert
- Owner: januswel
- Created: 2019-12-23T13:24:06.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-07T13:08:07.000Z (almost 2 years ago)
- Last Synced: 2024-09-15T01:14:51.421Z (about 2 months ago)
- Topics: plugin, typescript, webpack
- Language: TypeScript
- Size: 511 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# typescript-plugin-unassert
[![CircleCI](https://circleci.com/gh/januswel/typescript-plugin-unassert.svg?style=svg)](https://circleci.com/gh/januswel/typescript-plugin-unassert)
## Motivation
[Assertion Functions](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-7.html#assertion-functions) is available from TypeScript 3.7, but assertion functions are called and processed always, even in production codes.
This plugin eliminates all of `assert` and `assertIsDefined` calls, that are introduced at the official page.
## Getting Started
```console
npm install --save-dev typescript-plugin-unassert ts-loader
# or
yarn add --dev typescript-plugin-unassert ts-loader
```Write following lines in your `webpack.config.json`.
```js
const unassertTransformer = require('typescript-plugin-unassert')// snip
module.exports = {
// snip
module: {
rules: [
{
test: /\.tsx?$/,
loader: 'ts-loader',
options: {
getCustomTransformers: () => ({
before: [unassertTransformer],
}),
},
exclude: /node_modules/,
},
],
},
// snip
}
```Make sure to specify something except for `"CommonJS"` for the `"module"` property in `tsconfig.json` if you need tree shaking.
See [`example`](https://github.com/januswel/typescript-plugin-unassert/tree/master/example) dir which is minimum usage.