React Native 如何运行打包.jsx文件
来源:互联网 发布:mac粉饼专柜价格表 编辑:程序博客网 时间:2024/06/09 10:44
最近在学习RN,发现项目里面的.jsx文件怎样都无法引用,后来网上搜索了一下,发现RN无法运行.jsx文件。在网上搜索到一位大神的博客,描述了如何让RN运行打包.jsx文件,copy一份作为记录,源博客链接:http://www.cnblogs.com/Grart/p/5033281.html
1.项目主文件夹\node_modules\react-native\packager\react-packager\src\Server\index.js找"var watchRootConfigs = opts.projectRoots.map(dir => {"这段,加上'.jsx'
var watchRootConfigs = opts.projectRoots.map(dir => {return {dir: dir,globs: ['**/*.js','**/*.json','**/*.jsx',].concat(assetGlobs),};});
2.项目主文件夹\node_modules\react-native\packager\react-packager\src\DependencyResolver\DependencyGraph\index
0.22版使用的是node-haste在\node_modules\react-native\node_modules\node-haste\lib\index
找"this._crawling = crawl(allRoots, {"加段,同样加上'jsx'
this._crawling = crawl(allRoots, {ignore: this._opts.ignoreFilePath,exts: ['js', 'jsx','json'].concat(this._opts.assetExts),fileWatcher: this._opts.fileWatcher,});
3.项目主文件夹\node_modules\react-native\packager\react-packager\src\DependencyResolver\DependencyGraph\ResolutionRequest.js
0.22版在\node_modules\react-native\node_modules\node-haste\lib\DependencyGraph
找"if (this._fastfs.fileExists(potentialModulePath)) {"改成
let file;let exts=["", this._platform?('.' + this._platform + '.js'):null, '.js', '.json', '.jsx'];for(let c=0;c<exts.length;c++){ if(null!=exts[c] &&this._fastfs.fileExists(potentialModulePath + exts[c]) &&(file = potentialModulePath + exts[c])) break;}if(!file){ throw new UnableToResolveError( fromModule, toModule, `File ${potentialModulePath} doesnt exist`, );}//以下为原来的代码//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 ${potentialModulePath} doesnt exist`,// );//}
阅读全文
0 0
- React Native 如何运行打包.jsx文件
- React Native 中的JSX学习
- React Native 学习 之JSX
- React/JSX及React Native 编码规范
- React native ios 打包到手机运行
- React Native 打包生成apk文件
- react-native 打包android apk文件
- react native gradle assembleRelease打包运行失败,没有生成bundle文件
- React Native入门:关于JSX语法
- React-Native-源码分析二-JSX如何渲染成原生页面(上)
- React-Native-源码分析三-JSX如何渲染成原生页面(下)
- 如何运行github上react native项目
- 如何运行github上react native项目
- React Native开源项目如何运行
- 如何运行github上react native项目
- react ,jsx ,react native 一些相关的学习网站材料
- React Native学习笔记(2)--React与JSX语法
- react-native工程 打包
- 使用sqlplus执行sql时,发现有中文有乱码解决方法
- C#三种性能分析计时器介绍
- 巧妙利用标签TAG做长尾关键词上首页
- html实体字符
- SQL字符串中的不可见字符
- React Native 如何运行打包.jsx文件
- dubboAPl参考手册
- 如何生成压缩文件文件(zip)
- safari input 行高问题解决
- XSSFWorkbook和HSSFWorkbook读取excel
- 深入浅出JMS(一)--JMS基本概念
- 使用CrossApp实现版本更新管理(iOS端给AppStore链接,android端下载apk并替换)
- JEESZ-Redis分布式缓存安装和使用
- dbms_stats包的常用几个信息统计分析