
Security News
Feross on Risky Business Weekly Podcast: npm’s Ongoing Supply Chain Attacks
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
ts-project-loader
Advanced tools
A build tool that calls TypeScript compiler and webpack process sequentially
A TypeScript file loader for webpack, using TypeScript project (tsconfig.json). This loader provides the compiled (transpiled) JS files (from TS files) to webpack process, to bundle TypeScript files as webpack modules.
ts-project-loader compiles all TypeScript files in the project on the request only for the first TS file, not for each TS files. Because the TypeScript compilation is executed only once (per project and compiler instance), this will reduce total compilation time a little.
ts-project-loader is based on tsc2webpack
project, and is more easier-to-use because ts-project-loader is simply a webpack loader.
ts-project-loader requires typescript (version: >= 2.7) and webpack (version: 4.x; might run with 3.x but not tested fully).
npm install -D typescript webpack ts-project-loader
Before using ts-project-loader
, construct TypeScript project with tsconfig.json
. Zero configuration is supported but not recommended.
To use with webpack configuration, add ts-project-loader
as a loader for TypeScript files (*.ts / *.tsx).
...
module: {
rules: [
{
test: /\.tsx?$/,
use: [
{
loader: 'ts-project-loader'
}
]
}
]
}
From webpack command-line, specify --module-bind ts=ts-project-loader
.
You can specify following options into the fields of options
object. (All options are optional.)
use: [
{
loader: 'ts-project-loader',
options: { /* following options come here */ }
}
]
Specifies the TypeScript project file (such as tsconfig.json) or the directory path. If omitted, tsconfig.json will be searched from the directory of input TypeScript file.
declaration
option is supported. If declarationDir
is not specified, the declaration files (*.d.ts) will be emitted to the output directory of webpack.
NOTE: outDir
compiler option of tsconfig.json
is ignored. sourceMap
compiler option is overridden by webpack configuration.
Specifies the temporal output directory for emitted JS files from TypeScript compiler. If not specified, JS files will not be emitted.
Specifies the language (locale) for TypeScript compiler messages. (Currently other messages are outputted in English.)
Specifies the logger object to output logs. Following methods can be specified (all methods are optional):
logInfo(message: string, details?: any): void
logVerbose(message: string, details?: any): void
By default, internal logInfo
method is used and verbose messages are ignored.
Suppress logs from the loader. If true, the methods in logger
are not called.
Outputs the loader version on the first initialization. Ignored if silent
is true.
Specifies true
if using module resolution method from TypeScript only. By default, the loader uses enhanced-resolve
with webpack configuration for module resolution.
Additional compiler options for TypeScript files. This overrides the options in the config file.
NOTE: For the purpose of this loader, you cannot specify additional options per files; otherwise an unexpected behavior may occur.
configFile
or configFileName
is specified, and input TypeScript file does not belong to the project, the TS file will not be compiled.babel-loader
.MIT License
FAQs
A build tool that calls TypeScript compiler and webpack process sequentially
We found that ts-project-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.