Skip to content

Commit 61ef625

Browse files
committed
fix: preemptively filter type-only files to workaround Rollup bug
- basically, right now, the addition of `this.load` on all `references` is causing Rollup to error out on JSON files - specifically, this is impacting `configPlugin` usage (i.e. `rollup.config.ts`), where previously one didn't need `@rollup/plugin-json`, but now it is erroring out without it - I tracked this down to be because of `this.load` specifically - to avoid this and similar such issues, we can preemptively `filter` out files before calling `this.resolve` / `this.load`, which should end up `exclude`ing JSON files and any other non-rpt2 files - this should also make it a bit more efficient to skip some recursion - and non-rpt2 files shouldn't include any type-only files - confirmed that this change fixes the error - and that the type-only tests still pass
1 parent f6db596 commit 61ef625

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,11 @@ const typescript: PluginImpl<RPT2Options> = (options) =>
274274
// Rollup can't see these otherwise, because they are "emit-less" and produce no JS
275275
if (result.references && supportsThisLoad) {
276276
for (const ref of result.references) {
277+
// pre-emptively filter out some files (for efficiency, as well as to workaround a Rollup bug: https://github.com/ezolenko/rollup-plugin-typescript2/issues/426#issuecomment-1264812897)
277278
if (ref.endsWith(".d.ts"))
278279
continue;
280+
if (!filter(ref))
281+
continue;
279282

280283
const module = await this.resolve(ref, id);
281284
if (!module || transformedFiles.has(module.id)) // check for circular references (per https://rollupjs.org/guide/en/#thisload)

0 commit comments

Comments
 (0)