rollup / plugins

🍣 The one-stop shop for official Rollup plugins
MIT License
3.62k stars 581 forks source link

Typescript plugin throws an error when importing relative imports outside of the current working directory...even with `filterRoot` set #1650

Open ericmorand opened 9 months ago

ericmorand commented 9 months ago

Expected Behavior

When executing rollup in a sub-directory - i.e. not in the root project directory - the plugin is able to resolve relative imports.

Actual Behavior

When executing rollup in a sub-directory - i.e. not in the root project directory - the plugin is unable to resolve relative imports, and throws an error.

Additional Information

It seems like setting filterRoot option to . doesn't work as expected - it still considers that the "resolution base" is the current working directory. Which basically makes the option useless since it only works properly when set to an absolute path. Consequently, it makes the plugin unusable outside of the root of the project because whatever value we pass to filterRoot that is not absolute may not work depending of where we execute rollup from.

Typically, in my example, would we put .. as filterRoot, it would work when executing rollup from foo but fail when executing it from foo/bar.

I'm not sure I understand the purpose of filtering out files that are outside of the current working directory. TypeScript doesn't care about that - which is proven by the existence of the filterRoot option - and the rational behind adding a constraint to the plugin is not clear.

Just to confirm, I removed the part of the plugin that actually filter out files that are outside of the current working directory and it works perfectly in every project I've tested it.