diff --git a/gulpHelpers.js b/gulpHelpers.js index c0946edf93d..0e44875434f 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,39 +71,74 @@ 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) { // do something } + return memo; }, internalModules)); }), 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/modules/videoModule/constants/enums.js b/libraries/video/constants/enums.js similarity index 100% rename from modules/videoModule/constants/enums.js rename to libraries/video/constants/enums.js diff --git a/modules/videoModule/constants/events.js b/libraries/video/constants/events.js similarity index 100% rename from modules/videoModule/constants/events.js rename to libraries/video/constants/events.js diff --git a/modules/videoModule/constants/ortb.js b/libraries/video/constants/ortb.js similarity index 100% rename from modules/videoModule/constants/ortb.js rename to libraries/video/constants/ortb.js diff --git a/modules/videoModule/constants/vendorCodes.js b/libraries/video/constants/vendorCodes.js similarity index 100% rename from modules/videoModule/constants/vendorCodes.js rename to libraries/video/constants/vendorCodes.js diff --git a/modules/videoModule/coreVideo.js b/libraries/video/coreVideo.js similarity index 100% rename from modules/videoModule/coreVideo.js rename to libraries/video/coreVideo.js diff --git a/modules/videoModule/gamAdServerSubmodule.js b/libraries/video/gamAdServerSubmodule.js similarity index 100% rename from modules/videoModule/gamAdServerSubmodule.js rename to libraries/video/gamAdServerSubmodule.js diff --git a/modules/videoModule/index.js b/libraries/video/index.js similarity index 100% rename from modules/videoModule/index.js rename to libraries/video/index.js diff --git a/modules/videoModule/shared/parentModule.js b/libraries/video/shared/parentModule.js similarity index 100% rename from modules/videoModule/shared/parentModule.js rename to libraries/video/shared/parentModule.js diff --git a/modules/videoModule/shared/state.js b/libraries/video/shared/state.js similarity index 100% rename from modules/videoModule/shared/state.js rename to libraries/video/shared/state.js diff --git a/modules/videoModule/shared/vastXmlBuilder.js b/libraries/video/shared/vastXmlBuilder.js similarity index 100% rename from modules/videoModule/shared/vastXmlBuilder.js rename to libraries/video/shared/vastXmlBuilder.js diff --git a/modules/videoModule/shared/vastXmlEditor.js b/libraries/video/shared/vastXmlEditor.js similarity index 100% rename from modules/videoModule/shared/vastXmlEditor.js rename to libraries/video/shared/vastXmlEditor.js diff --git a/modules/videoModule/videoImpressionVerifier.js b/libraries/video/videoImpressionVerifier.js similarity index 100% rename from modules/videoModule/videoImpressionVerifier.js rename to libraries/video/videoImpressionVerifier.js diff --git a/modules/.submodules.json b/modules/.submodules.json index 3072eb05db5..ddf46fa01df 100644 --- a/modules/.submodules.json +++ b/modules/.submodules.json @@ -1,76 +1,86 @@ { - "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" - ], - "videoModule": [ - "jwplayerVideoProvider" - ] + "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": { + "video": { + "files": [ + "./index.js", "./constants/ortb.js", "./constants/enums.js" + ], + "dependants": [ + "jwplayerVideoProvider", + "testVideoProvider" + ] + } + } } diff --git a/modules/jwplayerVideoProvider.js b/modules/jwplayerVideoProvider.js index c6932e2f670..c51b4a0d8ba 100644 --- a/modules/jwplayerVideoProvider.js +++ b/modules/jwplayerVideoProvider.js @@ -1,9 +1,15 @@ import { PROTOCOLS, API_FRAMEWORKS, VIDEO_MIME_TYPE, PLAYBACK_METHODS, PLACEMENT, VPAID_MIME_TYPE -} from './videoModule/constants/ortb.js'; -import { PLAYBACK_MODE } from './videoModule/constants/enums.js'; -import stateFactory from './videoModule/shared/state.js'; -import { JWPLAYER_VENDOR } from './videoModule/constants/vendorCodes.js'; +} from '../libraries/video/constants/ortb.js'; +import { PLAYBACK_MODE } from '../libraries/video/constants/enums.js'; +import { + SETUP_COMPLETE, SETUP_FAILED, DESTROYED, AD_REQUEST, AD_BREAK_START, AD_LOADED, AD_STARTED, AD_IMPRESSION, AD_PLAY, + AD_TIME, AD_PAUSE, AD_CLICK, AD_SKIPPED, AD_ERROR, AD_COMPLETE, AD_BREAK_END, PLAYLIST, PLAYBACK_REQUEST, + AUTOSTART_BLOCKED, PLAY_ATTEMPT_FAILED, CONTENT_LOADED, PLAY, PAUSE, BUFFER, TIME, SEEK_START, SEEK_END, MUTE, VOLUME, + RENDITION_UPDATE, ERROR, COMPLETE, PLAYLIST_COMPLETE, FULLSCREEN, PLAYER_RESIZE, VIEWABLE, CAST +} from '../libraries/video/constants/events.js'; +import stateFactory from '../libraries/video/shared/state.js'; +import { JWPLAYER_VENDOR } from '../libraries/video/constants/vendorCodes.js'; import { submodule } from '../src/hook.js'; /** @@ -30,13 +36,6 @@ export function JWPlayerProvider(config, jwplayer_, adState_, timeState_, callba let minimumSupportedPlayerVersion = '8.20.1'; let setupCompleteCallback = null; let setupFailedCallback = null; - const prebidVideoEvents = sharedUtils.videoEvents; - const { - SETUP_COMPLETE, SETUP_FAILED, DESTROYED, AD_REQUEST, AD_BREAK_START, AD_LOADED, AD_STARTED, AD_IMPRESSION, AD_PLAY, - AD_TIME, AD_PAUSE, AD_CLICK, AD_SKIPPED, AD_ERROR, AD_COMPLETE, AD_BREAK_END, PLAYLIST, PLAYBACK_REQUEST, - AUTOSTART_BLOCKED, PLAY_ATTEMPT_FAILED, CONTENT_LOADED, PLAY, PAUSE, BUFFER, TIME, SEEK_START, SEEK_END, MUTE, VOLUME, - RENDITION_UPDATE, ERROR, COMPLETE, PLAYLIST_COMPLETE, FULLSCREEN, PLAYER_RESIZE, VIEWABLE, CAST - } = prebidVideoEvents; const MEDIA_TYPES = [ VIDEO_MIME_TYPE.MP4, VIDEO_MIME_TYPE.OGG, @@ -194,7 +193,7 @@ export function JWPlayerProvider(config, jwplayer_, adState_, timeState_, callba function offEvents(events, callback) { events.forEach(event => { - const jwEvent = utils.getJwEvent(event, prebidVideoEvents); + const jwEvent = utils.getJwEvent(event); if (!callback) { player.off(jwEvent); return; @@ -720,42 +719,42 @@ export const utils = { return jwConfig; }, - getJwEvent: function(eventName, prebidVideoEvents) { + getJwEvent: function(eventName) { switch (eventName) { - case prebidVideoEvents.SETUP_COMPLETE: + case SETUP_COMPLETE: return 'ready'; - case prebidVideoEvents.SETUP_FAILED: + case SETUP_FAILED: return 'setupError'; - case prebidVideoEvents.DESTROYED: + case DESTROYED: return 'remove'; - case prebidVideoEvents.AD_STARTED: - return prebidVideoEvents.AD_IMPRESSION; + case AD_STARTED: + return AD_IMPRESSION; - case prebidVideoEvents.AD_IMPRESSION: + case AD_IMPRESSION: return 'adViewableImpression'; - case prebidVideoEvents.PLAYBACK_REQUEST: + case PLAYBACK_REQUEST: return 'playAttempt'; - case prebidVideoEvents.AUTOSTART_BLOCKED: + case AUTOSTART_BLOCKED: return 'autostartNotAllowed'; - case prebidVideoEvents.CONTENT_LOADED: + case CONTENT_LOADED: return 'playlistItem'; - case prebidVideoEvents.SEEK_START: + case SEEK_START: return 'seek'; - case prebidVideoEvents.SEEK_END: + case SEEK_END: return 'seeked'; - case prebidVideoEvents.RENDITION_UPDATE: + case RENDITION_UPDATE: return 'visualQuality'; - case prebidVideoEvents.PLAYER_RESIZE: + case PLAYER_RESIZE: return 'resize'; default: diff --git a/modules/testVideoProvider.js b/modules/testVideoProvider.js new file mode 100644 index 00000000000..3b3166ac8f9 --- /dev/null +++ b/modules/testVideoProvider.js @@ -0,0 +1,26 @@ +import { + PROTOCOLS, API_FRAMEWORKS, VIDEO_MIME_TYPE, PLAYBACK_METHODS, PLACEMENT, VPAID_MIME_TYPE +} from '../libraries/video/constants/ortb.js'; +import { PLAYBACK_MODE } from '../libraries/video/constants/enums.js'; +import { + SETUP_COMPLETE, SETUP_FAILED, DESTROYED, AD_REQUEST, AD_BREAK_START, AD_LOADED, AD_STARTED, AD_IMPRESSION, AD_PLAY, + AD_TIME, AD_PAUSE, AD_CLICK, AD_SKIPPED, AD_ERROR, AD_COMPLETE, AD_BREAK_END, PLAYLIST, PLAYBACK_REQUEST, + AUTOSTART_BLOCKED, PLAY_ATTEMPT_FAILED, CONTENT_LOADED, PLAY, PAUSE, BUFFER, TIME, SEEK_START, SEEK_END, MUTE, VOLUME, + RENDITION_UPDATE, ERROR, COMPLETE, PLAYLIST_COMPLETE, FULLSCREEN, PLAYER_RESIZE, VIEWABLE, CAST +} from '../libraries/video/constants/events.js'; +import stateFactory from '../libraries/video/shared/state.js'; +import { VIDEO_JS_VENDOR } from '../libraries/video/constants/vendorCodes.js'; +import { submodule } from '../src/hook.js'; +import {registerBidder} from '../src/adapters/bidderFactory.js'; + +export function testProvider() { + const state = stateFactory(); + state.updateState(PROTOCOLS, API_FRAMEWORKS, VIDEO_MIME_TYPE, PLAYBACK_METHODS, PLACEMENT, VPAID_MIME_TYPE, SETUP_COMPLETE, SETUP_FAILED, DESTROYED, AD_REQUEST, AD_BREAK_START, AD_LOADED, AD_STARTED, AD_IMPRESSION, AD_PLAY, + AD_TIME, AD_PAUSE, AD_CLICK, AD_SKIPPED, AD_ERROR, AD_COMPLETE, AD_BREAK_END, PLAYLIST, PLAYBACK_REQUEST, + AUTOSTART_BLOCKED, PLAY_ATTEMPT_FAILED, CONTENT_LOADED, PLAY, PAUSE, BUFFER, TIME, SEEK_START, SEEK_END, MUTE, VOLUME, + RENDITION_UPDATE, ERROR, COMPLETE, PLAYLIST_COMPLETE, FULLSCREEN, PLAYER_RESIZE, VIEWABLE, CAST, registerBidder, PLAYBACK_MODE); +} + +testProvider.code = VIDEO_JS_VENDOR; + +submodule('videoModule', testProvider); diff --git a/test/spec/modules/videoModule/coreVideo_spec.js b/test/spec/modules/videoModule/coreVideo_spec.js index 40e424caf99..4926c165af1 100644 --- a/test/spec/modules/videoModule/coreVideo_spec.js +++ b/test/spec/modules/videoModule/coreVideo_spec.js @@ -1,5 +1,5 @@ import { expect } from 'chai'; -import { VideoCore } from 'modules/videoModule/coreVideo.js'; +import { VideoCore } from 'libraries/video/coreVideo.js'; describe('Video Core', function () { const mockSubmodule = { diff --git a/test/spec/modules/videoModule/pbVideo_spec.js b/test/spec/modules/videoModule/pbVideo_spec.js index e0ffba2494b..da925c55c93 100644 --- a/test/spec/modules/videoModule/pbVideo_spec.js +++ b/test/spec/modules/videoModule/pbVideo_spec.js @@ -1,7 +1,7 @@ import { expect } from 'chai'; -import { PbVideo } from 'modules/videoModule/index.js'; +import { PbVideo } from 'libraries/video/index.js'; import CONSTANTS from 'src/constants.json'; -import { AD_IMPRESSION, AD_ERROR, BID_IMPRESSION, BID_ERROR } from 'modules/videoModule/constants/events.js'; +import { AD_IMPRESSION, AD_ERROR, BID_IMPRESSION, BID_ERROR } from 'libraries/video/constants/events.js'; let ortbParamsMock; let videoCoreMock; diff --git a/test/spec/modules/videoModule/shared/parentModule_spec.js b/test/spec/modules/videoModule/shared/parentModule_spec.js index c9f7e453689..1e8e7fda380 100644 --- a/test/spec/modules/videoModule/shared/parentModule_spec.js +++ b/test/spec/modules/videoModule/shared/parentModule_spec.js @@ -1,4 +1,4 @@ -import { SubmoduleBuilder, ParentModule } from 'modules/videoModule/shared/parentModule.js'; +import { SubmoduleBuilder, ParentModule } from 'libraries/video/shared/parentModule.js'; import { expect } from 'chai'; describe('Parent Module', function() { diff --git a/test/spec/modules/videoModule/shared/state_spec.js b/test/spec/modules/videoModule/shared/state_spec.js index 6cce97ab0a0..bbd0a35b57e 100644 --- a/test/spec/modules/videoModule/shared/state_spec.js +++ b/test/spec/modules/videoModule/shared/state_spec.js @@ -1,4 +1,4 @@ -import stateFactory from 'modules/videoModule/shared/state.js'; +import stateFactory from 'libraries/video/shared/state.js'; import { expect } from 'chai'; describe('State', function () { diff --git a/test/spec/modules/videoModule/shared/vastXmlBuilder_spec.js b/test/spec/modules/videoModule/shared/vastXmlBuilder_spec.js index 1007e3898c2..2c67b898a53 100644 --- a/test/spec/modules/videoModule/shared/vastXmlBuilder_spec.js +++ b/test/spec/modules/videoModule/shared/vastXmlBuilder_spec.js @@ -1,5 +1,5 @@ import { buildVastWrapper, getVastNode, getAdNode, getWrapperNode, getAdSystemNode, - getAdTagUriNode, getErrorNode, getImpressionNode } from 'modules/videoModule/shared/vastXmlBuilder.js'; + getAdTagUriNode, getErrorNode, getImpressionNode } from 'libraries/video/shared/vastXmlBuilder.js'; import { expect } from 'chai'; describe('buildVastWrapper', function () { diff --git a/test/spec/modules/videoModule/shared/vastXmlEditor_spec.js b/test/spec/modules/videoModule/shared/vastXmlEditor_spec.js index 087ac93d7bc..2304b2f2833 100644 --- a/test/spec/modules/videoModule/shared/vastXmlEditor_spec.js +++ b/test/spec/modules/videoModule/shared/vastXmlEditor_spec.js @@ -1,4 +1,4 @@ -import { vastXmlEditorFactory } from 'modules/videoModule/shared/vastXmlEditor.js'; +import { vastXmlEditorFactory } from 'libraries/video/shared/vastXmlEditor.js'; import { expect } from 'chai'; describe('Vast XML Editor', function () { diff --git a/test/spec/modules/videoModule/submodules/jwplayerVideoProvider_spec.js b/test/spec/modules/videoModule/submodules/jwplayerVideoProvider_spec.js index bfaa7f398b8..0a1d34679da 100644 --- a/test/spec/modules/videoModule/submodules/jwplayerVideoProvider_spec.js +++ b/test/spec/modules/videoModule/submodules/jwplayerVideoProvider_spec.js @@ -8,13 +8,13 @@ import { import { PROTOCOLS, API_FRAMEWORKS, VIDEO_MIME_TYPE, PLAYBACK_METHODS, PLACEMENT, VPAID_MIME_TYPE -} from 'modules/videoModule/constants/ortb.js'; +} from 'libraries/video/constants/ortb.js'; import { SETUP_COMPLETE, SETUP_FAILED, PLAY, AD_IMPRESSION, videoEvents -} from 'modules/videoModule/constants/events.js'; +} from 'libraries/video/constants/events.js'; -import { PLAYBACK_MODE } from 'modules/videoModule/constants/enums.js'; +import { PLAYBACK_MODE } from 'libraries/video/constants/enums.js'; function getPlayerMock() { return makePlayerFactoryMock({ diff --git a/test/spec/modules/videoModule/videoImpressionVerifier_spec.js b/test/spec/modules/videoModule/videoImpressionVerifier_spec.js index 58109219a37..cfce7933895 100644 --- a/test/spec/modules/videoModule/videoImpressionVerifier_spec.js +++ b/test/spec/modules/videoModule/videoImpressionVerifier_spec.js @@ -1,4 +1,4 @@ -import { baseImpressionVerifier, PB_PREFIX } from 'modules/videoModule/videoImpressionVerifier.js'; +import { baseImpressionVerifier, PB_PREFIX } from 'libraries/video/videoImpressionVerifier.js'; let trackerMock; trackerMock = { 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;