-
Notifications
You must be signed in to change notification settings - Fork 2.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
Prebid Core: Library support #8527
Conversation
This is amazing work. Thanks a lot 🎉 |
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.
Thanks for putting this together! I disagree only with the name choice for the first library.
Also noting that this does not completely address #7936 (which is perfectly fine - I just wouldn't want that to be closed prematurely).
libraries/extraUtils/index.js
Outdated
/** | ||
* Returns the origin | ||
*/ | ||
export function getOrigin() { |
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.
IMO the library should just be named 'getOrigin' - 'extraUtils' invites us to dump more unrelated stuff in here, which will eventually bring about the same problem that utils has :)
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.
addressed
"files": [ | ||
"./index.js" | ||
], | ||
"dependants": [ |
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.
in principle we should be able to calculate these automatically by looking at import
s. I think webpack's chunking feature does it under the hood but I don't see an easy way to extract the graph for us to use in bundle
.
We can easily add it later so no request for this PR, just noting it here in case you are familiar with that feature.
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.
makes sense, I'm happy to explore that in the near future when cycles free up
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.
👍 I could see this dependents list getting out of hand quickly.
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.
LGTM! I'll note again that this could potentially break 3rd party vendors if they're using the build output as it is now - but I don't actually know of any concrete case where that would be a problem.
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.
Overall looks great. Just left one question. Good work solving a long standing problem with the build system!
"files": [ | ||
"./index.js" | ||
], | ||
"dependants": [ |
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.
👍 I could see this dependents list getting out of hand quickly.
/** | ||
* Returns the origin | ||
*/ | ||
export function getOrigin() { |
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.
is there any restrictions on library files? What happens if you want to import another file from the library file?
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.
When I initially envisioned this, the maintainer of the library would determine which files are necessary.
If users were to find the library too heavy, the maintainer could either split the library (i.e by feature or by light vs advanced) or a competitor could offer a lighter library.
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.
We'll probably need to cover this at a later date, with some best practices or boundaries
* adds extra utils * imports from extra utils * adds libraries to .submodules * adds libraries to build process * renames extraUtils * update userId submodules list
Type of change
Description of change
This PR allows modules to share code outside of core by introducing
Libraries
. With these changes, code outside ofcore
can be shared without duplication in the build.As an example, the
extraUtils
library is introduced. ThegetOrigin
function from the core utils has been moved to this library, and the library is now listed as a dependency of the 3 modules that use the util.Note that when the dist is built or bundled, the
getOrigin
function is not duplicated.You can test with:
gulp build --modules=ooloAnalyticsAdapter,resetdigitalBidAdapter
gulp bundle --modules=ooloAnalyticsAdapter,resetdigitalBidAdapter
Other information
Helps with issue #7936
Needed for #7264
@dgirardi for review