Skip to content

Commit

Permalink
Bump glob to 10.3.12 (#16450)
Browse files Browse the repository at this point in the history
* bump glob to 9.3.5

* bump glob to 10.3.12

* remove var usage

* add esm exports

* replace glob imports for Babel 7 + ESM

* simplify Babel 7 ESM imports

* suppress TS errors

* Resolve glob typings to glob 10 used in Babel 8
  • Loading branch information
JLHwung committed Apr 29, 2024
1 parent ea78cbc commit c6b393e
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 32 deletions.
2 changes: 1 addition & 1 deletion packages/babel-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"commander": "^4.0.1",
"convert-source-map": "^2.0.0",
"fs-readdir-recursive": "^1.1.0",
"glob": "^7.2.0",
"glob": "condition:BABEL_8_BREAKING ? ^10.3.12 : ^7.2.0 (esm:sync|default)",
"make-dir": "condition:BABEL_8_BREAKING ? : ^2.1.0",
"slash": "condition:BABEL_8_BREAKING ? ^3.0.0 : ^2.0.0"
},
Expand Down
12 changes: 10 additions & 2 deletions packages/babel-cli/src/babel/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from "fs";

import commander from "commander";
import { version, DEFAULT_EXTENSIONS } from "@babel/core";
import glob from "glob";
import * as glob from "glob";

import type { InputOptions } from "@babel/core";

