Skip to content

Commit

Permalink
Align extensions for tsconfig-paths with webpack config only if allowJs
Browse files Browse the repository at this point in the history
  • Loading branch information
novascreen committed Sep 5, 2019
1 parent a48bf1f commit 3e37e30
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,15 @@ module.exports = (
// we need to catch here because the plugin will
// error if there's no tsconfig in the working directory
try {
resolvePlugins.push(new TsconfigPathsPlugin({ silent: true, extensions: SUPPORTED_EXTENSIONS }));

const tsconfig = tsconfigPaths.loadConfig();
const fullTsconfig = JSON.parse(fs.readFileSync(tsconfig.configFileAbsolutePath).toString())

const tsconfigPathsOptions = { silent: true }
if (fullTsconfig.compilerOptions.allowJs) {
tsconfigPathsOptions.extensions = SUPPORTED_EXTENSIONS
}
resolvePlugins.push(new TsconfigPathsPlugin(tsconfigPathsOptions));

if (tsconfig.resultType === "success") {
tsconfigMatchPath = tsconfigPaths.createMatchPath(tsconfig.absoluteBaseUrl, tsconfig.paths);
}
Expand Down

0 comments on commit 3e37e30

Please sign in to comment.