Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jan 26, 2019. It is now read-only.

AllowmoduleNameMapper config override#303

Merged

Conversation

@sebald
Copy link
Contributor

@sebaldsebald commentedApr 11, 2018
edited
Loading

This patch will allow path mapping to be fully supported, by allowingmoduleNameMapper to be configured.

Issue

Currently, you can add paths to yourtsconfig 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 thesrc 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

{  "compilerOptions": {     ...+    "baseUrl": ".",+    "paths": {+      "~/*": ["src/*"]+    }  },

package.json

{  ...  "jest": {    ...+    "moduleNameMapper": {+      "^~/(.*)$": "<rootDir>/src/$1"+    }  },}

Changes:

  1. AddbaseUrl sotsconfig-paths-webpack-plugin will not warn that it is missing (Fixed problem with tsconfig.json baseUrl and paths #223)
  2. Allow overridingmoduleNameMapper (Support for TypeScripts 'paths' option #203)

Allow overriding themoduleNameMapper configuration is the pragmatic approach. If you're using absolute paths + react-native you would have to re-add the mapping.

adambowles, nmchaves, raptoria, and lichenglu reacted with thumbs up emoji
@farzadmf
Copy link

Any news on this? Any plan to merge this PR to havemoduleNameMapper support?

'coverageReporters',
'coverageThreshold',
'snapshotSerializers',
'moduleNameMapper',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

  • This should be listed in the corresponding README to be adjustable. Just recognized that the original section on CRA (https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#configuration) is absent here... However, this field (and potentially the section) should be listed there, including the example usage and a note on how this relates to entries in thetsconfig.json.
  • I'm still thinking about the default value used on this field,'^react-native$': 'react-native-web'. It should either be noted that it has to be provided manually in case of overriding this key, or that entry should be merged automatically. Suppose the first way might be preferable.

@DorianGrey
Copy link
Collaborator

I'm very sorry for the late response, I was quite busy lately and also attempted to figure out why the travis build began to fail shortly after it was fixed for the master branch ...

Comments are attached on the review.

@sebald
Copy link
ContributorAuthor

@DorianGrey No problem, I'll integrate the suggested changes next week 🙂

Sebastian Sebald added3 commitsMay 8, 2018 11:15
* master:  Stick @types/node to 9.6.7 to avoid problems with 10.0.0 (wmonk#315)  Fix travis build (wmonk#302)  v2.15.1  Update README For 2.15.1  fix(modules): remove duplicate mjs from jest config
@sebald
Copy link
ContributorAuthor

@DorianGrey added the section to the readme as suggested 🙂

@DorianGreyDorianGrey merged commite17362e intowmonk:masterMay 9, 2018
@DorianGrey
Copy link
Collaborator

LGTM, thanks!

(Note: I'll ignore the failing CI for the moment - thatkitchensink case is extremely unstable, still working on a fix for that).

adambowles reacted with thumbs up emojirrousselGit and sebald reacted with hooray emoji

@sebaldsebald deleted the allow-moduleNameMapper-override branchMay 9, 2018 06:58
@adambowles
Copy link
Contributor

Nice! When will this be released to npm?

rrousselGit reacted with thumbs up emoji

@DorianGrey
Copy link
Collaborator

I'm still waiting for a reaction on#314 to figure out if pinning the@types/node version can be reverted or has to be retained. Would be favorable to figure this out before an additional release.

DorianGrey added a commit that referenced this pull requestMay 11, 2018
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

1 more reviewer

@DorianGreyDorianGreyDorianGrey approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

4 participants

@sebald@farzadmf@DorianGrey@adambowles

[8]ページ先頭

©2009-2025 Movatter.jp