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

common-chunks 有没有这种可能 #79

Open
doxiaodong opened this issue Feb 16, 2018 · 9 comments
Open

common-chunks 有没有这种可能 #79

doxiaodong opened this issue Feb 16, 2018 · 9 comments
Labels

Comments

@doxiaodong
Copy link
Contributor

  1. vendor: import 'jQuery'

  2. chunk1: $.ajax

  3. chunk2: $.ajax

  4. fec_common: $ajax

script: fec_common ($ is undefined)
script: vendor ($ defined here)

@doxiaodong
Copy link
Contributor Author

@nighca

@doxiaodong
Copy link
Contributor Author

我再测试的过程中发现 有 common-chunk 那个 manifest chunk 就出不来

@nighca
Copy link
Collaborator

nighca commented Feb 18, 2018

script: fec_common ($ is undefined)
script: vendor ($ defined here)

这个不是预期的嘛?

另外有 common chunks 的时候就拿 common chunk 当 manifest 也去预期的吧?现在是有 common chunk 的时候起不到 manifest 的效果?

@doxiaodong
Copy link
Contributor Author

不是呀,我在 vendor 里面引入了 $ , 在其他的模块使用 $

@nighca
Copy link
Collaborator

nighca commented Feb 18, 2018

意思是其他模块里以全局变量的形式直接用 $?

@doxiaodong
Copy link
Contributor Author

对的。

@nighca
Copy link
Collaborator

nighca commented Feb 20, 2018

那不是我们这个层面去实现吧,他在 vendor 里

import $ from 'jQuery'
window.$ = $

@doxiaodong
Copy link
Contributor Author

对啊,这段代码辉被打进 vendor 去, 但是 fec__common 会在 vendor 前面被引入

@nighca
Copy link
Collaborator

nighca commented Feb 20, 2018

按理说,这俩的顺序应该没关系,这些代码是在 module 的 factory 里,factory 本身的执行顺序跟文件本身的引入顺序无关的,只要保证在入口代码最开始去 import vendor,那初始化全局变量的事情就在 common 中 factory 前边执行了。

不过我还不太确定 webpack 会不会对 vendor 或者 manifest entry 干点黑科技,没有黑科技的话应该就是上边的逻辑

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

No branches or pull requests

2 participants