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

Narrow import of DEFAULT_APP_CATEGORIES to avoid bundling unnecessary code #834

Closed

Conversation

AMoo-Miki
Copy link
Contributor

@AMoo-Miki AMoo-Miki commented Jul 27, 2023

Description

#741 introduced an import of DEFAULT_APP_CATEGORIES which results in the importing of everything under @osd/std which invokes the typeof transformer that confuses babel/webpack/babel plugins/osd-optimizer into incorrectly identifying the exportsArgument and that results in exports being used in a context that isn't aware of it, resulting in export is not defined when OSD is accessed.

I believe this is a better solution than #826 since it prevents the bundling of @osd/std and ... .

Issues Resolved

[List any issues this PR will resolve]

Check List

  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

…ry code

Signed-off-by: Miki <miki@amazon.com>
@Hailong-am
Copy link
Collaborator

Hailong-am commented Jul 27, 2023

@AMoo-Miki thank you to find out the root cause and have a better solution to fix it, i will close #826.

another question is that we have same code in notification plugin, not sure why it works

@AMoo-Miki
Copy link
Contributor Author

AMoo-Miki commented Jul 27, 2023

@Hailong-am notifications has the same problem of bundling a ton of unnecessary things and this change will help them.

The reason the typeof confusion is not happening there is because of the different babel config being applied.

PS, i just noticed that this causes a release build failure and am looking to see how I can solve that.

Module not found: Error: import [../../../src/core/utils/default_app_categories] references a non-public 
export of the [core] bundle and must point to one of the public directories: [public, public/utils]

@SuZhou-Joe
Copy link
Member

I have a question that why does this only happen in production/bundled mode, not dev mode. Or we can get rid of it earlier. Babel/Webpack stuffs should also be applied when in dev mode. @AMoo-Miki Do you have any idea on this?

@AMoo-Miki
Copy link
Contributor Author

We know different rules are are being applied to prod releases and dev bundles, and are working on narrowing the difference.

@Hailong-am
Copy link
Collaborator

Hailong-am commented Jul 28, 2023

@Hailong-am notifications has the same problem of bundling a ton of unnecessary things and this change will help them.

The reason the typeof confusion is not happening there is because of the different babel config being applied.

PS, i just noticed that this causes a release build failure and am looking to see how I can solve that.

Module not found: Error: import [../../../src/core/utils/default_app_categories] references a non-public 
export of the [core] bundle and must point to one of the public directories: [public, public/utils]

If we change it to public or public/utils, that will be the same change as before.

@AMoo-Miki
Copy link
Contributor Author

If we change it to public or public/utils, that will be the same change as before.

Correct; there are multiple factors that have gotten aligned to make this issue manifest here. The good thing is that it has allowed us to discover a couple of problems we have. If one of those factors was removed, we wouldn't have the issue manifest itself and we knew that this PR was not the best solution, even though it eliminated one of the factors to solve the issue, because it was advocating for doing the wrong thing.

Over the past couple of days, I have looked at each of the factors and found that the best one is to get rid of your babel config overrides. I will close this PR and raise a new one to do so.

@AMoo-Miki AMoo-Miki closed this Jul 28, 2023
@Hailong-am
Copy link
Collaborator

Over the past couple of days, I have looked at each of the factors and found that the best one is to get rid of your babel config overrides. I will close this PR and raise a new one to do so

@AMoo-Miki do you mean remove babel.config.js and use default? where can i find the default config?

@Hailong-am Hailong-am mentioned this pull request Aug 3, 2023
1 task
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 this pull request may close these issues.

3 participants