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

circular dependency between util.js and config.js #6023

Closed
cazyw opened this issue Nov 23, 2020 · 6 comments
Closed

circular dependency between util.js and config.js #6023

cazyw opened this issue Nov 23, 2020 · 6 comments
Assignees

Comments

@cazyw
Copy link

cazyw commented Nov 23, 2020

Type of issue

Possible bug - although since nobody else has complained about this, there must be a workaround

Description

We have been running Prebid without problems up to version 3.15.0. When we upgraded to 3.16.0 (and any version after), running it on a site results in the following error:

TypeError: p.getParameterByName is not a function

I've narrowed it down to the change here introduced in 3.16.0 #5092

and in particular changing this in config.js

const DEFAULT_DEBUG = (parseQS(window.location.search)[CONSTANTS.DEBUG_MODE] || '').toUpperCase() === 'TRUE';

to this

const DEFAULT_DEBUG = utils.getParameterByName(CONSTANTS.DEBUG_MODE).toUpperCase() === 'TRUE';

config.js imports utils.js const utils = require('./utils.js'); but utils.js also imports config.js import { config } from './config.js';

If I comment out the import inside utils.js, everything loads fine. If I add the line back in, the error appears.
This circular dependency is causing issues because the DEFAULT_DEBUG is now calling the utils.getParameterByName immediately, but utils hasn't finished loading yet so getParameterByName is not available.

I have not seen anyone else mention this specific error so is there some setting in webpack or babel etc that allows this to work
for others?

We're using prebid with import prebid from 'prebid.js';, as soon as this import is included, the error appears.

Steps to reproduce

Upgrade from Prebid 3.15.0 to 3.16.0
We did not change anything else in our implementation

Test page

N/A

Expected results

Prebid loads as usual on sites

Actual results

This error appears breaking all the ads TypeError: p.getParameterByName is not a function

Platform details

Prebid.js version 3.16.0 and up (have tried with latest 4.17.0)
Chrome 86
Node 10 (have tried v12 as well)
Webpack 4.35
Babel 7

Other information

This is the PR change which seems to have introduced the issue #5092

@cazyw
Copy link
Author

cazyw commented Nov 24, 2020

As a follow-up, we got this working by setting optimization.concatenateModules: false.

Looks like the mix of module formats in prebid.js was causing issues for us.

@stale
Copy link

stale bot commented Dec 25, 2020

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.

@stale stale bot added the stale label Dec 25, 2020
@gglas gglas removed the stale label Jan 13, 2021
@markplewis
Copy link

markplewis commented Jan 15, 2021

I'm also experiencing this issue. We have a React app, so we're using a Webpack dynamic import to pull in the Prebid NPM package and all of the adapter modules that we need (because Prebid requires access to the window object, it can't be imported server-side).

We started with prebid.js version 4.20.0, then tried downgrading to 3.22.0, but the getParameterByName is not a function error didn't disappear until we downgraded to 3.15.0.

Is there a fix planned for version 5, perhaps?

Unfortunately, we're unable to change our Webpack configuration, so we can't apply the optimization.concatenateModules workaround suggested above.

@ChrisHuie ChrisHuie self-assigned this Feb 18, 2021
@ChrisHuie
Copy link
Collaborator

@markplewis are you still working around this issue? I can do a bit more research on this and see what solutions may be possible.

@ChrisHuie
Copy link
Collaborator

If I'm correct concatenateModules in webpack only is True when webpack is set to in production and has to do with figuring out which exports are used versus unused and prioritizing import.

I have a next app setup in a similar configuration but I don't seem to be encountering this so can't provide too much guidance at a more technical level. My Webpack is definitely much more simple.

I think this brings up webpack dead code elimination because that is the main reason for this production prioritization but we are not utilizing the used vs unused distinctions.

@markplewis
Copy link

markplewis commented Mar 11, 2021

Sorry @ChrisHuie, I didn't notice your reply until now. We downgraded to version 3.15.0 and haven't changed anything since. It's working for us now, but it would be nice to be able to upgrade to a newer version eventually. I'll try testing the latest version when a new one is released. Thanks!

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

No branches or pull requests

4 participants