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

consolidate logic around common chunk inclusions #4087

Merged
merged 1 commit into from
Aug 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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