-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
[kbn/optimizer] update public path before imports #67561
[kbn/optimizer] update public path before imports #67561
Conversation
Pinging @elastic/kibana-operations (Team:Operations) |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…lic-path-before-imports
…lic-path-before-imports
…lic-path-before-imports
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
@elastic/kibana-design this includes some scss files but just for testing the optimizer. |
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.
Yep, that's fine!
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.
clever solution...LGTM
Co-authored-by: spalger <spalger@users.noreply.github.com> # Conflicts: # packages/kbn-optimizer/src/integration_tests/__snapshots__/basic_optimization.test.ts.snap # packages/kbn-optimizer/src/integration_tests/basic_optimization.test.ts
Co-authored-by: spalger <spalger@users.noreply.github.com> # Conflicts: # packages/kbn-optimizer/src/integration_tests/__snapshots__/basic_optimization.test.ts.snap # packages/kbn-optimizer/src/integration_tests/basic_optimization.test.ts
In #64226 we moved from replacing the public path in the JS source to an approach that supports setting the
__webpack_public_path__
in the webpack bundles with some global variable magic. This relies on a webpack loader which injects some code into the top of each bundle entry point. This works in the kbn-ui-shared-deps where it's easier to test and all modules are imported using commonjs but didn't work for static imports in KP plugins because the public path loader was injecting code into the top of the file and webpack moved the imports up above that code, causing__webpack_public_path__
to be updated after the import statements are processed.To fix this we no longer inject code to set
__webpack_public_path__
, we inject a dynamic module at the top of the entry bundle which does that, since it's an import the code stays above the rest of the imports in that file. Doing this dynamically required the use of theval-loader
to dynamically generate the source for the module at compilation time.