-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
(Question)Is there a way to share code between app and libs? #833
Comments
@slowcheetah @zloirock Hi, would you mind take a look at this? Thanks~ |
It's a good issue.
They rely on modules with the same name, but with a different code.
The "pure" implementation has too many limitations, uses expensive workarounds, in many cases non-complete, so we could not do it. I played with solving this problem for a long time. Sharing common modules between those versions makes no sense - it's just a little part of the code size and it will increase the size of each version if it's used alone. However, now I have an idea of how to solve this issue in the next generation of tools. The details will be later. |
Ah, happy to wait for your 'The details' |
I wanted to publish details a long time ago, but I posted this only right now. This problem should be solved in this, transpiler-based, way. |
core-js/modules/es.promise.js
andcore-js-pure/modules/es.promise.js
are exactly the same code, the main difference is just that the former has global pollution. If so, whycore-js
doesn't use(directly import)core-js-pure
to polyfill and then add it to the global?IMO, this will greatly reduce the duplications because at now many libs usally use
@babel/transform-runtime
with{ corejs: 3}
(finally iscore-js-pure
) but many apps usepreset-env
with{corejs: 2}
(finally iscore-js
), there isno
shared/shareable codes between apps and libs, right?Refer to babel/babel#11515
The text was updated successfully, but these errors were encountered: