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

内部依赖包rmc-cascader 所依赖的包中的 Cascader.web.js 文件中依赖的 rmc-picker/lib/Picker.web 文件已被移除(或重命名?) #1239

Closed
inJs opened this issue Apr 28, 2017 · 9 comments

Comments

@inJs
Copy link

inJs commented Apr 28, 2017

Version

1.1.0

Environment

Mac OS 10, chrome 59 react 59

Reproduction link

https://github.com/ant-design/ant-design-mobile

Steps to reproduce

因 antd-mobile 无法完整支持 ssr, 故写了如下hack 代码:

require.extensions['.js'] = function(module, filename) {
    const name = filename.substr(0, filename.length - 3);

    if(fs.existsSync(`${name}.web.js`)) {
        filename = `${name}.web.js`;
    }
    let result = fs.readFileSync(filename, 'utf-8');
    
    if(~filename.indexOf('app') || ~filename.indexOf('server')) {
        result = babel.transform(result, {
            presets: [
                'es2015',
                'es2017',
                'stage-0'
            ],
            plugins: [
                'transform-runtime',
                'add-module-exports',
                'transform-react-jsx'
            ]
        }).code;
    }

    return module._compile(result, filename);
};

逻辑很简单, 在存在 .web 文件时, 加载 .web 文件, 因此引发了该问题(因为 Cascader.web.js 文件中将文件名写死了, 然而 mc-picker/lib/Picker.web 文件已经被重命名或删除?现在只存在 mc-picker/lib/Picker 文件)。

What is expected?

服务启动正常!

What is actually happening?

Error: Cannot find module 'rmc-picker/lib/Picker.web'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/workstation/wac/calculus-loan-platform/node_modules/rmc-cascader/lib/Cascader.web.js:15:15)
    at Module._compile (module.js:570:32)
@cncolder
Copy link
Contributor

cncolder commented Apr 28, 2017

@inJs 应该是你的 m-cascader 和 rmc-picker 版本不匹配吧,这两个模块是同一个作者,两个模块同时更新去掉了 .web 后缀,我看了一眼改动发生在两小时以前。

@paranoidjk
Copy link
Contributor

这个改动会慢慢全推,做了相关ssr hack的话需要处理下了,抱歉。

#1235

@inJs
Copy link
Author

inJs commented Apr 28, 2017

@cncolder 嗯, 是yiminghe的模块。 @paranoidjk 意思是影响会更大? 目前已经通过项目 package.json 锁死了版本解决该问题。

@yiminghe
Copy link
Contributor

yiminghe commented May 2, 2017

最新的 m-cascader 已经没有 Cascader.web.js了,看下是否需要升级 @paranoidjk

@deot
Copy link

deot commented May 2, 2017

可以先用npm i [email protected]把版本锁死

@cncolder
Copy link
Contributor

cncolder commented May 2, 2017

@yiminghe break change 应该增加 major 版本号吧

@onlyLiru
Copy link

我用的0.9.5的antd-mobile依然存在这个问题啊,请问怎么解决?

@pingan1927
Copy link
Contributor

pingan1927 commented May 17, 2017

@yiminghe @paranoidjk 小版本回滚掉吧,大版本发布才能解决问题。

@pingan1927 pingan1927 reopened this May 17, 2017
@paranoidjk
Copy link
Contributor

不需要回滚的

  • antd-mobile 没有显式引用 rc-component/lib/foo.web
  • webpack resolve 配置会自动 fallback
resolve: {
  modulesDirectories: ['node_modules', path.join(__dirname, '../node_modules')],
  extensions: ['', '.web.js', '.js', '.json'],
},

https://mobile.ant.design/docs/react/introduce-cn#Web-使用方式
https://github.com/ant-tool/atool-build/blob/1d750f00fc84cf38ed3dec709e85dd6b9d282534/src/getWebpackCommonConfig.js#L82

@ant-design ant-design locked as off-topic and limited conversation to collaborators May 28, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants