Skip to content

Commit a0f5d69

Browse files
👷 remove glob dependency in favor of native glob from node:fs (#3950)
1 parent 5dc89f4 commit a0f5d69

File tree

7 files changed

+36
-28
lines changed

7 files changed

+36
-28
lines changed

‎LICENSE-3rdparty.csv‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ dev,eslint-plugin-jasmine,MIT,Copyright (c) 2021 Tom Vincent
4040
dev,eslint-plugin-jsdoc,BSD-3-Clause,Copyright (c) 2018, Gajus Kuizinas (http://gajus.com/)
4141
dev,eslint-plugin-unicorn,MIT,Copyright (c) Sindre Sorhus <[email protected]> (https://sindresorhus.com)
4242
dev,express,MIT,Copyright 2009-2014 TJ Holowaychuk 2013-2014 Roman Shtylman 2014-2015 Douglas Christopher Wilson
43-
dev,glob,ISC,Copyright (c) 2009-2022 Isaac Z. Schlueter and Contributors
4443
dev,globals,MIT,Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com)
4544
dev,html-webpack-plugin,MIT,Copyright JS Foundation and other contributors
4645
dev,jasmine-core,MIT,Copyright 2008-2017 Pivotal Labs

‎eslint.config.mjs‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ export default tseslint.config(
360360
ignores: [SPEC_FILES],
361361
rules: {
362362
'local-rules/enforce-monitor-until-comment': 'error',
363+
// @ts-expect-error - MONITOR_UNTIL_COMMENT_EXPIRED_LEVEL is either 'warn' or 'error'
363364
'local-rules/monitor-until-comment-expired': MONITOR_UNTIL_COMMENT_EXPIRED_LEVEL,
364365
'local-rules/disallow-side-effects': 'error',
365366
'local-rules/disallow-zone-js-patched-values': 'error',
@@ -429,6 +430,17 @@ export default tseslint.config(
429430
rules: {
430431
'@typescript-eslint/no-require-imports': 'off',
431432
'import/enforce-node-protocol-usage': ['error', 'always'],
433+
'no-restricted-imports': [
434+
'error',
435+
{
436+
paths: [
437+
{
438+
name: 'glob',
439+
message: 'Use node:fs or node:fs/promises (fs.glob) instead.',
440+
},
441+
],
442+
},
443+
],
432444
},
433445
},
434446

‎package.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@
6464
"eslint-plugin-jsdoc": "61.1.5",
6565
"eslint-plugin-unicorn": "61.0.2",
6666
"express": "5.1.0",
67-
"glob": "11.0.3",
6867
"globals": "16.4.0",
6968
"html-webpack-plugin": "5.6.4",
7069
"http-server": "14.1.1",

‎scripts/build/replace-build-env.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { globSync } from 'glob'
1+
import { globSync } from 'node:fs'
2+
import { resolve } from 'node:path'
23
import { printLog, runMain } from '../lib/executionUtils.ts'
34
import { modifyFile } from '../lib/filesUtils.ts'
45
import { buildEnvKeys, getBuildEnvValue } from '../lib/buildEnv.ts'
@@ -12,8 +13,8 @@ import { buildEnvKeys, getBuildEnvValue } from '../lib/buildEnv.ts'
1213
runMain(async () => {
1314
const buildDirectory = process.argv[2]
1415

15-
for (const path of globSync('**/*.js', { cwd: buildDirectory, absolute: true })) {
16-
if (await modifyFile(path, (content: string) => replaceBuildEnv(content))) {
16+
for (const path of globSync('**/*.js', { cwd: buildDirectory })) {
17+
if (await modifyFile(resolve(buildDirectory, path), (content: string) => replaceBuildEnv(content))) {
1718
printLog(`Replaced BuildEnv in ${path}`)
1819
}
1920
}

‎scripts/lib/computeBundleSize.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import path from 'node:path'
22
import fs from 'node:fs'
33
import zlib from 'node:zlib'
4-
import { glob } from 'glob'
54

65
const packages = ['rum', 'logs', 'flagging', 'rum-slim', 'worker'] as const
76

@@ -52,7 +51,7 @@ function getPackageSize(packageName: string): BundleSizes {
5251
const bundleSizes: BundleSizes = {}
5352
const packagePath = path.join(import.meta.dirname, `../../packages/${packageName}/bundle/`)
5453

55-
for (const file of glob.sync('**/*.js', { cwd: packagePath })) {
54+
for (const file of fs.globSync('**/*.js', { cwd: packagePath })) {
5655
const name = getPackageName(file)
5756

5857
if (!name) {

‎test/e2e/lib/helpers/validation.ts‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import fs from 'fs'
22
import type { RumEvent } from '@datadog/browser-rum'
33
import ajv from 'ajv'
4-
import { globSync } from 'glob'
54

65
export function validateRumFormat(events: RumEvent[]) {
76
const instance = new ajv({
87
allErrors: true,
98
})
10-
const allJsonSchemas = globSync('./rum-events-format/schemas/**/*.json').map(
11-
(path) => JSON.parse(fs.readFileSync(path, 'utf8')) as object
12-
)
9+
const allJsonSchemas = fs
10+
.globSync('./rum-events-format/schemas/**/*.json')
11+
.map((path) => JSON.parse(fs.readFileSync(path, 'utf8')) as object)
1312
instance.addSchema(allJsonSchemas)
1413

1514
events.forEach((rumEvent) => {

‎yarn.lock‎

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3895,7 +3895,6 @@ __metadata:
38953895
eslint-plugin-jsdoc: "npm:61.1.5"
38963896
eslint-plugin-unicorn: "npm:61.0.2"
38973897
express: "npm:5.1.0"
3898-
glob: "npm:11.0.3"
38993898
globals: "npm:16.4.0"
39003899
html-webpack-plugin: "npm:5.6.4"
39013900
http-server: "npm:14.1.1"
@@ -6950,22 +6949,6 @@ __metadata:
69506949
languageName: node
69516950
linkType: hard
69526951

6953-
"glob@npm:11.0.3, glob@npm:^11.0.3":
6954-
version: 11.0.3
6955-
resolution: "glob@npm:11.0.3"
6956-
dependencies:
6957-
foreground-child: "npm:^3.3.1"
6958-
jackspeak: "npm:^4.1.1"
6959-
minimatch: "npm:^10.0.3"
6960-
minipass: "npm:^7.1.2"
6961-
package-json-from-dist: "npm:^1.0.0"
6962-
path-scurry: "npm:^2.0.0"
6963-
bin:
6964-
glob: dist/esm/bin.mjs
6965-
checksum: 10c0/7d24457549ec2903920dfa3d8e76850e7c02aa709122f0164b240c712f5455c0b457e6f2a1eee39344c6148e39895be8094ae8cfef7ccc3296ed30bce250c661
6966-
languageName: node
6967-
linkType: hard
6968-
69696952
"glob@npm:^10.2.2":
69706953
version: 10.4.5
69716954
resolution: "glob@npm:10.4.5"
@@ -6982,6 +6965,22 @@ __metadata:
69826965
languageName: node
69836966
linkType: hard
69846967

6968+
"glob@npm:^11.0.3":
6969+
version: 11.0.3
6970+
resolution: "glob@npm:11.0.3"
6971+
dependencies:
6972+
foreground-child: "npm:^3.3.1"
6973+
jackspeak: "npm:^4.1.1"
6974+
minimatch: "npm:^10.0.3"
6975+
minipass: "npm:^7.1.2"
6976+
package-json-from-dist: "npm:^1.0.0"
6977+
path-scurry: "npm:^2.0.0"
6978+
bin:
6979+
glob: dist/esm/bin.mjs
6980+
checksum: 10c0/7d24457549ec2903920dfa3d8e76850e7c02aa709122f0164b240c712f5455c0b457e6f2a1eee39344c6148e39895be8094ae8cfef7ccc3296ed30bce250c661
6981+
languageName: node
6982+
linkType: hard
6983+
69856984
"glob@npm:^7.0.5, glob@npm:^7.1.3, glob@npm:^7.1.6, glob@npm:^7.1.7":
69866985
version: 7.2.3
69876986
resolution: "glob@npm:7.2.3"

0 commit comments

Comments
 (0)