(code, id)
| 59 | transform: { |
| 60 | filter: { code: 'import.meta.glob' }, |
| 61 | async handler(code, id) { |
| 62 | const result = await transformGlobImport( |
| 63 | code, |
| 64 | id, |
| 65 | config.root, |
| 66 | (im, _, options) => |
| 67 | this.resolve(im, id, options).then((i) => i?.id || im), |
| 68 | config.experimental.importGlobRestoreExtension, |
| 69 | config.logger, |
| 70 | ) |
| 71 | if (result) { |
| 72 | if (!importGlobMaps.has(this.environment)) { |
| 73 | importGlobMaps.set(this.environment, new Map()) |
| 74 | } |
| 75 | |
| 76 | const globMatchers = result.matches.map((i) => { |
| 77 | const affirmed: string[] = [] |
| 78 | const negated: string[] = [] |
| 79 | for (const glob of i.globsResolved) { |
| 80 | if (glob[0] === '!') { |
| 81 | negated.push(glob.slice(1)) |
| 82 | } else { |
| 83 | affirmed.push(glob) |
| 84 | } |
| 85 | } |
| 86 | const affirmedMatcher = picomatch(affirmed, { |
| 87 | noextglob: true, |
| 88 | dot: !!i.options.exhaustive, |
| 89 | nocase: !(i.options.caseSensitive ?? true), |
| 90 | ignore: i.options.exhaustive ? [] : ['**/node_modules/**'], |
| 91 | }) |
| 92 | const negatedMatcher = picomatch(negated, { |
| 93 | noextglob: true, |
| 94 | dot: !!i.options.exhaustive, |
| 95 | nocase: !(i.options.caseSensitive ?? true), |
| 96 | ignore: i.options.exhaustive ? [] : ['**/node_modules/**'], |
| 97 | }) |
| 98 | |
| 99 | return (file: string) => { |
| 100 | // (glob1 || glob2) && !(glob3 || glob4)... |
| 101 | return ( |
| 102 | (affirmed.length === 0 || affirmedMatcher(file)) && |
| 103 | !(negated.length > 0 && negatedMatcher(file)) |
| 104 | ) |
| 105 | } |
| 106 | }) |
| 107 | importGlobMaps.get(this.environment)!.set(id, globMatchers) |
| 108 | |
| 109 | return transformStableResult(result.s, id, config) |
| 110 | } |
| 111 | }, |
| 112 | }, |
| 113 | hotUpdate({ type, file, modules: oldModules }) { |
| 114 | if (type === 'update') return |
nothing calls this directly
no test coverage detected