Skip to content

Commit

Permalink
consolidate logic around common chunk inclusions (prebid#4087)
Browse files Browse the repository at this point in the history
  • Loading branch information
snapwich authored and sa1omon committed Nov 28, 2019
1 parent b6defb6 commit e45d733
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 30 deletions.
32 changes: 5 additions & 27 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@

const sharedWhiteList = [
"core-js/library/fn/array/find", // no ie11
"core-js/library/fn/array/includes", // no ie11
"core-js/library/fn/set", // ie11 supports Set but not Set#values
"core-js/library/fn/string/includes", // no ie11
"core-js/library/fn/number/is-integer", // no ie11,
"core-js/library/fn/array/from" // no ie11
];
const allowedModules = require("./allowedModules");

module.exports = {
"env": {
Expand Down Expand Up @@ -45,25 +38,10 @@ module.exports = {
"no-undef": "off",
"no-useless-escape": "off",
},
"overrides": [{
"files": "modules/**/*.js",
"overrides": Object.keys(allowedModules).map((key) => ({
"files": key + "/**/*.js",
"rules": {
"prebid/validate-imports": ["error", [
...sharedWhiteList,
"jsencrypt",
"crypto-js"
]]
"prebid/validate-imports": ["error", allowedModules[key]]
}
}, {
"files": "src/**/*.js",
"rules": {
"prebid/validate-imports": ["error", [
...sharedWhiteList,
"fun-hooks/no-eval",
"just-clone",
"dlv",
"dset"
]]
}
}]
}))
};
24 changes: 24 additions & 0 deletions allowedModules.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

const sharedWhiteList = [
"core-js/library/fn/array/find", // no ie11
"core-js/library/fn/array/includes", // no ie11
"core-js/library/fn/set", // ie11 supports Set but not Set#values
"core-js/library/fn/string/includes", // no ie11
"core-js/library/fn/number/is-integer", // no ie11,
"core-js/library/fn/array/from" // no ie11
];

module.exports = {
'modules': [
...sharedWhiteList,
'jsencrypt',
'crypto-js'
],
'src': [
...sharedWhiteList,
'fun-hooks/no-eval',
'just-clone',
'dlv',
'dset'
]
};
9 changes: 6 additions & 3 deletions webpack.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var helpers = require('./gulpHelpers');
var RequireEnsureWithoutJsonp = require('./plugins/RequireEnsureWithoutJsonp.js');
var { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
var argv = require('yargs').argv;
var allowedModules = require('./allowedModules');

// list of module names to never include in the common bundle chunk
var neverBundle = [
Expand All @@ -26,12 +27,14 @@ plugins.push( // this plugin must be last so it can be easily removed for karma
name: 'prebid',
filename: 'prebid-core.js',
minChunks: function(module) {
return (
return (
(
module.context && module.context === path.resolve('./src') &&
module.context && module.context.startsWith(path.resolve('./src')) &&
!(module.resource && neverBundle.some(name => module.resource.includes(name)))
) ||
module.resource && module.resource.includes(path.resolve('./node_modules/core-js'))
module.resource && (allowedModules.src.concat(['core-js'])).some(
name => module.resource.includes(path.resolve('./node_modules/' + name))
)
);
}
})
Expand Down

0 comments on commit e45d733

Please sign in to comment.