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
Improves the logic to import objects in helpers #10161
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/11288/ |
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/11044/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes it more compliant to the node implementation:
// main.mjs
import * as a from "./a.js";
import { aFromB } from "./b.mjs";
console.log(a === aFromB);
// m.mjs
import * as a from "./a.js";
export { a as aFromB };
// a.js
module.exports = { foo: 1 };
Note that this optimization would only work when using |
@nicolo-ribaudo Thanks for your feedback. I will try something better based on what you said. |
@nicolo-ribaudo I've modified it to work well in the case you mentioned. Please let me know if there's anything else I need to consider. |
@nicolo-ribaudo @Andarist @zloirock Thank you all for the feedback. I realized that there might be no In this case, I modified the cache to not work. I'm sure |
@ljharb Thank you for pointing out what I did not think of. |
@nicolo-ribaudo @jridgewell @Andarist @zloirock @ljharb @cpojer Do you have plans to merge this PR? I'm sure this cache feature makes React Native apps run faster. The following table shows the time spent running js bundle at startup.
The following cases are more effective.
I think we can improve the performance of many React Native apps without any effort. Please review it positively. |
@ifsnow On the CircleCI failure, please rebase on upstream master. |
Co-Authored-By: Jordan Harband <ljharb@gmail.com>
2e0b029
to
5c622ec
Compare
@JLHwung Thanks for your feedback. Rebased my changes on upstream master to clear CircleCI failure. I think Travis CI failure is due to a build system issue (Network timeout). |
Restarted |
@nicolo-ribaudo Do you have any plans to release the new version? I'm wondering when this fix will be available :) |
In the case of
react-native
,Compiled as below.
The below logic(looping) is performed whenever
_interopRequireWildcard
withreact
is called.Generally, We have a lot of components that imports
react
orreact-native
. I don't think it's good to check the same object repeatedly on every call. so, I thought it would be better to put cache logic in here.I counted the number of how many loops are executed to start my production-level App. It may feel like, but it feels like my app is a little faster. :)
I don't fully understand
Babel
architecture. Please let me know if I have any mistakes.I hope this helps.