Skip to content

Commit

Permalink
fix: configure jest node_modules for dangerous #18
Browse files Browse the repository at this point in the history
  • Loading branch information
oklas committed Sep 28, 2021
1 parent 464a0fc commit 98ddf5f
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/aliasDangerous.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const path = require('path')
const paths = require('react-scripts/config/paths')
const {
aliasJest,
aliasJest: aliasJestSafe,
configFilePath,
configPathsRaw,
configPaths,
Expand Down Expand Up @@ -101,6 +101,20 @@ function expandPluginsTsChecker(plugins, configPath) {
}
}

function aliasJest(aliasMap) {
const aliasJestInstance = aliasJestSafe(aliasMap)
return function(config) {
const expanded = aliasJestInstance(config)
return {
...expanded,
moduleDirectories: [
...(config.moduleDirectories || []),
path.resolve(paths.appPath, 'node_modules')
],
}
}
}

function aliasDangerous(aliasMap) {
const aliasLocal = Object.keys(aliasMap).reduce( (a,i) => {
a[i] = path.resolve(paths.appPath, aliasMap[i])
Expand Down

0 comments on commit 98ddf5f

Please sign in to comment.