Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
tsconfig-paths-webpack-plugin
Advanced tools
The tsconfig-paths-webpack-plugin is a plugin for webpack that allows you to leverage the paths defined in your tsconfig.json file. This means you can alias paths in your TypeScript code and have those aliases correctly resolved by webpack when bundling your application. It simplifies the module resolution process when using TypeScript with webpack.
Path Resolution
This feature allows webpack to resolve paths based on the aliases defined in the tsconfig.json file. The code sample shows how to include the TsconfigPathsPlugin in your webpack configuration.
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
module.exports = {
// ... other webpack config settings ...
resolve: {
plugins: [
new TsconfigPathsPlugin({ configFile: './path/to/tsconfig.json' })
]
}
};
This Babel plugin allows you to add new 'root' directories that contain your modules. It also allows you to map a path to another and to safely ignore certain modules during the Babel process. It's similar to tsconfig-paths-webpack-plugin but is used in the context of Babel rather than webpack.
This is the library that webpack uses under the hood for resolving modules. It can be used directly in Node.js projects to resolve files or directories using webpack's resolution algorithm. It's more low-level compared to tsconfig-paths-webpack-plugin and doesn't directly use the tsconfig.json file.
Aliasify is a transform for Browserify that lets you rewrite module calls in your browserify project. This can be used to alias module paths similar to what tsconfig-paths-webpack-plugin does for webpack, but it's specific to Browserify.
Use this to load modules whose location is specified in the paths
section of
tsconfig.json
when using webpack.
yarn add --dev tsconfig-paths-webpack-plugin
or
npm install --save-dev tsconfig-paths-webpack-plugin
In your webpack config add this:
var TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
module.exports = {
...
resolve: {
plugins: [new TsconfigPathsPlugin({ /*configFile: "./path/to/tsconfig.json" */ })]
}
...
}
Allows you to specify where to find the TypeScript configuration file.
You may provide
tsconfig-paths
package. The search will start at cwd
.cwd
.The use of
cwd
as default above is not optimal but we've found no better solution yet. If you have a suggestion please file an issue.
If true, no console.log messages will be emitted. Note that most error messages are emitted via webpack which is not affected by this flag.
Can be info
, warn
or error
which limits the log output to the specified
log level. Beware of the fact that errors are written to stderr and everything
else is written to stderr (or stdout if logInfoToStdOut is true).
If false
, disables built-in colors in logger messages.
This is important if you read from stdout or stderr and for proper error handling. The default value ensures that you can read from stdout e.g. via pipes or you use webpack -j to generate json output.
To run the provided example:
yarn example
This project uses work done in the awesome-typescript-loader.
FAQs
Load modules according to tsconfig paths in webpack.
The npm package tsconfig-paths-webpack-plugin receives a total of 4,386,343 weekly downloads. As such, tsconfig-paths-webpack-plugin popularity was classified as popular.
We found that tsconfig-paths-webpack-plugin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 14 open source maintainers 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
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.