Awesome TS loader for webpack
npx @tessl/cli install tessl/npm-awesome-typescript-loader@5.2.0awesome-typescript-loader is a high-performance TypeScript webpack loader that enables compilation of TypeScript files in webpack-based projects. It offers advanced features including first-class Babel integration with caching capabilities, forked type-checking and compilation for faster development cycles, and support for complex TypeScript configurations including path mapping and custom transformers.
npm install awesome-typescript-loader --save-dev// Main loader - used in webpack configuration
const loader = require('awesome-typescript-loader');For additional plugins:
const { CheckerPlugin, TsConfigPathsPlugin } = require('awesome-typescript-loader');Basic webpack configuration:
const { CheckerPlugin } = require('awesome-typescript-loader');
module.exports = {
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx']
},
module: {
rules: [{
test: /\.tsx?$/,
loader: 'awesome-typescript-loader'
}]
},
plugins: [
new CheckerPlugin()
]
};With configuration options:
module.exports = {
module: {
rules: [{
test: /\.tsx?$/,
loader: 'awesome-typescript-loader',
options: {
useCache: true,
useBabel: true,
transpileOnly: false,
configFileName: 'tsconfig.json'
}
}]
}
};awesome-typescript-loader is built around several key components:
Core webpack loader functionality for compiling TypeScript files to JavaScript with full webpack integration.
/**
* Main TypeScript loader function for webpack
* Handles compilation of .ts/.tsx files to JavaScript
*/
function loader(text: string): void;
namespace loader {
export const TsConfigPathsPlugin: typeof PathPlugin;
export const CheckerPlugin: typeof CheckerPluginClass;
}Comprehensive configuration system for customizing TypeScript compilation, Babel integration, caching, and performance optimization.
interface LoaderConfig {
instance?: string;
compiler?: string;
configFileName?: string;
configFileContent?: string;
transpileOnly?: boolean;
useCache?: boolean;
useBabel?: boolean;
forceIsolatedModules?: boolean;
errorsAsWarnings?: boolean;
silent?: boolean;
// ... additional options
}Essential webpack plugins for enhanced functionality including async error reporting and TypeScript path mapping support.
class CheckerPlugin {
apply(compiler: any): void;
}
class TsConfigPathsPlugin {
constructor(config?: LoaderConfig & ts.CompilerOptions & PathPluginOptions);
apply(resolver: Resolver): void;
}interface LoaderConfig {
instance?: string;
compiler?: string;
configFileName?: string;
configFileContent?: string;
forceIsolatedModules?: boolean;
errorsAsWarnings?: boolean;
transpileOnly?: boolean;
ignoreDiagnostics?: number[];
compilerOptions?: ts.CompilerOptions;
useTranspileModule?: boolean;
useBabel?: boolean;
babelCore?: string;
babelOptions?: any;
usePrecompiledFiles?: boolean;
silent?: boolean;
useCache?: boolean;
cacheDirectory?: string;
entryFileIsJs?: boolean;
debug?: boolean;
reportFiles?: string[];
context?: string;
getCustomTransformers?: string | ((program: ts.Program) => ts.CustomTransformers | undefined);
}
interface PathPluginOptions {
context?: string;
}