npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@titanium-sdk/webpack-plugin-typescript

v0.1.0

Published

TypeScript Plugin for Appcd Webpack

Downloads

4

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:

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 section for details.

This plugin can be used alongside @titanium-sdk/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.

💡 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.

{
  "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 a slight adjustment to the tsconfig.json is neccessary:

{
  "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.

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.

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)