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

Allow dynamic route and code split configable #470

Closed
afc163 opened this issue Dec 20, 2017 · 23 comments · Fixed by #562
Closed

Allow dynamic route and code split configable #470

afc163 opened this issue Dec 20, 2017 · 23 comments · Fixed by #562
Assignees

Comments

@afc163
Copy link
Member

afc163 commented Dec 20, 2017

并在发布部署那里增加相关文档说明。

@wunayou
Copy link
Contributor

wunayou commented Dec 26, 2017

这个功能还是没有啊 如何让后端自由生成页面呢?

@afc163 afc163 added the v1 label Dec 26, 2017
@chenshuai2144
Copy link
Collaborator

@wunayou 自由生成是什么意思?

@afc163
Copy link
Member Author

afc163 commented Dec 28, 2017

@chenshuai2144 这块明天能搞定么?默认 code split 现在给内部发布流程带来很大的困扰,可配置后默认关闭好了。

@chenshuai2144
Copy link
Collaborator

@afc163 没有问题. 明天上午12点左右提交

@wunayou
Copy link
Contributor

wunayou commented Dec 29, 2017

@chenshuai2144 就是说地址相同 但是加载组件可以不同 或者地址不同 加载相同的组件, 让后台根据参数 生成页面,让他们自由搭配组件

@chenshuai2144
Copy link
Collaborator

chenshuai2144 commented Dec 29, 2017

这个应该用模板生成器吧....
前后端分离的后台只能提供一下数据这些的...
你可以试着自己生成meun.js
你说的这么灵活的配置是为了什么了?

@yesmeck
Copy link
Member

yesmeck commented Dec 29, 2017

能不能默认就不用动态加载。代码里留下比较方便的做动态加载的可能性和注释加文档。

@afc163
Copy link
Member Author

afc163 commented Dec 29, 2017

对,这是这个 issue 的目标。

@chenshuai2144
Copy link
Collaborator

如果用代码的方法实现..改动太大了.

@afc163
Copy link
Member Author

afc163 commented Dec 29, 2017

书写方式统一,默认关闭,一键打开。

打包成一个文件对于部署方式的技术要求会简单很多。

@chenshuai2144
Copy link
Collaborator

chenshuai2144 commented Jan 2, 2018

babel得方式行不通
我还没进行处理了 代码已经变成
Promise.resolve().then(() => require('model'));
webpack插件受限于roadhog 添加不上去.

@afc163
Copy link
Member Author

afc163 commented Jan 2, 2018

直接处理 Promise.resolve().then(() => require('model')); 如何?

@chenshuai2144
Copy link
Collaborator

怎么处理?
webpack内部改一个参数就可以解决。。
要不直接去给webpack pr把。。。
webpack/webpack#5029
这个issue就是这方面的。

@afc163
Copy link
Member Author

afc163 commented Jan 2, 2018

Promise.resolve().then(() => require('model')); 换成 require('model')

@chenshuai2144
Copy link
Collaborator

让我试一试。 好像没有别人想要去掉代码分割。都是教怎么开启代码分割的。

@chenshuai2144
Copy link
Collaborator

chenshuai2144 commented Jan 3, 2018

又失败了 。看见babel就恶心。。。。。
太麻烦了。。。
还有没有别的办法?

@chenshuai2144
Copy link
Collaborator

现在觉得写备注也能接受了

@sorrycc
Copy link
Contributor

sorrycc commented Jan 4, 2018

通过 babel 插件改代码就好了吧,业务 JS 全走 babel 转换的。

@afc163
Copy link
Member Author

afc163 commented Jan 4, 2018

@sorrycc 看看有没有必要把 #562 的功能内建了。

@sorrycc
Copy link
Contributor

sorrycc commented Jan 4, 2018

可以,加个 disableDynamicImport 的配置吧。

@sorrycc
Copy link
Contributor

sorrycc commented Jan 5, 2018

@sorrycc 看看有没有必要把 #562 的功能内建了。

加上了。

@afc163
Copy link
Member Author

afc163 commented Jan 5, 2018

貌似

const dynamicWrapper = (app, models, component) => {
// () => require('module')
// transformed by babel-plugin-dynamic-import-node-sync
if (component.toString().indexOf('.then(') < 0) {
models.forEach((model) => {
if (modelNotExisted(app, model)) {
// eslint-disable-next-line
app.model(require(`../models/${model}`));
}
});
return (props) => {
if (!routerDataCache) {
routerDataCache = getRouterData(app);
}
return createElement(component(), {
...props,
routerData: routerDataCache,
});
};
}
// () => import('module')
return dynamic({
app,
models: () => models.filter(
model => modelNotExisted(app, model)).map(m => import(`../models/${m}.js`)
),
// add routerData prop
component: () => {
if (!routerDataCache) {
routerDataCache = getRouterData(app);
}
return component().then((raw) => {
const Component = raw.default || raw;
return props => createElement(Component, {
...props,
routerData: routerDataCache,
});
});
},
});
};
这段判断还需要存在,单纯的开启 disableDynamicImport 会报错。

@sorrycc
Copy link
Contributor

sorrycc commented Jan 5, 2018

这应该就加在 antd-design-pro 里吧。

afc163 referenced this issue in ant-design/ant-design-pro-site Jan 10, 2018
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 a pull request may close this issue.

5 participants