Gathering detailed insights and metrics for resolve-typescript-plugin
Gathering detailed insights and metrics for resolve-typescript-plugin
Gathering detailed insights and metrics for resolve-typescript-plugin
Gathering detailed insights and metrics for resolve-typescript-plugin
rollup-plugin-typescript-paths
Rollup plugin to automatically resolve TypeScript path aliases.
typescript-resolve-plugin
[![NPM Version][npm-image]][npm-url]
@types/rollup-plugin-node-resolve
Stub TypeScript definitions entry for rollup-plugin-node-resolve, which provides its own types definitions
rollup-plugin-typescript-resolve
Rollup Plugin to resolve imports using TypeScript resolution algorithm
webpack plugin to resolve TypeScript files when importing with js file extension in ESM projects
npm install resolve-typescript-plugin
Typescript
Module System
Min. Node Version
Node Version
NPM Version
TypeScript (54.6%)
JavaScript (45.4%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
ISC License
48 Stars
573 Commits
2 Forks
2 Watchers
12 Branches
3 Contributors
Updated on Apr 13, 2025
Latest Version
2.0.1
Package Id
resolve-typescript-plugin@2.0.1
Unpacked Size
14.10 kB
Size
5.06 kB
File Count
6
NPM Version
8.19.3
Node Version
19.7.0
Published on
Mar 13, 2023
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
1
21
A webpack plugin to resolve TypeScript files imported using the .js
extension
when using ESM imports.
webpack has equivalent functionality built-in since v5.74.0. This plugin is no longer needed unless you are using an older version of webpack.
To migrate from this plugin, set resolve.extensionAlias
in
webpack.config.js
:
1export default { 2 resolve: { 3 extensionAlias: { 4 ".js": [".ts", ".js"], 5 ".mjs": [".mts", ".mjs"] 6 } 7 } 8};
and remove new ResolveTypeScriptPlugin()
from resolve.plugins
.
If you are using webpack in conjunction with TypeScript and ES Modules, you need this plugin for full compliance with the ES Modules ecosystem.
ES Modules require imports to specify the runtime path of the file to be
imported, including file extension. For TypeScript files, this means that you
must import using the extension .js
even though the source file uses the
extension .ts
or .tsx
. This is because TypeScript compiles to a .js
file
that will be used at runtime.
However, webpack behaves differently, even when configured for ES Modules.
webpack expects that files will be imported by specifying the compile-time path
of the file, including the compile-time extension. For TypeScript files this
will be .ts
or .tsx
. Alternatively, webpack expects that files will be
imported with no extension, in which case webpack will resolve the extension
automatically according to the resolve.extensions
option. Neither of
these behaviours is consistent with browser or node ES Module environments.
This plugin extends webpack module resolution so that imports specifying a .js
extension will resolve to the corresponding .ts
or .tsx
file if available,
and fall back to .js
otherwise.
If you want to create ES Modules in TypeScript that are consistent between webpack, browser, and node environments, use this plugin.
See ts-loader#1110 for more background on this issue.
With npm:
1npm install --save-dev resolve-typescript-plugin
or yarn:
1yarn add --dev resolve-typescript-plugin
Include the following in package.json
to configure your project to be an ES
Module:
1{ 2 "type": "module" 3}
Include something like the following in webpack.config.js
:
1import ResolveTypeScriptPlugin from "resolve-typescript-plugin"; 2 3export default { 4 module: { 5 rules: [ 6 { 7 test: /\.tsx?$/, 8 use: "ts-loader" 9 } 10 ] 11 }, 12 resolve: { 13 plugins: [new ResolveTypeScriptPlugin()] 14 } 15};
You will also need to have ts-loader (or another TypeScript loader) installed and configured.
Previous versions of this README recommended setting resolve.fullySpecified
to
true
. This is no longer recommended because it breaks compatibility with
webpack-dev-server and possibly other webpack tooling.
If you use this plugin, you should probably remove .ts
and .tsx
from
resolve.extensions
.
Pass options to the plugin as an argument to the constructor, as follows:
1new ResolveTypeScriptPlugin({
2 includeNodeModules: false
3});
By default, the plugin does not resolve TypeScript files inside node_modules
subdirectories. To enable this, set includeNodeModules: true
.
Default: false
.
This plugin supports webpack versions 4.x and 5.x. However, there are some caveats when using webpack 4.x in conjunction with ES modules.
Webpack 4.x does not support webpack.config
files in ES module format, so if
you set "type": "module"
in package.json
then you must mark the
webpack.config
file as a CommonJS file by naming it webpack.config.cjs
(with
a .cjs
extension). Of course, you must also use CommonJS format, for example:
1const ResolveTypeScriptPlugin = require("resolve-typescript-plugin"); 2 3module.exports = { 4 module: { 5 rules: [ 6 { 7 test: /\.tsx?$/, 8 use: "ts-loader" 9 } 10 ] 11 }, 12 resolve: { 13 plugins: [new ResolveTypeScriptPlugin()] 14 } 15};
Webpack 4.x also will not discover the webpack.config
file automatically if it
is named with a .cjs
extension, so you must specify the path to the
configuration file explicitly when running webpack, for example:
webpack --config ./webpack.config.cjs
.
Webpack 5.x has none of these caveats. In Webpack 5.x, configuration files may
be in ES Module or CommonJS format, and will be discovered automatically if they
are named with any of .js
, .cjs
, or .mjs
file extensions.
We're seeking community feedback on this plugin.
Please report bugs, problems, and missing features on the GitHub Issue Tracker.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 3
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/28 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
30 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More