Skip to content

Commit 64191de

Browse files
bomsyclaude
andcommitted
Drop the dead 'url' core module fallback in lib/url.js
`lib/url.js` fell back to `require("url").URL` when `URL` was not a global, which was only the case on Node 8. This package requires Node >= 12 and `URL` has been global since Node 10, so the fallback was unreachable. It was not harmless, though: bundlers that no longer polyfill Node core modules fail outright on it. Under webpack 5 this breaks `npm run build` in bench/ with: Module not found: Error: Can't resolve 'url' in '.../lib' BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default. The comment above it also claimed the file was overridden via `package.json#browser` to use `lib/url-browser.js`. That stopped being true in b95ecf0, which removed `lib/url-browser.js` without removing the browser mapping's last reader or this comment. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
1 parent 31615d3 commit 64191de

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

‎lib/url.js‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
*/
77
"use strict";
88

9-
// Note: This file is overridden in the 'package.json#browser' field to
10-
// substitute lib/url-browser.js instead.
11-
12-
// Use the URL global for Node 10, and the 'url' module for Node 8.
13-
module.exports = typeof URL === "function" ? URL : require("url").URL;
9+
// `URL` has been a global since Node 10 and this package requires Node >= 12,
10+
// so there is no need to fall back to the 'url' core module. Requiring it would
11+
// also break bundlers that no longer polyfill Node core modules (webpack >= 5).
12+
module.exports = URL;

0 commit comments

Comments
 (0)