From 9fd37e6d3abb97ab4b2a04ff140a525a51941c92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Nison?= Date: Fri, 19 Apr 2019 15:15:42 +0100 Subject: [PATCH 1/4] Adds the configuration for PnP/Typescript --- packages/react-dev-utils/package.json | 2 +- packages/react-scripts/config/pnpTs.js | 33 +++++++++++++++++++ .../react-scripts/config/webpack.config.js | 10 +++++- packages/react-scripts/package.json | 1 + 4 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 packages/react-scripts/config/pnpTs.js diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index adafd95c042..55baab54bcb 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -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.0", "global-modules": "2.0.0", "globby": "8.0.2", "gzip-size": "5.0.0", diff --git a/packages/react-scripts/config/pnpTs.js b/packages/react-scripts/config/pnpTs.js new file mode 100644 index 00000000000..ae1fc25cf0b --- /dev/null +++ b/packages/react-scripts/config/pnpTs.js @@ -0,0 +1,33 @@ +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 + ); +}; diff --git a/packages/react-scripts/config/webpack.config.js b/packages/react-scripts/config/webpack.config.js index a0ba6c6306e..8e34e17756e 100644 --- a/packages/react-scripts/config/webpack.config.js +++ b/packages/react-scripts/config/webpack.config.js @@ -269,7 +269,9 @@ module.exports = function(webpackEnv) { // We placed these paths second because we want `node_modules` to "win" // if there are any conflicts. This matches Node resolution mechanism. // https://github.com/facebook/create-react-app/issues/253 - modules: ['node_modules', paths.appNodeModules].concat(modules.additionalModulePaths || []), + modules: ['node_modules', paths.appNodeModules].concat( + modules.additionalModulePaths || [] + ), // These are the reasonable defaults supported by the Node ecosystem. // We also include JSX as a common component filename extension to support // some tools, although we do not recommend using it, see: @@ -638,6 +640,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: [ '**', diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 00e4ae8c46e..f87d22397a8 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -73,6 +73,7 @@ "semver": "6.0.0", "style-loader": "0.23.1", "terser-webpack-plugin": "1.2.3", + "ts-pnp": "1.1.1", "url-loader": "1.1.2", "webpack": "4.29.6", "webpack-dev-server": "3.2.1", From 7187048c5dd470deda8232e378af86b49a38af52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Nison?= Date: Sat, 20 Apr 2019 12:35:03 +0100 Subject: [PATCH 2/4] Adds the header --- packages/react-scripts/config/pnpTs.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/react-scripts/config/pnpTs.js b/packages/react-scripts/config/pnpTs.js index ae1fc25cf0b..ed810df6307 100644 --- a/packages/react-scripts/config/pnpTs.js +++ b/packages/react-scripts/config/pnpTs.js @@ -1,3 +1,13 @@ +// @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 = ( From 218ff475055d509e4c6078ae4ef08b3b7ec0d8e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Nison?= Date: Sun, 21 Apr 2019 18:38:19 +0100 Subject: [PATCH 3/4] Bumps ts-pnp --- packages/react-scripts/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index f87d22397a8..dd658401a08 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -73,7 +73,7 @@ "semver": "6.0.0", "style-loader": "0.23.1", "terser-webpack-plugin": "1.2.3", - "ts-pnp": "1.1.1", + "ts-pnp": "1.1.2", "url-loader": "1.1.2", "webpack": "4.29.6", "webpack-dev-server": "3.2.1", From 06efceb21218e3daf0c8ab83941dba81b5d13482 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Nison?= Date: Mon, 22 Apr 2019 22:46:10 +0100 Subject: [PATCH 4/4] Bumps fork-ts-checker-webpack-plugin --- packages/react-dev-utils/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-dev-utils/package.json b/packages/react-dev-utils/package.json index 55baab54bcb..15cb2dd8bbc 100644 --- a/packages/react-dev-utils/package.json +++ b/packages/react-dev-utils/package.json @@ -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.1.0", + "fork-ts-checker-webpack-plugin": "1.1.1", "global-modules": "2.0.0", "globby": "8.0.2", "gzip-size": "5.0.0",