-
-
Notifications
You must be signed in to change notification settings - Fork 8.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
Exposing System.register _context variable to bundled code. #9119
Conversation
For maintainers only:
|
Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon. |
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 is a great low-level way to support SystemJS contextual metadata.
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.
Your implementation only works in the main chunk. Non of the code-splitted chunks would have access to __system_context__
.
@sokra since the jsonp interface doesn't have an easy way to pipe through this So would make this PR dependent on having native SystemJS chunk loading support for webpack chunks, which we may not be able to implement any time soon. It seems a shame to block this useful feature on the development of more difficult feature. |
Afaik, setting the public path dynamically is something you only really need to do in the main chunk. So I see value in the PR as is, and would be happy with it merged even with the limitation you described. All of that said, what do you think of the following implementation for sharing // output bundle
System.register([], function(_export, __system_context__) {
return {
execute: function() {
// normal webpack initialization stuff
// ...
// Add system context to webpack require
__webpack_require__.__system_context__ = __system_context__
}
}
}) Is there a better way to go about sharing the system context? Or would it turn into a full blown code splits refactor, like you mentioned before? |
@sokra if you have a moment to give any advice on how we might move forward with this general direction, would really appreciate your thoughts. |
@sokra I have updated this with your feedback. |
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.
It would be great to get this supported.
Any update on this? I know you are busy and appreciate your time 😄 |
40761da
to
790c76e
Compare
@sokra I have updated this with your feedback |
I have signed the CLA but Github's checks section says I haven't. Do I need to trigger another build or something to make Github realize that it is signed? |
@joeldenning you email in commit is not same as in github |
fb19446
to
cf4f067
Compare
@joeldenning Thanks for your update. I labeled the Pull Request so reviewers will review it again. @sokra Please review the new changes. |
Bump. I just merged master into this branch. I would very much appreciate a review 😄. |
Just merged master into this. Now fully up-to-date with latest master branch. |
The code coverage report seems to be incorrect? It lists a lot of files that have not been changed in my pull request as the reason why code coverage is failing. For example, in this report it cites I tried retriggering the build by pushing new commits, but to no effect. I also wonder whether I need to squash my commits to see if that helps it sort out what are the new changes and what aren't. I started this PR before the master branch became webpack@5, and so there are large merge commits that potentially could be causing trouble. If anyone has advice on this, I'd love to hear it. Despite this PR being almost a year old, I'd still very much like to see it reviewed and merged, if possible. |
The minimum test ratio has been reached. Thanks! |
4d8c22a
to
f8767b9
Compare
55c91be
to
efc5789
Compare
Making __system_context__ available to code splits. Fixing git problem Making PR compatible with webpack 5 Undoing prettier changes to open-bot Adding test Triggering build Triggering build Reimplementing with new file Exposing System.register _context variable to bundled code. Making __system_context__ available to code splits. Making PR compatible with webpack 5 Undoing prettier changes to open-bot Adding test Triggering build Triggering build Self review Self review Fixing license Removing deleted file Fix
efc5789
to
76d5cd5
Compare
@sokra (or anyone else with merge privilege) I would appreciate your review on this. It is ready for merge - the coverage failures seem to be unrelated. |
Thanks |
Motivation
The motivation for this change is discussed in systemjs/systemjs#1939.
The change allows users to do things like the following:
What kind of change does this PR introduce?
Feature. This allows webpack users to use the _context argument provided to System.register bundles.
Did you add tests for your changes?
Yes.
Does this PR introduce a breaking change?
No
What needs to be documented once your changes are merged?
We need to document that
__system_context__
is a variable available to those bundling tooutput.libraryTarget: "system"
.