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

PBjs Core - Build Related : alias dependencies tree #11327

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

GeneGenie
Copy link
Contributor

@GeneGenie GeneGenie commented Apr 11, 2024

Type of change

  • Build related changes

Description of change

I was trying to build a feature to match bidderCodes and aliases to bidAdapter names to pre-validate common format, and build an alias-adapter dependency tree, so the final result after all transformations would be a map with aliaseNames and bidderCodes as keys, and real adapter file name.

First try

i was trying to import ESM bid adapters modules to node code, but didn't succeed with various ideas. Eventually I admitted the need of compilation step, for it to be either nodejs app with tones of window mocks, or reuse existing bundling process with webpack and run in FE env using karma.

Solution

i think that funcs speak for themselfs but:

  1. grab all bidAdapters from dir
  2. compose import statements as code + compose runtime vars loggers code
  3. write "fake" test file
  4. run fake test file through karma and webpack
  5. scrape produced logs

(forked node process needs to be muted to be able to handle logs)

Running

node discoverPrebidAdapters.js

Final thoughts

So the code is still somewhat dirty, i have some improvents for it, but i'd like to clarify is this a right way to move or i missed some tools?

Thank you

PS Future plans:

  1. Import adapter manager to scan registered bidders, instead of wildcard imports
  2. match and parse md file docs from prebid.io repo
  3. automate doc validation/generation
  4. check for truth about required params, using proxy objects ?

PPS: does anyone know how to pass data from browser env to node env through karma in more elegant way? =)

@GeneGenie GeneGenie changed the title Play with adapters Alias dependencies research. Apr 11, 2024
@GeneGenie
Copy link
Contributor Author

GeneGenie commented Apr 11, 2024

Some history:
i already had such process, but built with AST tree processing, to resolve bidderCode value, tracking up all valriables etc. But it was hard to maintain without good expertise in code processing (skill issues). And adapters introduce new ways to define code and aliases, so static code analysis is not helpfull anymore.
EG:
https://github.com/prebid/Prebid.js/blob/master/modules/admixerBidAdapter.js#L21
https://github.com/prebid/Prebid.js/blob/master/modules/kargoBidAdapter.js#L9
(and others)

So I think such tool may provide more reliable data about the lib dependencies runtime. Handy

Or maybe we could enforce eslint rule to use only static values for aliases and codes, to "increase clarity" but not an expert here neither

@ChrisHuie ChrisHuie requested a review from dgirardi April 15, 2024 17:26
@ChrisHuie ChrisHuie requested a review from bretg April 15, 2024 17:26
@ChrisHuie ChrisHuie changed the title Alias dependencies research. PBjs Core - Build Related : alias dependencies tree Apr 15, 2024
@bretg
Copy link
Collaborator

bretg commented Apr 15, 2024

@GeneGenie - are you aware that the docs repo has a mapping of adapter code to aliases? This was recently surfaced in the bidder CSV file https://docs.prebid.org/dev-docs/bidder-data.csv -- not sure if it's helpful for your purposes, but it's certainly related.

@dgirardi
Copy link
Collaborator

I am hesitant about this - what is it going to be used for?

match and parse md file docs from prebid.io repo
automate doc validation/generation

for these it would make more sense to extract aliases into something that is easy to parse statically and acts as the sole source of truth. For example, we could have a aliases.json somewhere, and have both the JS and the docs build pick it up to generate adapter aliases / documentation aliases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants