Never Play Metal

    @ts-tools/webpack-loader
    TypeScript icon, indicating that this package has built-in type declarations

    4.0.0 • Public • Published

    @ts-tools/webpack-loader

    npm version

    TypeScript loader for webpack.

    Features:

    • Fast! Uses ts.transpileModule. Leaves type checking to other flows.
    • Uses persistent disk caching (node_modules/.cache/ts-<moodule>-<target>). Second run will not re-transpile a file if not changed.
    • Loads configuration from the closest tsconfig.json.
    • Automated source map configuration based on current devtool configuration.

    Getting started

    Install the library as a dev dependency in an existing TypeScript project:

    npm i @ts-tools/webpack-loader --save-dev
    

    And adjust your webpack configuration to include:

    module.exports = {
      // ...
      module: {
        rules: [
          {
            test: /\.tsx?$/,
            loader: '@ts-tools/webpack-loader',
          },
        ],
      },
      resolve: {
        extensions: ['.ts', '.tsx', '.mjs', '.js', '.json'],
      },
      // ...
    };

    Options

    interface ITypeScriptLoaderOptions {
      /**
       * Keys to override in the `compilerOptions` section of the
       * `tsconfig.json` file.
       */
      compilerOptions?: object;
    
      /**
       * Turn persistent caching on/off.
       *
       *  @default true
       */
      cache?: boolean;
    
      /**
       * Absolute path of an existing directory to use for persistent cache.
       *
       * @default uses `find-cache-dir` to search for caching path.
       */
      cacheDirectoryPath?: string;
    
      /**
       * Path to `tsconfig.json` file.
       * Specifying it will skip config lookup
       */
      configFilePath?: string;
    
      /**
       * Name of config file to search for when looking up config.
       *
       * @default 'tsconfig.json'
       */
      configFileName?: string;
    
      /**
       * Should loader search for config.
       * Loader will search for the closest tsconfig file to the root context, and load it.
       *
       * @default true
       */
      configLookup?: boolean;
    }

    Options can be provided via the webpack configuration:

    module.exports = {
      // ...
      module: {
        rules: [
          {
            test: /\.tsx?$/,
            loader: '@ts-tools/webpack-loader',
            options: {
              compilerOptions: {
                target: 'es5',
              },
            },
          },
        ],
      },
      // ...
    };

    Similar projects

    License

    MIT

    Keywords

    none

    Install

    npm i @ts-tools/webpack-loader

    DownloadsWeekly Downloads

    3,371

    Version

    4.0.0

    License

    MIT

    Unpacked Size

    23.5 kB

    Total Files

    13

    Last publish

    Collaborators

    • avi.vahl