From ab3b71cb468a6b6f50d8e124312708cfbbdbd456 Mon Sep 17 00:00:00 2001 From: Karim Mourra Date: Mon, 6 Jun 2022 15:41:31 -0400 Subject: [PATCH 1/6] adds extra utils --- libraries/ExtraUtils/utils.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 libraries/ExtraUtils/utils.js diff --git a/libraries/ExtraUtils/utils.js b/libraries/ExtraUtils/utils.js new file mode 100644 index 00000000000..c37a913db07 --- /dev/null +++ b/libraries/ExtraUtils/utils.js @@ -0,0 +1,11 @@ +/** + * Returns the origin + */ +export function getOrigin() { + // IE10 does not have this property. https://gist.github.com/hbogs/7908703 + if (!window.location.origin) { + return window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : ''); + } else { + return window.location.origin; + } +} From 98ce2ea8572ffa6bf65736093043414f28f69315 Mon Sep 17 00:00:00 2001 From: Karim Mourra Date: Mon, 6 Jun 2022 15:47:27 -0400 Subject: [PATCH 2/6] imports from extra utils --- libraries/{ExtraUtils => extraUtils}/utils.js | 0 modules/ooloAnalyticsAdapter.js | 3 ++- modules/resetdigitalBidAdapter.js | 3 ++- modules/rtbhouseBidAdapter.js | 3 ++- 4 files changed, 6 insertions(+), 3 deletions(-) rename libraries/{ExtraUtils => extraUtils}/utils.js (100%) diff --git a/libraries/ExtraUtils/utils.js b/libraries/extraUtils/utils.js similarity index 100% rename from libraries/ExtraUtils/utils.js rename to libraries/extraUtils/utils.js diff --git a/modules/ooloAnalyticsAdapter.js b/modules/ooloAnalyticsAdapter.js index 398459d604d..b6905024e22 100644 --- a/modules/ooloAnalyticsAdapter.js +++ b/modules/ooloAnalyticsAdapter.js @@ -1,4 +1,5 @@ -import { _each, deepClone, pick, deepSetValue, getOrigin, logError, logInfo } from '../src/utils.js'; +import { _each, deepClone, pick, deepSetValue, logError, logInfo } from '../src/utils.js'; +import { getOrigin } from '../libraries/extraUtils/utils.js'; import adapter from '../src/AnalyticsAdapter.js' import adapterManager from '../src/adapterManager.js' import CONSTANTS from '../src/constants.json' diff --git a/modules/resetdigitalBidAdapter.js b/modules/resetdigitalBidAdapter.js index 255ee32629c..2e1f073c5be 100644 --- a/modules/resetdigitalBidAdapter.js +++ b/modules/resetdigitalBidAdapter.js @@ -1,5 +1,6 @@ -import { timestamp, deepAccess, getOrigin } from '../src/utils.js'; +import { timestamp, deepAccess } from '../src/utils.js'; +import { getOrigin } from '../libraries/extraUtils/utils.js'; import { config } from '../src/config.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'resetdigital'; diff --git a/modules/rtbhouseBidAdapter.js b/modules/rtbhouseBidAdapter.js index b8436179a30..f69a68e2f0d 100644 --- a/modules/rtbhouseBidAdapter.js +++ b/modules/rtbhouseBidAdapter.js @@ -1,4 +1,5 @@ -import {deepAccess, getOrigin, isArray, logError} from '../src/utils.js'; +import {deepAccess, isArray, logError} from '../src/utils.js'; +import { getOrigin } from '../libraries/extraUtils/utils.js'; import {BANNER, NATIVE} from '../src/mediaTypes.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {includes} from '../src/polyfill.js'; From 123c00e300c91e0acfbf0f31f73820dfd87411b8 Mon Sep 17 00:00:00 2001 From: Karim Mourra Date: Mon, 6 Jun 2022 15:49:32 -0400 Subject: [PATCH 3/6] adds libraries to .submodules --- modules/.submodules.json | 158 +++++++++++++++++++++------------------ src/utils.js | 11 --- 2 files changed, 85 insertions(+), 84 deletions(-) diff --git a/modules/.submodules.json b/modules/.submodules.json index 8d62f30d7c4..1813899d723 100644 --- a/modules/.submodules.json +++ b/modules/.submodules.json @@ -1,75 +1,87 @@ { - "userId": [ - "33acrossIdSystem", - "admixerIdSystem", - "adtelligentIdSystem", - "akamaiDAPIdSystem", - "amxIdSystem", - "britepoolIdSystem", - "connectIdSystem", - "cpexIdSystem", - "criteoIdSystem", - "dacIdSystem", - "deepintentDpesIdSystem", - "dmdIdSystem", - "fabrickIdSystem", - "flocIdSystem", - "hadronIdSystem", - "haloIdSystem", - "id5IdSystem", - "ftrackIdSystem", - "identityLinkIdSystem", - "idxIdSystem", - "imuIdSystem", - "intentIqIdSystem", - "justIdSystem", - "kinessoIdSystem", - "liveIntentIdSystem", - "lotamePanoramaIdSystem", - "merkleIdSystem", - "mwOpenLinkIdSystem", - "naveggIdSystem", - "netIdSystem", - "nextrollIdSystem", - "novatiqIdSystem", - "parrableIdSystem", - "pubProvidedIdSystem", - "publinkIdSystem", - "quantcastIdSystem", - "sharedIdSystem", - "tapadIdSystem", - "trustpidSystem", - "uid2IdSystem", - "unifiedIdSystem", - "verizonMediaIdSystem", - "zeotapIdPlusIdSystem", - "adqueryIdSystem", - "gravitoIdSystem" - ], - "adpod": [ - "freeWheelAdserverVideo", - "dfpAdServerVideo" - ], - "rtdModule": [ - "airgridRtdProvider", - "akamaiDapRtdProvider", - "browsiRtdProvider", - "dgkeywordRtdProvider", - "geoedgeRtdProvider", - "hadronRtdProvider", - "haloRtdProvider", - "iasRtdProvider", - "jwplayerRtdProvider", - "medianetRtdProvider", - "optimeraRtdProvider", - "permutiveRtdProvider", - "reconciliationRtdProvider", - "sirdataRtdProvider", - "timeoutRtdProvider", - "weboramaRtdProvider" - ], - "fpdModule": [ - "enrichmentFpdModule", - "validationFpdModule" - ] + "parentModules": { + "userId": [ + "33acrossIdSystem", + "admixerIdSystem", + "adtelligentIdSystem", + "akamaiDAPIdSystem", + "amxIdSystem", + "britepoolIdSystem", + "connectIdSystem", + "cpexIdSystem", + "criteoIdSystem", + "dacIdSystem", + "deepintentDpesIdSystem", + "dmdIdSystem", + "fabrickIdSystem", + "flocIdSystem", + "hadronIdSystem", + "haloIdSystem", + "id5IdSystem", + "ftrackIdSystem", + "identityLinkIdSystem", + "idxIdSystem", + "imuIdSystem", + "intentIqIdSystem", + "justIdSystem", + "kinessoIdSystem", + "liveIntentIdSystem", + "lotamePanoramaIdSystem", + "merkleIdSystem", + "mwOpenLinkIdSystem", + "naveggIdSystem", + "netIdSystem", + "nextrollIdSystem", + "novatiqIdSystem", + "parrableIdSystem", + "pubProvidedIdSystem", + "publinkIdSystem", + "quantcastIdSystem", + "sharedIdSystem", + "tapadIdSystem", + "trustpidSystem", + "uid2IdSystem", + "unifiedIdSystem", + "verizonMediaIdSystem", + "zeotapIdPlusIdSystem", + "adqueryIdSystem" + ], + "adpod": [ + "freeWheelAdserverVideo", + "dfpAdServerVideo" + ], + "rtdModule": [ + "airgridRtdProvider", + "browsiRtdProvider", + "dgkeywordRtdProvider", + "geoedgeRtdProvider", + "hadronRtdProvider", + "haloRtdProvider", + "iasRtdProvider", + "jwplayerRtdProvider", + "medianetRtdProvider", + "optimeraRtdProvider", + "permutiveRtdProvider", + "reconciliationRtdProvider", + "sirdataRtdProvider", + "timeoutRtdProvider", + "weboramaRtdProvider" + ], + "fpdModule": [ + "enrichmentFpdModule", + "validationFpdModule" + ] + }, + "libraries": { + "extraUtils": { + "files": [ + "./utils.js" + ], + "dependants": [ + "ooloAnalyticsAdapter", + "resetdigitalBidAdapter", + "rtbhouseBidAdapter.js" + ] + } + } } diff --git a/src/utils.js b/src/utils.js index 3e96e427e2c..ede171936cc 100644 --- a/src/utils.js +++ b/src/utils.js @@ -925,17 +925,6 @@ export function getUserConfiguredParams(adUnits, adUnitCode, bidder) { .filter((bidderData) => bidderData.bidder === bidder) .map((bidderData) => bidderData.params || {}); } -/** - * Returns the origin - */ -export function getOrigin() { - // IE10 does not have this property. https://gist.github.com/hbogs/7908703 - if (!window.location.origin) { - return window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : ''); - } else { - return window.location.origin; - } -} /** * Returns Do Not Track state From b324d906a9954865d548f06eb9a74c7b9973a96b Mon Sep 17 00:00:00 2001 From: Karim Mourra Date: Mon, 6 Jun 2022 16:14:07 -0400 Subject: [PATCH 4/6] adds libraries to build process --- gulpHelpers.js | 69 ++++++++++++++++----- gulpfile.js | 1 + libraries/extraUtils/{utils.js => index.js} | 0 modules/.submodules.json | 2 +- modules/ooloAnalyticsAdapter.js | 2 +- modules/resetdigitalBidAdapter.js | 2 +- modules/rtbhouseBidAdapter.js | 2 +- webpack.conf.js | 15 ++++- 8 files changed, 72 insertions(+), 21 deletions(-) rename libraries/extraUtils/{utils.js => index.js} (100%) diff --git a/gulpHelpers.js b/gulpHelpers.js index c0946edf93d..020b1e8fb1a 100644 --- a/gulpHelpers.js +++ b/gulpHelpers.js @@ -6,9 +6,12 @@ const MANIFEST = 'package.json'; const through = require('through2'); const _ = require('lodash'); const gutil = require('gulp-util'); -const submodules = require('./modules/.submodules.json'); +const dependencyMap = require('./modules/.submodules.json'); +const submodules = dependencyMap.parentModules; +const libraries = dependencyMap.libraries; const MODULE_PATH = './modules'; +const LIBRARY_PATH = './libraries'; const BUILD_PATH = './build/dist'; const DEV_PATH = './build/dev'; const ANALYTICS_PATH = '../analytics'; @@ -68,34 +71,68 @@ module.exports = { } }); + Object.keys(libraries).forEach(library => { + if (!modules.includes(library) && modules.some(module => libraries[library].dependants.includes(module))) { + modules.unshift(library); + } + }); + return modules; }, + getParentLibraries(moduleName) { + const libraryNames = []; + Object.keys(libraries).forEach(libraryName => { + const library = libraries[libraryName]; + if (library.dependants.includes(moduleName)) { + libraryNames.push(libraryName); + } + }); + return libraryNames; + }, + getLibraryFiles(name) { + const library = libraries[name]; + const files = library.files.map(file => require.resolve(file, {paths: ['./libraries/' + name + '/']})); + return files; + }, + isLibrary(name) { + return !!libraries[name]; + }, getModules: _.memoize(function(externalModules) { externalModules = externalModules || []; var internalModules; try { + var getInternalModules = function(absolutePath) { + return fs.readdirSync(absolutePath) + .filter(file => (/^[^\.]+(\.js)?$/).test(file)) + .reduce((memo, file) => { + var moduleName = file.split(new RegExp('[.\\' + path.sep + ']'))[0]; + var modulePath = path.join(absolutePath, file); + if (fs.lstatSync(modulePath).isDirectory()) { + modulePath = path.join(modulePath, 'index.js') + } + if (fs.existsSync(modulePath)) { + memo[modulePath] = moduleName; + } + return memo; + }, {}); + }; + var absoluteModulePath = path.join(__dirname, MODULE_PATH); - internalModules = fs.readdirSync(absoluteModulePath) - .filter(file => (/^[^\.]+(\.js)?$/).test(file)) - .reduce((memo, file) => { - var moduleName = file.split(new RegExp('[.\\' + path.sep + ']'))[0]; - var modulePath = path.join(absoluteModulePath, file); - if (fs.lstatSync(modulePath).isDirectory()) { - modulePath = path.join(modulePath, 'index.js') - } - if (fs.existsSync(modulePath)) { - memo[modulePath] = moduleName; - } - return memo; - }, {}); + var absoluteLibraryPath = path.join(__dirname, LIBRARY_PATH); + + internalModules = getInternalModules(absoluteModulePath); + var internalLibraries = getInternalModules(absoluteLibraryPath); + Object.assign(internalModules, internalLibraries); } catch (err) { internalModules = {}; } return Object.assign(externalModules.reduce((memo, module) => { try { // prefer internal project modules before looking at project dependencies - var modulePath = require.resolve(module, {paths: ['./modules']}); - if (modulePath === '') modulePath = require.resolve(module); + var modulePath = require.resolve(module, {paths: [MODULE_PATH, LIBRARY_PATH]}); + if (modulePath === '') { + modulePath = require.resolve(module); + } memo[modulePath] = module; } catch (err) { diff --git a/gulpfile.js b/gulpfile.js index ff49436384b..6abc40f11f5 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -73,6 +73,7 @@ function lint(done) { return gulp.src([ 'src/**/*.js', 'modules/**/*.js', + 'libraries/**/*.js', 'test/**/*.js', 'plugins/**/*.js', '!plugins/**/node_modules/**', diff --git a/libraries/extraUtils/utils.js b/libraries/extraUtils/index.js similarity index 100% rename from libraries/extraUtils/utils.js rename to libraries/extraUtils/index.js diff --git a/modules/.submodules.json b/modules/.submodules.json index 1813899d723..aad37a0039f 100644 --- a/modules/.submodules.json +++ b/modules/.submodules.json @@ -75,7 +75,7 @@ "libraries": { "extraUtils": { "files": [ - "./utils.js" + "./index.js" ], "dependants": [ "ooloAnalyticsAdapter", diff --git a/modules/ooloAnalyticsAdapter.js b/modules/ooloAnalyticsAdapter.js index b6905024e22..5c7248c84e3 100644 --- a/modules/ooloAnalyticsAdapter.js +++ b/modules/ooloAnalyticsAdapter.js @@ -1,5 +1,5 @@ import { _each, deepClone, pick, deepSetValue, logError, logInfo } from '../src/utils.js'; -import { getOrigin } from '../libraries/extraUtils/utils.js'; +import { getOrigin } from '../libraries/extraUtils/index.js'; import adapter from '../src/AnalyticsAdapter.js' import adapterManager from '../src/adapterManager.js' import CONSTANTS from '../src/constants.json' diff --git a/modules/resetdigitalBidAdapter.js b/modules/resetdigitalBidAdapter.js index 2e1f073c5be..a9ccb4ffd00 100644 --- a/modules/resetdigitalBidAdapter.js +++ b/modules/resetdigitalBidAdapter.js @@ -1,6 +1,6 @@ import { timestamp, deepAccess } from '../src/utils.js'; -import { getOrigin } from '../libraries/extraUtils/utils.js'; +import { getOrigin } from '../libraries/extraUtils/index.js'; import { config } from '../src/config.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'resetdigital'; diff --git a/modules/rtbhouseBidAdapter.js b/modules/rtbhouseBidAdapter.js index f69a68e2f0d..180e3c289b4 100644 --- a/modules/rtbhouseBidAdapter.js +++ b/modules/rtbhouseBidAdapter.js @@ -1,5 +1,5 @@ import {deepAccess, isArray, logError} from '../src/utils.js'; -import { getOrigin } from '../libraries/extraUtils/utils.js'; +import { getOrigin } from '../libraries/extraUtils/index.js'; import {BANNER, NATIVE} from '../src/mediaTypes.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {includes} from '../src/polyfill.js'; diff --git a/webpack.conf.js b/webpack.conf.js index 5269f5300f5..f849f71a0fb 100644 --- a/webpack.conf.js +++ b/webpack.conf.js @@ -31,12 +31,25 @@ module.exports = { } }; const selectedModules = new Set(helpers.getArgModules()); + Object.entries(helpers.getModules()).forEach(([fn, mod]) => { if (selectedModules.size === 0 || selectedModules.has(mod)) { - entry[mod] = { + const moduleEntry = { import: fn, dependOn: 'prebid-core' + }; + + if (helpers.isLibrary(mod)) { + const libraryFiles = helpers.getLibraryFiles(mod); + moduleEntry.import = libraryFiles || moduleEntry.import; } + + const libraries = helpers.getParentLibraries(mod); + if (libraries.length) { + moduleEntry.dependOn = ['prebid-core'].concat(libraries); + } + + entry[mod] = moduleEntry; } }); return entry; From 93b23f50a152c60808f5a2bdef28dbfbc268e1e4 Mon Sep 17 00:00:00 2001 From: Karim Mourra Date: Tue, 7 Jun 2022 12:39:54 -0400 Subject: [PATCH 5/6] renames extraUtils --- libraries/{extraUtils => getOrigin}/index.js | 0 modules/.submodules.json | 2 +- modules/ooloAnalyticsAdapter.js | 2 +- modules/resetdigitalBidAdapter.js | 2 +- modules/rtbhouseBidAdapter.js | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) rename libraries/{extraUtils => getOrigin}/index.js (100%) diff --git a/libraries/extraUtils/index.js b/libraries/getOrigin/index.js similarity index 100% rename from libraries/extraUtils/index.js rename to libraries/getOrigin/index.js diff --git a/modules/.submodules.json b/modules/.submodules.json index aad37a0039f..a6ff418e9a3 100644 --- a/modules/.submodules.json +++ b/modules/.submodules.json @@ -73,7 +73,7 @@ ] }, "libraries": { - "extraUtils": { + "getOrigin": { "files": [ "./index.js" ], diff --git a/modules/ooloAnalyticsAdapter.js b/modules/ooloAnalyticsAdapter.js index 5c7248c84e3..6f9d5620d53 100644 --- a/modules/ooloAnalyticsAdapter.js +++ b/modules/ooloAnalyticsAdapter.js @@ -1,5 +1,5 @@ import { _each, deepClone, pick, deepSetValue, logError, logInfo } from '../src/utils.js'; -import { getOrigin } from '../libraries/extraUtils/index.js'; +import { getOrigin } from '../libraries/getOrigin/index.js'; import adapter from '../src/AnalyticsAdapter.js' import adapterManager from '../src/adapterManager.js' import CONSTANTS from '../src/constants.json' diff --git a/modules/resetdigitalBidAdapter.js b/modules/resetdigitalBidAdapter.js index a9ccb4ffd00..62434b88ccb 100644 --- a/modules/resetdigitalBidAdapter.js +++ b/modules/resetdigitalBidAdapter.js @@ -1,6 +1,6 @@ import { timestamp, deepAccess } from '../src/utils.js'; -import { getOrigin } from '../libraries/extraUtils/index.js'; +import { getOrigin } from '../libraries/getOrigin/index.js'; import { config } from '../src/config.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; const BIDDER_CODE = 'resetdigital'; diff --git a/modules/rtbhouseBidAdapter.js b/modules/rtbhouseBidAdapter.js index 180e3c289b4..f4bd1d06fd7 100644 --- a/modules/rtbhouseBidAdapter.js +++ b/modules/rtbhouseBidAdapter.js @@ -1,5 +1,5 @@ import {deepAccess, isArray, logError} from '../src/utils.js'; -import { getOrigin } from '../libraries/extraUtils/index.js'; +import { getOrigin } from '../libraries/getOrigin/index.js'; import {BANNER, NATIVE} from '../src/mediaTypes.js'; import {registerBidder} from '../src/adapters/bidderFactory.js'; import {includes} from '../src/polyfill.js'; From 6c667601f77f31b54ac12dda4454701c0e602598 Mon Sep 17 00:00:00 2001 From: Karim Mourra Date: Thu, 9 Jun 2022 15:43:49 -0400 Subject: [PATCH 6/6] update userId submodules list --- modules/.submodules.json | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/modules/.submodules.json b/modules/.submodules.json index a6ff418e9a3..daa8b1421ce 100644 --- a/modules/.submodules.json +++ b/modules/.submodules.json @@ -4,7 +4,6 @@ "33acrossIdSystem", "admixerIdSystem", "adtelligentIdSystem", - "akamaiDAPIdSystem", "amxIdSystem", "britepoolIdSystem", "connectIdSystem", @@ -14,9 +13,7 @@ "deepintentDpesIdSystem", "dmdIdSystem", "fabrickIdSystem", - "flocIdSystem", "hadronIdSystem", - "haloIdSystem", "id5IdSystem", "ftrackIdSystem", "identityLinkIdSystem", @@ -31,7 +28,6 @@ "mwOpenLinkIdSystem", "naveggIdSystem", "netIdSystem", - "nextrollIdSystem", "novatiqIdSystem", "parrableIdSystem", "pubProvidedIdSystem", @@ -44,7 +40,8 @@ "unifiedIdSystem", "verizonMediaIdSystem", "zeotapIdPlusIdSystem", - "adqueryIdSystem" + "adqueryIdSystem", + "gravitoIdSystem" ], "adpod": [ "freeWheelAdserverVideo", @@ -52,6 +49,7 @@ ], "rtdModule": [ "airgridRtdProvider", + "akamaiDapRtdProvider", "browsiRtdProvider", "dgkeywordRtdProvider", "geoedgeRtdProvider",