diff --git a/gulpfile.js b/gulpfile.js index f3d44243ef8..17c421f4dc1 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -295,8 +295,7 @@ function bundle(dev, moduleArr) { [coreFile].concat(moduleFiles).map(name => path.basename(name)).forEach((file) => { (depGraph[file] || []).forEach((dep) => dependencies.add(helpers.getBuiltPath(dev, dep))); }); - - const entries = [coreFile].concat(Array.from(dependencies), moduleFiles); + const entries = _.uniq([coreFile].concat(Array.from(dependencies), moduleFiles)); var outputFileName = argv.bundleName ? argv.bundleName : 'prebid.js'; diff --git a/modules/fledgeForGpt.js b/modules/fledgeForGpt.js index 7e841234e24..bda4494faaf 100644 --- a/modules/fledgeForGpt.js +++ b/modules/fledgeForGpt.js @@ -7,6 +7,11 @@ import {getGptSlotForAdUnitCode} from '../libraries/gptUtils/gptUtils.js'; import {config} from '../src/config.js'; import {getGlobal} from '../src/prebidGlobal.js'; +// import parent module to keep backwards-compat for NPM consumers after paapi was split from fledgeForGpt +// there's a special case in webpack.conf.js to avoid duplicating build output on non-npm builds +// TODO: remove this in prebid 9 +// eslint-disable-next-line prebid/validate-imports +import './paapi.js'; const MODULE = 'fledgeForGpt'; let getPAAPIConfig; diff --git a/webpack.conf.js b/webpack.conf.js index 0ead550e446..8d29c786595 100644 --- a/webpack.conf.js +++ b/webpack.conf.js @@ -128,10 +128,31 @@ module.exports = { return [lib, def]; }) ); + const core = path.resolve('./src'); + const paapiMod = path.resolve('./modules/paapi.js'); + const nodeModules = path.resolve('./node_modules'); + return Object.assign(libraries, { + core: { + name: 'chunk-core', + test: (module) => { + return module.resource?.startsWith(core) || module.resource?.startsWith(nodeModules); + } + }, + paapi: { + // fledgeForGpt imports paapi to keep backwards compat for NPM consumers + // this makes the paapi module its own chunk, pulled in by both paapi and fledgeForGpt entry points, + // to avoid duplication + // TODO: remove this in prebid 9 + name: 'chunk-paapi', + test: (module) => { + return module.resource === paapiMod; + } + } + }, { default: false, defaultVendors: false - }) + }); })() } },