Skip to content

Commit

Permalink
fix(#58): guard plugin resolution w/ include and exclude
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Nov 29, 2023
1 parent 2a3b06a commit 51980bd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Plugin as RollupPlugin } from 'rollup';

import fs from 'fs';
import { extname, resolve, dirname, join } from 'path';
import { extname, resolve, dirname, join, sep } from 'path';
import { createFilter, type FilterPattern } from '@rollup/pluginutils';
import type {
Options as SwcOptions,
Expand Down Expand Up @@ -75,7 +75,13 @@ function swc(options: PluginOptions = {}): RollupPlugin {
return null;
}

if (importer && importee.startsWith('.')) {
// If the importer (the module that is importing the importee) should not be handled by this plugin,
// we skip the resolution to avoid the issue like https://github.com/SukkaW/rollup-plugin-swc/issues/58
if (!filter(importer)) {
return null;
}

if (importer && importee[0] === '.') {
const resolved = resolve(
importer ? dirname(importer) : process.cwd(),
importee
Expand Down

0 comments on commit 51980bd

Please sign in to comment.