-
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
How best to include Prebid.js as part of a bigger project? #1853
Comments
I'm glad someone finally asked! I don't actually know the best practice here. Would you mind either posting a minimal build system you are using or describing the the setup in more detail? Open to suggestions here but my guess is that we'd need to distribute a "packaged" version of the core + add on modules to be able to do a direct import. |
@mkendall07 - thanks for the very quick reply. I'm still prototyping a few ideas, we have literally just started on this, so there is very little code. This is just to have a single build to go in the header of the site that will include Prebid.js. I think you are correct, it will just require a built version
|
@snapwich - you're working on packaging enhancements... would that help address this item? |
For now, I'm going to leave this as a basic Prebid module: -
It would be great to properly bundle this in however 👍 |
Snapwich is out this week, but will take a look next week. |
@cwbeck Prebid.js doesn't have a default export (I don't believe) so importing prebid as a 'named' export will transpile to something unusable. Based on your output I'm guessing your not actually doing that or you're using some sort of TS setting that I'm not familiar with. I'd expect
to transpile to something similar to
I doubt you're doing this though since you're not getting an error saying something about prebid.default being undefined.So just to clarify, have you tried |
@entol, sorry, I forgot to reply to this! Trying to include it as you suggested just results in warnings complaining about dependencies from prebid. I can see why this is the case now, it would take a built version to be provided - this is the behaviour of other libraries that allow |
@cwbeck I just spent some time looking into this and here is what I ended up doing:
#!/bin/bash
cd node_modules/prebid.js
yarn install
node_modules/.bin/gulp build --modules=../../modules.json
cp build/dist/prebid.js ../../vendor/prebid.js Finally you just need to call |
@mmilleruva correct. This is exactly how I have it set up now, although I symlink to my fork prebid.js - This is however not necessarily the best way of doing it. |
You could also load prebid in a different script tag and mark it as an external in webpack. As long as script order is maintained (not using async or using defer) this should work too. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
A lot has changed to the point where this might be more possible than it was in the past. Going to take some looks about the feasibility here. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
We are moving to a new framework and thought it a good idea to ask how best to include Prebid.js library. In an ideal world, I would like to add it as a dependency to package.json and :-
import prebid from "prebid.js";
This leads to a whole load of issues: -
Has anyone found a good way to include this, or is it just easier to stick to a build and shim it in?
Just feels a bit horrible!
The text was updated successfully, but these errors were encountered: