Skip to content
This repository was archived by the owner on Aug 4, 2021. It is now read-only.
This repository was archived by the owner on Aug 4, 2021. It is now read-only.

Why is createFilter is scoped to process.cwd? #39

@tivac

Description

@tivac

const getMatcher = id => ( isRegexp( id ) ? id : { test: mm.matcher( resolve( id ) ) } );

If you invoke createFilter() with a string for include or exclude it'll be run through path.resolve before it's passed to mm.matcher().

Why?

It means that unless you pass a regular expression matcher all globs will only match files underneath process.cwd(). This cropped up as I tried to move my fixtures to the system temp folder and suddenly my plugin's filters stopped matching anything because they're all scoped. It seems like it'd be more intuitive for the glob to be passed to mm.matcher() w/o the resolving.

const { createFilter } = require("rollup-pluginutils");

const filter = createFilter("**/*.css");

// Now filter() is matching against
`${process.cwd()}/**/*.css`

// instead of what I expected, which is
`**/*.css`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions