Skip to content

Commit

Permalink
Adds the configuration for PnP/Typescript (#6856)
Browse files Browse the repository at this point in the history
* Adds the configuration for PnP/Typescript

* Adds the header

* Bumps ts-pnp

* Bumps fork-ts-checker-webpack-plugin
  • Loading branch information
arcanis authored and iansu committed May 1, 2019
1 parent 6710f52 commit b36d1ea
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/react-dev-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"escape-string-regexp": "1.0.5",
"filesize": "3.6.1",
"find-up": "3.0.0",
"fork-ts-checker-webpack-plugin": "1.0.1",
"fork-ts-checker-webpack-plugin": "1.1.1",
"global-modules": "2.0.0",
"globby": "8.0.2",
"gzip-size": "5.0.0",
Expand Down
43 changes: 43 additions & 0 deletions packages/react-scripts/config/pnpTs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// @remove-on-eject-begin
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// @remove-on-eject-end
'use strict';

const { resolveModuleName } = require('ts-pnp');

exports.resolveModuleName = (
typescript,
moduleName,
containingFile,
compilerOptions,
resolutionHost
) => {
return resolveModuleName(
moduleName,
containingFile,
compilerOptions,
resolutionHost,
typescript.resolveModuleName
);
};

exports.resolveTypeReferenceDirective = (
typescript,
moduleName,
containingFile,
compilerOptions,
resolutionHost
) => {
return resolveModuleName(
moduleName,
containingFile,
compilerOptions,
resolutionHost,
typescript.resolveTypeReferenceDirective
);
};
6 changes: 6 additions & 0 deletions packages/react-scripts/config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,12 @@ module.exports = function(webpackEnv) {
async: isEnvDevelopment,
useTypescriptIncrementalApi: true,
checkSyntacticErrors: true,
resolveModuleNameModule: process.versions.pnp
? `${__dirname}/pnpTs.js`
: undefined,
resolveTypeReferenceDirectiveModule: process.versions.pnp
? `${__dirname}/pnpTs.js`
: undefined,
tsconfig: paths.appTsConfig,
reportFiles: [
'**',
Expand Down
1 change: 1 addition & 0 deletions packages/react-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"semver": "6.0.0",
"style-loader": "0.23.1",
"terser-webpack-plugin": "1.2.3",
"ts-pnp": "1.1.2",
"url-loader": "1.1.2",
"webpack": "4.29.6",
"webpack-dev-server": "3.2.1",
Expand Down

0 comments on commit b36d1ea

Please sign in to comment.