# @titanium-sdk/webpack-plugin-typescript

> TypeScript Plugin for Appcd Webpack

Latest version **0.1.0** (published 2020-08-20) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @titanium-sdk/webpack-plugin-typescript
pnpm add @titanium-sdk/webpack-plugin-typescript
yarn add @titanium-sdk/webpack-plugin-typescript
bun add @titanium-sdk/webpack-plugin-typescript
```

## 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.1.0 |
| Published | 2020-08-20 |
| First published | 2020-08-20 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=10.0.0 |
| Dependencies | 3 |
| Unpacked size | 18.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Axway Appcelerator |
| Maintainers | janvennemann, appcelerator, awam, cb1kenobi, titanium-sdk-admin |
| Keywords | titanium, webpack, typescript, appcd |

## Links

- npm: https://www.npmjs.com/package/@titanium-sdk/webpack-plugin-typescript
- Repository: https://github.com/appcelerator/webpack-plugin-typescript
- Homepage: https://github.com/appcelerator/webpack-plugin-typescript#readme
- Issues: https://github.com/appcelerator/webpack-plugin-typescript/issues
- npm.io page: https://npm.io/package/@titanium-sdk/webpack-plugin-typescript

## Dependencies (3)

- [ts-loader](https://npm.io/package/ts-loader.md) ^8.0.2
- [cache-loader](https://npm.io/package/cache-loader.md) ^4.1.0
- [fork-ts-checker-webpack-plugin](https://npm.io/package/fork-ts-checker-webpack-plugin.md) ^5.1.0

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.1.0 (latest) — 2020-08-20

## README

# @titanium-sdk/webpack-plugin-typescript

> TypeScript plugin for Appcd Webpack

## Installation

To install this plugin in an existing project, run the following command in your project root:

```sh
npm i -D @titanium-sdk/webpack-plugin-typescript typescript @types/titanium
```

Since `typescript` is a peer dependency of this package, you can use the version of TypeScript that you need. All versions >=2.0 are supported.

You can opt-in to use ESLint in addition to TypeScript's type checking. See the [ESLint](#eslint) section for details.

This plugin can be used alongside [`@titanium-sdk/webpack-plugin-babel`](https://github.com/appcelerator/webpack-plugin-babel). When used with Babel, make sure to let TypeScript output ES2015 code so Babel can handle transpiling.

## Configuration

After installing the plugin, TypeScript can be configured via `tsconfig.json`. For best performance, all type checking is done in a seperate process with [`fork-ts-checker-webpack-plugin`](https://github.com/TypeStrong/fork-ts-checker-webpack-plugin).

> 💡 **NOTE:** Since all linting is done in a seperate process it will not fail the Webpack build when it detects errors.

### TypeScript

Create a `tsconfig.json` in the project root directory to configure TypeScript. See the following example configuration for recommended values when using TypeScript with Titanium.

> 💡 **NOTE:** When used with `@titanium-sdk/webpack-plugin-babel`, change the `target` to `es2015` so Babel can take care of transpiling your code.

```json
{
  "compilerOptions": {
    "target": "ES5",
    "module": "ESNext",
    "strict": true,
    "importHelpers": true,
    "allowJs": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "sourceMap": true,
    "baseUrl": ".",
    "types": [
      "titanium"
    ],
    "paths": {
      "@/*": [
        "src/*"
      ]
    },
    "lib": [
      "esnext"
    ]
  },
  "include": [
    "src/**/*.ts"
  ],
  "exclude": [
    "node_modules"
  ]
}
```

When used with [@titanium-sdk/webpack-plugin-alloy](https://github.com/appcelerator/webpack-plugin-alloy) a slight adjustment to the `tsconfig.json` is neccessary:

```json
{
  "compilerOptions": {
    "paths": {
      "@/*": [
        "app/*"
      ]
    },
    "lib": [
      "esnext",
      "dom"
    ]
  },
  "include": [
    "app/**/*.ts"
  ]
}
```

### ESLint

To opt-in to use ESLint for additional linting, simply install `eslint` and the relevant TypeScript parser and plugin.

```sh
npm i -D eslint @typescript-eslint/parser @typescript-eslint/eslint-plugin
```

Configuration of ESLint can be done as usual with a `.eslintrc.js` in the project root. Here is an example to get you started.

```js
const path = require('path');

module.exports = {
  parser: '@typescript-eslint/parser', // Specifies the ESLint parser
  extends: [
    'plugin:@typescript-eslint/recommended' // Uses the recommended rules from the @typescript-eslint/eslint-plugin
  ],
  parserOptions: {
    project: path.resolve(__dirname, './tsconfig.json'),
    tsconfigRootDir: __dirname,
    ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
    sourceType: 'module', // Allows for the use of imports
  },
  rules: {
    // Place to specify ESLint rules. Can be used to overwrite rules specified from the extended configs
    // e.g. "@typescript-eslint/explicit-function-return-type": "off",
  }
};
```

## Webpack configuration

This plugin will add/modify the following Webpack options:

### Rules

- `rule('ts')`
- `rule('ts').use('cache-loader')`
- `rule('ts').use('babel-loader')` (when used alongside `@titanium-sdk/webpack-plugin-babel`)
- `rule('ts').use('ts-loader')`

### Plugins

- `plugin('fork-ts-checker')` (when `eslint` and the TypeScript parser and plugin are installed the `eslint` option will automatically be configured)

---
_Source: https://npm.io/package/@titanium-sdk/webpack-plugin-typescript · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
