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

Build system: adjust babel configuration to reduce bundle size #8732

Merged
merged 1 commit into from
Jul 26, 2022

Conversation

dgirardi
Copy link
Collaborator

Type of change

  • Build related changes

Description of change

This updates babel configuration to:

  • not polyfill Object.assign (all browers we care about now support it)
  • share other polyfills among source files, instead of redefining them each time they are needed.

The result is ~10KB reduction in prebid-core and ~150KB overall.

Before:

-rw-rw-r-- 1 demetrio demetrio  147195 Jul 22 15:29 build/dist/prebid-core.js
-rw-rw-r-- 1 demetrio demetrio 2455160 Jul 22 15:29 build/dist/prebid.js

After:

-rw-rw-r-- 1 demetrio demetrio  136981 Jul 22 15:27 build/dist/prebid-core.js
-rw-rw-r-- 1 demetrio demetrio 2306056 Jul 22 15:27 build/dist/prebid.js

@ChrisHuie ChrisHuie requested a review from Fawke July 25, 2022 12:02
@ChrisHuie ChrisHuie self-requested a review July 25, 2022 12:02
@ChrisHuie ChrisHuie self-assigned this Jul 25, 2022
@patmmccann patmmccann merged commit ddde310 into prebid:master Jul 26, 2022
@muuki88
Copy link
Collaborator

muuki88 commented Aug 1, 2022

This seems to have broken our typescript build. During runtime we get the following error

Uncaught ReferenceError: exports is not defined

https://stackoverflow.com/questions/43042889/typescript-referenceerror-exports-is-not-defined

I'm trying to chase this down why it happens. Curious if others see this as well.

@muuki88
Copy link
Collaborator

muuki88 commented Aug 1, 2022

I found: webpack/webpack#4039 (comment)

@babel/plugin-transform-runtime, and you are running Babel on CommonJS files (either your own, or in random node_modules, if you're trying to compile that). Babel assumes files are ES modules by default, meaning those transforms would insert import statements into your file, triggering case 1. above

I assume we have to detangle the babel configs in our build.

@muuki88
Copy link
Collaborator

muuki88 commented Aug 1, 2022

Now I found another bug.

if (FEATURES.NATIVE) {
Object.assign(HANDLER_MAP, {
'Prebid Native': handleNativeRequest,
})
}

The FEATURES variable is not imported or required in anyway. Our webpack build with prebid as a npm dependency works, but during runtime we now get

secureCreatives.js:25 Uncaught ReferenceError: FEATURES is not defined
    at ./node_modules/prebid.js/src/secureCreatives.js (secureCreatives.js:25:1)
    at __webpack_require__ (bootstrap:19:1)
    at ./node_modules/prebid.js/src/prebid.js (polyfill.js:18:2)
    at __webpack_require__ (bootstrap:19:1)
    at make namespace object:7:1
    at moli.mjs:41251:3
    at moli.mjs:41253:12

This was introduced in #8219

--- Update

Maybe again related to our webpack build.

@dgirardi dgirardi mentioned this pull request Aug 10, 2022
1 task
JacobKlein26 pushed a commit to nextmillenniummedia/Prebid.js that referenced this pull request Feb 9, 2023
jorgeluisrocha pushed a commit to jwplayer/Prebid.js that referenced this pull request May 23, 2023
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.

6 participants