Skip to content

Commit 868f007

Browse files
author
Eike Reifhardt
committed
fix(matched): replace matched with glob
1 parent c3dcdc0 commit 868f007

File tree

3 files changed

+143
-20
lines changed

3 files changed

+143
-20
lines changed

packages/multi-entry/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
},
6262
"dependencies": {
6363
"@rollup/plugin-virtual": "^3.0.0",
64-
"matched": "^5.0.1"
64+
"glob": "^11.0.3"
6565
},
6666
"devDependencies": {
6767
"rollup": "^4.0.0-24"

packages/multi-entry/src/index.js

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable no-param-reassign */
22

33
import virtual from '@rollup/plugin-virtual';
4-
import { promise as matched } from 'matched';
4+
import { glob } from 'glob';
55

66
const DEFAULT_OUTPUT = 'multi-entry.js';
77
const AS_IMPORT = 'import';
@@ -57,13 +57,27 @@ export default function multiEntry(conf = {}) {
5757
};
5858
},
5959

60-
buildStart(options) {
60+
async buildStart(options) {
6161
const patterns = config.include.concat(config.exclude.map((pattern) => `!${pattern}`));
62-
const entries = patterns.length
63-
? matched(patterns, { realpath: true }).then((paths) =>
64-
paths.sort().map(exporter).join('\n')
65-
)
66-
: Promise.resolve('');
62+
63+
// Split patterns based on includes and excludes
64+
const includePatterns = patterns.filter((pattern) => !pattern.startsWith('!'));
65+
const excludePatterns = patterns
66+
.filter((pattern) => pattern.startsWith('!'))
67+
.map((pattern) => pattern.substring(1));
68+
69+
const paths = await Promise.all(
70+
includePatterns.map(async (pattern) =>
71+
glob(pattern, {
72+
absolute: true,
73+
ignore: excludePatterns
74+
})
75+
)
76+
);
77+
78+
const flatPaths = [...new Set(paths.flat())];
79+
80+
const entries = flatPaths.length ? flatPaths.map(exporter).join('\n') : '';
6781

6882
virtualisedEntry = virtual({ [options.input]: entries });
6983
},

pnpm-lock.yaml

Lines changed: 121 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)