This repository was archived by the owner on Jan 26, 2019. It is now read-only.
Allow moduleNameMapper
config override #303
Merged
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
This patch will allow path mapping to be fully supported, by allowing
moduleNameMapper
to be configured.Issue
Currently, you can add paths to your
tsconfig
and the app will run fine. Butjest
/ts-jest
does not use the configuration from yourtsconfig
. Configuring themoduleNameMapper
will solve this. Sadly, the property is not "supported" and tests can not be run if the configuration is set.Example usage:
Changing the following files will allow you to import modules from the
src
folder, by prefixing the import path with a tilde. E.g. a component living insrc/components/Button
can always be imported via~/components/Button
. No../../../
anymore!tsconfig.json
package.json
Changes:
baseUrl
sotsconfig-paths-webpack-plugin
will not warn that it is missing (Fixed problem with tsconfig.json baseUrl and paths #223)moduleNameMapper
(Support for TypeScripts 'paths' option #203)Allow overriding the
moduleNameMapper
configuration is the pragmatic approach. If you're using absolute paths + react-native you would have to re-add the mapping.