Skip to content

Commit

Permalink
clients: use minimal 'url' polyfil instead of url-shim (#13545)
Browse files Browse the repository at this point in the history
  • Loading branch information
brendankenny committed Jan 7, 2022
1 parent da73d4a commit fd58e01
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
7 changes: 6 additions & 1 deletion build/build-bundle.js
Expand Up @@ -142,7 +142,6 @@ async function build(entryPath, distPath, opts = {minify: true}) {
entries: {
'debug': require.resolve('debug/src/browser.js'),
'lighthouse-logger': require.resolve('../lighthouse-logger/index.js'),
'url': require.resolve('../lighthouse-core/lib/url-shim.js'),
},
}),
rollupPlugins.shim({
Expand All @@ -152,6 +151,12 @@ async function build(entryPath, distPath, opts = {minify: true}) {
import Audit from '${require.resolve('../lighthouse-core/audits/audit.js')}';
export {Audit};
`,
// Most node 'url' polyfills don't include the WHATWG `URL` property, but
// that's all that's needed, so make a mini-polyfill.
// @see https://github.com/GoogleChrome/lighthouse/issues/5273
// TODO: remove when not needed for pubads (https://github.com/googleads/publisher-ads-lighthouse-plugin/pull/325)
// and robots-parser (https://github.com/samclarke/robots-parser/pull/23)
'url': 'export const URL = globalThis.URL;',
}),
rollupPlugins.json(),
rollupPlugins.inlineFs({verbose: false}),
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -170,7 +170,7 @@
"resolve": "^1.20.0",
"rollup": "^2.52.7",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-polyfill-node": "^0.7.0",
"rollup-plugin-polyfill-node": "^0.8.0",
"rollup-plugin-replace": "^2.2.0",
"rollup-plugin-shim": "^1.0.0",
"rollup-plugin-terser": "^7.0.2",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Expand Up @@ -7150,10 +7150,10 @@ rollup-plugin-node-resolve@^5.2.0:
resolve "^1.11.1"
rollup-pluginutils "^2.8.1"

rollup-plugin-polyfill-node@^0.7.0:
version "0.7.0"
resolved "https://registry.yarnpkg.com/rollup-plugin-polyfill-node/-/rollup-plugin-polyfill-node-0.7.0.tgz#938e13278c98a582a4f8814975ddd26f90afddcc"
integrity sha512-iJLZDfvxcQh3SpC0OiYlZG9ik26aRM29hiC2sARbAPXYunB8rzW8GtVaWuJgiCtX1hNAo/OaYvVXfPp15fMs7g==
rollup-plugin-polyfill-node@^0.8.0:
version "0.8.0"
resolved "https://registry.yarnpkg.com/rollup-plugin-polyfill-node/-/rollup-plugin-polyfill-node-0.8.0.tgz#859c070822f5e38d221e5b4238cb34aa894c2b19"
integrity sha512-C4UeKedOmOBkB3FgR+z/v9kzRwV1Q/H8xWs1u1+CNe4XOV6hINfOrcO+TredKxYvopCmr+WKUSNsFUnD1RLHgQ==
dependencies:
"@rollup/plugin-inject" "^4.0.0"

Expand Down

0 comments on commit fd58e01

Please sign in to comment.