Recently in the study of react Native. The feeling of development efficiency is really good, but the JSX grammar is not very comfortable to write.
Tried the sublime Text 3 and visual Studio code to write codes, feeling the reaction is always slow a pat.
or want to change back VS2015 write jsx, but with vs write jsx seems to be only in the suffix of. jsx file inside write. (Do not know if the VS has directly set the method of writing jsx in JS)
Then turned over the react-native of the packaging process, changed to let the packaging program can automatically package. jsx file.
Paste the modified method, accustomed to vs can try to change the
1. Project Home folder \node_modules\react-native\packager\react-packager\src\server\index.js
Find "var watchrootconfigs = opts.projectRoots.map (dir = = {" This paragraph, plus '. Jsx ')
var watchrootconfigs = Opts.projectRoots.map (dir = = {return {dir:dir,globs: [' **/*.js ', ' **/*.json ', ' **/*.jsx ',]. Concat (Assetglobs),};});
2. Project Home folder \node_modules\react-native\packager\react-packager\src\dependencyresolver\dependencygraph\index
Look for "this._crawling = Crawl (Allroots, {" Add paragraph, also add ' jsx '
This._crawling = Crawl (Allroots, {ignore:this._opts.ignorefilepath,exts: [' js ', ' jsx ', ' json '].concat (this._ opts.assetexts), Filewatcher:this._opts.filewatcher,});
3. Project Home folder \node_modules\react-native\packager\react-packager\src\dependencyresolver\dependencygraph\ Resolutionrequest.js
Find "if (this._fastfs.fileexists (Potentialmodulepath)) {" Change to
let file; Let exts=["", This._platform? ('. ' + This._platform + '. js '): null, '. js ', '. json ', '. js ' X ']; for (let c=0;c<exts.length;c++) {if (Null!=exts[c] &&this._fastfs.fileexists (potentialmodulep Ath + exts[c]) && (file = Potentialmodulepath + exts[c]) break; } if (!file) {throw new Unabletoresolveerror (Frommodule, Tomodule, ' file ${potentia Lmodulepath} doesnt exist ',); }//Below is the original code//if (This._fastfs.fileexists (Potentialmodulepath)) {//file = Potentialmodulepath; } else if (this._platform! = null &&//this._fastfs.fileexists (Potentialmodulepath + '. ' + this. _platform + '. js ')} {//File = Potentialmodulepath + '. ' + This._platform + '. js '; } else if (this._fastfs.fileexists (Potentialmodulepath + '. js ')) {//File = Potentialmodulepath + '. js '; //}else if (this._fastfs.fileexists (Potentialmodulepath + '. JSON ')) {//File = Potentialmodulepath + '. JSON '; } else {//throw new Unabletoresolveerror (//Frommodule,///Tomodule,//' File ${potenti Almodulepath} doesnt exist ',//); //}
Change to run react-native start to automatically package the suffix. jsx files.
React Native packaging. jsx file