Skip to content

Commit 19fd937

Browse files
authored
feat!: switch from globby and fast-glob to tinyglobby (#795)
1 parent 49df230 commit 19fd937

File tree

4 files changed

+46
-89
lines changed

4 files changed

+46
-89
lines changed

package-lock.json

+30-65
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,11 @@
4949
"webpack": "^5.1.0"
5050
},
5151
"dependencies": {
52-
"fast-glob": "^3.3.2",
5352
"glob-parent": "^6.0.1",
54-
"globby": "^14.0.1",
5553
"normalize-path": "^3.0.0",
5654
"schema-utils": "^4.2.0",
57-
"serialize-javascript": "^6.0.2"
55+
"serialize-javascript": "^6.0.2",
56+
"tinyglobby": "^0.2.12"
5857
},
5958
"devDependencies": {
6059
"@babel/cli": "^7.24.6",

src/index.js

+10-17
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,17 @@ const getSerializeJavascript = memoize(() =>
2525
require("serialize-javascript"),
2626
);
2727

28-
const getFastGlob = memoize(() =>
28+
const getTinyGlobby = memoize(() =>
2929
// eslint-disable-next-line global-require
30-
require("fast-glob"),
30+
require("tinyglobby"),
3131
);
3232

33-
const getGlobby = memoize(async () => {
34-
// @ts-ignore
35-
const { globby } = await import("globby");
36-
37-
return globby;
38-
});
39-
4033
/** @typedef {import("schema-utils/declarations/validate").Schema} Schema */
4134
/** @typedef {import("webpack").Compiler} Compiler */
4235
/** @typedef {import("webpack").Compilation} Compilation */
4336
/** @typedef {import("webpack").WebpackError} WebpackError */
4437
/** @typedef {import("webpack").Asset} Asset */
45-
/** @typedef {import("globby").Options} GlobbyOptions */
38+
/** @typedef {import("tinyglobby").GlobOptions} GlobbyOptions */
4639
/** @typedef {ReturnType<Compilation["getLogger"]>} WebpackLogger */
4740
/** @typedef {ReturnType<Compilation["getCache"]>} CacheFacade */
4841
/** @typedef {ReturnType<ReturnType<Compilation["getCache"]>["getLazyHashedEtag"]>} Etag */
@@ -267,7 +260,7 @@ class CopyPlugin {
267260

268261
/**
269262
* @private
270-
* @param {typeof import("globby").globby} globby
263+
* @param {typeof import("tinyglobby").glob} globby
271264
* @param {Compiler} compiler
272265
* @param {Compilation} compilation
273266
* @param {WebpackLogger} logger
@@ -339,10 +332,10 @@ class CopyPlugin {
339332

340333
/** @type {GlobbyOptions} */
341334
const globOptions = {
335+
absolute: true,
342336
followSymbolicLinks: true,
343337
...(pattern.globOptions || {}),
344338
cwd: pattern.context,
345-
objectMode: false,
346339
onlyFiles: true,
347340
};
348341

@@ -359,7 +352,7 @@ class CopyPlugin {
359352

360353
pattern.context = absoluteFrom;
361354
glob = path.posix.join(
362-
getFastGlob().escapePath(
355+
getTinyGlobby().escapePath(
363356
getNormalizePath()(path.resolve(absoluteFrom)),
364357
),
365358
"**/*",
@@ -376,7 +369,7 @@ class CopyPlugin {
376369
logger.debug(`added '${absoluteFrom}' as a file dependency`);
377370

378371
pattern.context = path.dirname(absoluteFrom);
379-
glob = getFastGlob().escapePath(
372+
glob = getTinyGlobby().escapePath(
380373
getNormalizePath()(path.resolve(absoluteFrom)),
381374
);
382375

@@ -397,7 +390,7 @@ class CopyPlugin {
397390
glob = path.isAbsolute(originalFrom)
398391
? originalFrom
399392
: path.posix.join(
400-
getFastGlob().escapePath(
393+
getTinyGlobby().escapePath(
401394
getNormalizePath()(path.resolve(pattern.context)),
402395
),
403396
originalFrom,
@@ -815,7 +808,7 @@ class CopyPlugin {
815808
const cache = compilation.getCache("CopyWebpackPlugin");
816809

817810
/**
818-
* @type {typeof import("globby").globby}
811+
* @type {typeof import("tinyglobby").glob}
819812
*/
820813
let globby;
821814

@@ -827,7 +820,7 @@ class CopyPlugin {
827820
async (unusedAssets, callback) => {
828821
if (typeof globby === "undefined") {
829822
try {
830-
globby = await getGlobby();
823+
globby = await getTinyGlobby().glob;
831824
} catch (error) {
832825
callback(/** @type {Error} */ (error));
833826

0 commit comments

Comments
 (0)