Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/react-scripts/config/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ function getAdditionalModulePaths(options = {}) {

// Allow the user set the `baseUrl` to `appSrc`.
if (path.relative(paths.appSrc, baseUrlResolved) === '') {
return [paths.appSrc];
return {
resolved: [paths.appSrc],
relative: [baseUrl],
};
}

// If the path is equal to the root directory we ignore it here.
Expand Down
4 changes: 3 additions & 1 deletion packages/react-scripts/config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,9 @@ module.exports = function (webpackEnv) {
// 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.additionalModulePaths
? modules.additionalModulePaths.resolved
: []
),
// These are the reasonable defaults supported by the Node ecosystem.
// We also include JSX as a common component filename extension to support
Expand Down
9 changes: 8 additions & 1 deletion packages/react-scripts/scripts/utils/createJestConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
'use strict';

const fs = require('fs');
const path = require('path');
const chalk = require('react-dev-utils/chalk');
const paths = require('../../config/paths');
const modules = require('../../config/modules');
Expand Down Expand Up @@ -52,7 +53,13 @@ module.exports = (resolve, rootDir, isEjecting) => {
'[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs|cjs|ts|tsx)$',
'^.+\\.module\\.(css|sass|scss)$',
],
modulePaths: modules.additionalModulePaths || [],
modulePaths: modules.additionalModulePaths
? modules.additionalModulePaths.relative.map(
// Absolute paths will cause issues if the ejected jest config is applied on other
// machines, so we translate them to relative paths to the rootDir
modulePath => path.join('<rootDir>', modulePath)
)
: [],
moduleNameMapper: {
'^react-native$': 'react-native-web',
'^.+\\.module\\.(css|sass|scss)$': 'identity-obj-proxy',
Expand Down