Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复在同构项目中, 因该依赖问题导致node端在没有react-native 的环境下,会提示找不到该模块, 实际上,即使有react-… #758

Closed
wants to merge 2 commits into from

Conversation

inJs
Copy link

@inJs inJs commented Jan 22, 2017

…native 模块也会有其他的错误爆出。 目前该问题并没有在纯前端渲染的模式中体现出来。

First of all, thanks for your contribution! :-)

Please makes sure these boxes are checked before submitting your PR, thank you!

  • Make sure you follow antd's code convention.
  • Run npm run lint and fix those errors before submitting in order to keep consistent code style.
  • Rebase before creating a PR to keep commit history clear.
  • Add some descriptions and refer relative issues for you PR.

…native 模块也会有其他的错误爆出。 目前该问题并没有在纯前端渲染的模式中体现出来。
@inJs inJs changed the title 修复在同构项目中, 因该依赖问题导致node端在没有react-native 的环境下,会提示找不到该模块, 实际上, 既有有react-… 修复在同构项目中, 因该依赖问题导致node端在没有react-native 的环境下,会提示找不到该模块, 实际上,即使有react-… Jan 22, 2017
@warmhug
Copy link
Contributor

warmhug commented Jan 22, 2017

关联 #757 。这个不光是 list 组件这么做,其他组件也都这么做的。目前算是不支持同构的。

同构的支持后续会尝试做,但需要测试所有组件,还需要考虑 RN,再确认统一的修改方案。

@inJs
Copy link
Author

inJs commented Jan 22, 2017

@warmhug 从代码上来看, 在 .web 的文件中, 将所有组件(.web 的组件)的内部组件以来改为 .web 是否就可以了?

@afc163
Copy link
Member

afc163 commented Jan 22, 2017

#602

@silentcloud
Copy link
Contributor

理论上 .web.tsx 文件里引用 web 子文件的时候,最好还是要指定引用为 .web 后缀,类似 PR 里提的这个,我们还是要 check 一下现有组件,都改过来 @warmhug

@warmhug
Copy link
Contributor

warmhug commented Jan 23, 2017

@yiminghe 说过不加 web 后缀

@inJs
Copy link
Author

inJs commented Jan 24, 2017

@warmhug 为啥呢? 感觉 .web 的只引入 .web 是合理的吧?不求甚解!

@warmhug
Copy link
Contributor

warmhug commented Jan 25, 2017

import PopupDatePicker from 'rmc-date-picker/lib/Popup';

https://github.com/react-component/m-date-picker/blob/910676ce8c71fc17f2c05a432afe7346efcc2c38/src/Popup.tsx#L3
类似这些底层依赖也要改了才行,要改改动的地方也比较多的。

@inJs
Copy link
Author

inJs commented Jan 25, 2017

@warmhug 那意思是可改, 只是改的地方较多。 这个意思?

@inJs
Copy link
Author

inJs commented Jan 25, 2017

其实我需要看到一个结论, 是不是需要改? 需要的话我可以 one by one 的改过来。 项目急需用, 啊哈哈

@warmhug
Copy link
Contributor

warmhug commented Jan 26, 2017

@inJs 年后上班再确认结论,先休息过年~

@inJs
Copy link
Author

inJs commented Feb 3, 2017

@warmhug 这个pr 最终方案怎么定?

@silentcloud
Copy link
Contributor

@inJs 这个按照你 pr 的方式来改

@inJs
Copy link
Author

inJs commented Feb 6, 2017

@silentcloud ok, 那我去办

@inJs
Copy link
Author

inJs commented Feb 7, 2017

这个pr 什么时候合过去?

@warmhug
Copy link
Contributor

warmhug commented Feb 7, 2017

@yiminghe review 下看看有没问题

@inJs
Copy link
Author

inJs commented Feb 7, 2017

@yiminghe

@yiminghe
Copy link
Contributor

yiminghe commented Feb 7, 2017

不要这样改,有些组件不能改,尝试在nodejs端修改

require.extensions['.js'] = function(module, filename) {
   if(fs.exists(filename+'web.js')) filename=filename+'web.js';
    return module._compile(transform(filename), filename);
};

@silentcloud
Copy link
Contributor

这个最终结论? @inJs 按照 @yiminghe 的建议吧,PR 我就先 close 了

@qqnp1100
Copy link

qqnp1100 commented Aug 5, 2017

require.extensions['.js'] = function(module, filename) {
   if(fs.exists(filename+'web.js')) filename=filename+'web.js';
    return module._compile(transform(filename), filename);
};

@yiminghe transform 是什么函数?

@inJs
Copy link
Author

inJs commented Aug 5, 2017

@qqnp1100 babel.transform , 文档地址: https://babeljs.io/docs/usage/api/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants