Skip to content

Commit

Permalink
chore(dynamic-import-vars): switch to tinyglobby for fewer dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Sep 30, 2024
1 parent 4a2358a commit 843baa0
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
4 changes: 2 additions & 2 deletions packages/dynamic-import-vars/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
"@rollup/pluginutils": "^5.0.1",
"astring": "^1.8.5",
"estree-walker": "^2.0.2",
"fast-glob": "^3.2.12",
"magic-string": "^0.30.3"
"magic-string": "^0.30.3",
"tinyglobby": "^0.2.7"
},
"devDependencies": {
"acorn": "^8.8.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/dynamic-import-vars/src/dynamic-import-to-glob.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'path';

import fastGlob from 'fast-glob';
import { escapePath } from 'tinyglobby';

export class VariableDynamicImportError extends Error {}

Expand All @@ -12,7 +12,7 @@ function sanitizeString(str) {
if (str.includes('*')) {
throw new VariableDynamicImportError('A dynamic import cannot contain * characters.');
}
return fastGlob.escapePath(str);
return escapePath(str);
}

function templateLiteralToGlob(node) {
Expand Down
4 changes: 2 additions & 2 deletions packages/dynamic-import-vars/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import path from 'path';

import { walk } from 'estree-walker';
import MagicString from 'magic-string';
import fastGlob from 'fast-glob';
import { globSync } from 'tinyglobby';
import { generate } from 'astring';

import { createFilter } from '@rollup/pluginutils';
Expand Down Expand Up @@ -50,7 +50,7 @@ function dynamicImportVariables({ include, exclude, warnOnError, errorWhenNoFile
}

// execute the glob
const result = fastGlob.sync(glob, { cwd: path.dirname(id) });
const result = globSync(glob, { cwd: path.dirname(id), expandDirectories: false });
const paths = result.map((r) =>
r.startsWith('./') || r.startsWith('../') ? r : `./${r}`
);
Expand Down
35 changes: 31 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 843baa0

Please sign in to comment.