Expand Down Expand Up @@ -213,7 +213,15 @@ export default function parseArgv(args: Array<string>): CmdOptions | null {
const errors: string[] = [];

let filenames = commander.args.reduce(function (globbed: string[], input) {
let files = glob.sync(input);
let files = process.env.BABEL_8_BREAKING
? // glob 9+ no longer sorts the result, here we maintain the glob 7 behaviour
// https://github.com/isaacs/node-glob/blob/c3cd57ae128faa0e9190492acc743bb779ac4054/common.js#L151
glob.sync(input, { dotRelative: true }).sort(function alphasort(a, b) {
return a.localeCompare(b, "en");
})
: // @ts-expect-error When USE_ESM is true and BABEL_8_BREAKING is off,
// the glob package is an ESM wrapper of the CJS glob 7
(USE_ESM ? glob.default.sync : glob.sync)(input);
if (!files.length) files = [input];
globbed.push(...files);
return globbed;
Expand Down
1 change: 1 addition & 0 deletions scripts/generators/tsconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ fs.writeFileSync(
"babel-plugin-dynamic-import-node/utils",
["./lib/babel-plugin-dynamic-import-node.d.ts"],
],
["glob", ["./node_modules/glob-BABEL_8_BREAKING-true"]],
["globals", ["./node_modules/globals-BABEL_8_BREAKING-true"]],
["js-tokens", ["./node_modules/js-tokens-BABEL_8_BREAKING-true"]],
["regexpu-core", ["./lib/regexpu-core.d.ts"]],
Expand Down
3 changes: 3 additions & 0 deletions tsconfig.paths.json
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,9 @@
"babel-plugin-dynamic-import-node/utils": [
"./lib/babel-plugin-dynamic-import-node.d.ts"
],
"glob": [
"./node_modules/glob-BABEL_8_BREAKING-true"
],
"globals": [
"./node_modules/globals-BABEL_8_BREAKING-true"
],
Expand Down
83 changes: 54 additions & 29 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ __metadata:
commander: "npm:^4.0.1"
convert-source-map: "npm:^2.0.0"
fs-readdir-recursive: "npm:^1.1.0"
glob: "npm:^7.2.0"
glob: "condition:BABEL_8_BREAKING ? ^10.3.12 : ^7.2.0 (esm:sync|default)"
make-dir: "condition:BABEL_8_BREAKING ? : ^2.1.0"
semver: "npm:^6.3.1"
slash: "condition:BABEL_8_BREAKING ? ^3.0.0 : ^2.0.0"
Expand Down Expand Up @@ -10460,6 +10460,35 @@ __metadata:
languageName: node
linkType: hard

"glob-BABEL_8_BREAKING-false@npm:glob@^7.2.0, glob@npm:^7.0.0, glob@npm:^7.1.0, glob@npm:^7.1.1, glob@npm:^7.1.3, glob@npm:^7.1.4, glob@npm:^7.2.0":
version: 7.2.3
resolution: "glob@npm:7.2.3"
dependencies:
fs.realpath: "npm:^1.0.0"
inflight: "npm:^1.0.4"
inherits: "npm:2"
minimatch: "npm:^3.1.1"
once: "npm:^1.3.0"
path-is-absolute: "npm:^1.0.0"
checksum: 10/59452a9202c81d4508a43b8af7082ca5c76452b9fcc4a9ab17655822e6ce9b21d4f8fbadabe4fe3faef448294cec249af305e2cd824b7e9aaf689240e5e96a7b
languageName: node
linkType: hard

"glob-BABEL_8_BREAKING-true@npm:glob@^10.3.12":
version: 10.3.12
resolution: "glob@npm:10.3.12"
dependencies:
foreground-child: "npm:^3.1.0"
jackspeak: "npm:^2.3.6"
minimatch: "npm:^9.0.1"
minipass: "npm:^7.0.4"
path-scurry: "npm:^1.10.2"
bin:
glob: dist/esm/bin.mjs
checksum: 10/9e8186abc22dc824b5dd86cefd8e6b5621a72d1be7f68bacc0fd681e8c162ec5546660a6ec0553d6a74757a585e655956c7f8f1a6d24570e8d865c307323d178
languageName: node
linkType: hard

"glob-parent@npm:^3.1.0":
version: 3.1.0
resolution: "glob-parent@npm:3.1.0"
Expand Down Expand Up @@ -10528,6 +10557,16 @@ __metadata:
languageName: node
linkType: hard

"glob@condition:BABEL_8_BREAKING ? ^10.3.12 : ^7.2.0 (esm:sync|default)":
version: 0.0.0-condition-7d059e
resolution: "glob@condition:BABEL_8_BREAKING?^10.3.12:^7.2.0(esm:sync|default)#7d059e"
dependencies:
glob-BABEL_8_BREAKING-false: "npm:glob@^7.2.0"
glob-BABEL_8_BREAKING-true: "npm:glob@^10.3.12"
checksum: 10/8ac0cc489a0e0e709f98f9ec846e9ba17fa5cffa3c2ca9b29051aebfa5b9924ab8926ccb7f1a1f00d9c64d048ea4d7cb62f3be3e3ab20d6c657c51614664b900
languageName: node
linkType: hard

"glob@npm:^10.3.10":
version: 10.3.10
resolution: "glob@npm:10.3.10"
Expand All @@ -10543,20 +10582,6 @@ __metadata:
languageName: node
linkType: hard

"glob@npm:^7.0.0, glob@npm:^7.1.0, glob@npm:^7.1.1, glob@npm:^7.1.3, glob@npm:^7.1.4, glob@npm:^7.2.0":
version: 7.2.3
resolution: "glob@npm:7.2.3"
dependencies:
fs.realpath: "npm:^1.0.0"
inflight: "npm:^1.0.4"
inherits: "npm:2"
minimatch: "npm:^3.1.1"
once: "npm:^1.3.0"
path-is-absolute: "npm:^1.0.0"
checksum: 10/59452a9202c81d4508a43b8af7082ca5c76452b9fcc4a9ab17655822e6ce9b21d4f8fbadabe4fe3faef448294cec249af305e2cd824b7e9aaf689240e5e96a7b
languageName: node
linkType: hard

"glob@npm:^8.0.3":
version: 8.0.3
resolution: "glob@npm:8.0.3"
Expand Down Expand Up @@ -11825,7 +11850,7 @@ __metadata:
languageName: node
linkType: hard

"jackspeak@npm:^2.3.5":
"jackspeak@npm:^2.3.5, jackspeak@npm:^2.3.6":
version: 2.3.6
resolution: "jackspeak@npm:2.3.6"
dependencies:
Expand Down Expand Up @@ -12982,6 +13007,13 @@ __metadata:
languageName: node
linkType: hard

"lru-cache@npm:^10.2.0":
version: 10.2.0
resolution: "lru-cache@npm:10.2.0"
checksum: 10/502ec42c3309c0eae1ce41afca471f831c278566d45a5273a0c51102dee31e0e250a62fa9029c3370988df33a14188a38e682c16143b794de78668de3643e302
languageName: node
linkType: hard

"lru-cache@npm:^4.0.1":
version: 4.1.5
resolution: "lru-cache@npm:4.1.5"
Expand All @@ -13008,13 +13040,6 @@ __metadata:
languageName: node
linkType: hard

"lru-cache@npm:^9.1.1 || ^10.0.0":
version: 10.1.0
resolution: "lru-cache@npm:10.1.0"
checksum: 10/207278d6fa711fb1f94a0835d4d4737441d2475302482a14785b10515e4c906a57ebf9f35bf060740c9560e91c7c1ad5a04fd7ed030972a9ba18bce2a228e95b
languageName: node
linkType: hard

"magic-string@npm:^0.27.0":
version: 0.27.0
resolution: "magic-string@npm:0.27.0"
Expand Down Expand Up @@ -13323,7 +13348,7 @@ __metadata:
languageName: node
linkType: hard

"minipass@npm:^5.0.0 || ^6.0.2 || ^7.0.0":
"minipass@npm:^5.0.0 || ^6.0.2 || ^7.0.0, minipass@npm:^7.0.4":
version: 7.0.4
resolution: "minipass@npm:7.0.4"
checksum: 10/e864bd02ceb5e0707696d58f7ce3a0b89233f0d686ef0d447a66db705c0846a8dc6f34865cd85256c1472ff623665f616b90b8ff58058b2ad996c5de747d2d18
Expand Down Expand Up @@ -14260,13 +14285,13 @@ __metadata:
languageName: node
linkType: hard

"path-scurry@npm:^1.10.1":
version: 1.10.1
resolution: "path-scurry@npm:1.10.1"
"path-scurry@npm:^1.10.1, path-scurry@npm:^1.10.2":
version: 1.10.2
resolution: "path-scurry@npm:1.10.2"
dependencies:
lru-cache: "npm:^9.1.1 || ^10.0.0"
lru-cache: "npm:^10.2.0"
minipass: "npm:^5.0.0 || ^6.0.2 || ^7.0.0"
checksum: 10/eebfb8304fef1d4f7e1486df987e4fd77413de4fce16508dea69fcf8eb318c09a6b15a7a2f4c22877cec1cb7ecbd3071d18ca9de79eeece0df874a00f1f0bdc8
checksum: 10/a2bbbe8dc284c49dd9be78ca25f3a8b89300e0acc24a77e6c74824d353ef50efbf163e64a69f4330b301afca42d0e2229be0560d6d616ac4e99d48b4062016b1
languageName: node
linkType: hard

Expand Down

0 comments on commit c6b393e

Please sign in to comment.