diff --git a/package.json b/package.json index f297abd4..07960d72 100644 --- a/package.json +++ b/package.json @@ -59,6 +59,11 @@ "prettier --write" ] }, + "dependencies": { + "babel-runtime": "^6.26.0", + "lodash.debounce": "^4.0.8", + "sane-domparser-error": "^0.2.0" + }, "devDependencies": { "@commitlint/cli": "^7.0.0", "@commitlint/travis-cli": "^7.0.0", @@ -84,7 +89,6 @@ "jest-environment-jsdom": "^23.4.0", "jsdoc": "^3.5.5", "lint-staged": "^10.5.4", - "lodash.debounce": "^4.0.8", "mini-css-extract-plugin": "^0.4.5", "mockdate": "^2.0.2", "mol-commitlint-config": "^1.1.0", @@ -98,12 +102,10 @@ "rollup-plugin-node-resolve": "^3.3.0", "rollup-plugin-sourcemaps": "^0.4.2", "rollup-plugin-terser": "^1.0.1", - "sane-domparser-error": "^0.2.0", "semantic-release": "^15.12.1", "terser-webpack-plugin": "^1.1.0", "webpack": "^4.16.5", "webpack-cli": "^3.1.0", - "webpack-dev-server": "^3.1.5", - "whatwg-fetch": "^2.0.4" + "webpack-dev-server": "^3.1.5" } } diff --git a/rollup.config.js b/rollup.config.js index 37b6fcda..4afa5abc 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -12,23 +12,15 @@ const production = process.env.NODE_ENV === 'production'; const plugins = [ sourcemaps(), babel({ - exclude: [ - '../../node_modules/**', - 'node_modules/**' - ], + exclude: ['../../node_modules/**', 'node_modules/**'], plugins: ['external-helpers'] }), - resolve({ - customResolveOptions: { - moduleDirectory: [ - 'node_modules', - '../../node_modules' - ] - } - }), commonjs() ]; +// NOTE: don't include external dependencies into esm/cjm bundles +const external = ['babel-runtime/regenerator', 'lodash.debounce', 'sane-domparser-error']; + // NOTE: see https://github.com/rollup/rollup/issues/408 to understand why we silences `THIS_IS_UNDEFINED` warnings const onwarn = (warning, warn) => { if (warning.code === 'THIS_IS_UNDEFINED') { @@ -49,6 +41,11 @@ const config = [ }, plugins: [ ...plugins, + resolve({ + customResolveOptions: { + moduleDirectory: ['node_modules', '../../node_modules'] + } + }), production && terser() ] }, @@ -60,7 +57,8 @@ const config = [ file: pkg.module, format: 'es' }, - plugins + plugins, + external }, { input: 'src/index.js', @@ -70,7 +68,8 @@ const config = [ file: pkg.main, format: 'cjs' }, - plugins + plugins, + external } ]; diff --git a/src/adUnit/helpers/fetch/fetchHtml.js b/src/adUnit/helpers/fetch/fetchHtml.js index 6180a442..2d07e991 100644 --- a/src/adUnit/helpers/fetch/fetchHtml.js +++ b/src/adUnit/helpers/fetch/fetchHtml.js @@ -1,13 +1,7 @@ -// eslint-disable-next-line import/no-unassigned-import -import 'whatwg-fetch'; - const isValidContentType = (contentType) => { const normalisedCT = contentType.toLowerCase(); - return [ - 'text/plain', - 'text/html' - ].some((allowedType) => normalisedCT.includes(allowedType)); + return ['text/plain', 'text/html'].some((allowedType) => normalisedCT.includes(allowedType)); }; const fetchHtml = async (endpoint) => { diff --git a/src/vastRequest/helpers/fetch.js b/src/vastRequest/helpers/fetch.js index c7a37333..17a054f8 100644 --- a/src/vastRequest/helpers/fetch.js +++ b/src/vastRequest/helpers/fetch.js @@ -1,6 +1,3 @@ -/* eslint-disable filenames/match-exported, import/no-unassigned-import */ -import 'whatwg-fetch'; - const fetch = async (endpoint, options = {}) => { const defaults = { credentials: 'include' diff --git a/yarn.lock b/yarn.lock index 1fc78353..4fb7a2e5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -10344,10 +10344,6 @@ whatwg-encoding@^1.0.1, whatwg-encoding@^1.0.3: dependencies: iconv-lite "0.4.24" -whatwg-fetch@^2.0.4: - version "2.0.4" - resolved "http://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz#dde6a5df315f9d39991aa17621853d720b85566f" - whatwg-mimetype@^2.1.0, whatwg-mimetype@^2.2.0: version "2.3.0" resolved "https://registry.yarnpkg.com/whatwg-mimetype/-/whatwg-mimetype-2.3.0.tgz#3d4b1e0312d2079879f826aff18dbeeca5960fbf"