Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pluginutils)!: don't add cwd to absolute or patterns that start with a glob #517

Merged

Conversation

LarsDenBakker
Copy link
Contributor

@LarsDenBakker LarsDenBakker commented Jul 29, 2020

Rollup Plugin Name: pluginutils

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

If yes, then include "BREAKING CHANGES:" in the first commit message body, followed by a description of what is breaking.

List any relevant issue numbers: Fixes #490

Description

When a pattern is an absolute path or when it starts with a glob star, the current working directory is not prefixed.

If a pattern is an absolute pattern: /Users/me/some/path/to/code.js, the pattern becomes /Users/me/some/path/Users/me/some/path/to/code.js which is a useless path.

If a pattern starts with a glob, like: **/* the user's intent is to clearly match all parent directories. This becomes: /Users/me/some/path/**/*, and the user (unknowingly) does not include or exclude files outside of the current working directory.

I consider this a bugfix because in both cases it goes against the user's intent. However if code is relying on this behavior, it might have an unintended side effect. I think the benefit outweighs this risk.

@LarsDenBakker LarsDenBakker changed the title fix(pluginutils): don't add cwd to absolute or patterns that start wi… fix(pluginutils): don't add cwd to absolute or patterns that start with a glob Jul 29, 2020
Copy link
Collaborator

@shellscape shellscape left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tivac
Copy link

tivac commented Jul 29, 2020

This definitely seems like a breaking change, even if the previous behavior is considered a bug?

Had deja vu reading this, wasn't sure why, then I went back and found rollup/rollup-pluginutils#39

@shellscape
Copy link
Collaborator

@lukastaegert I think we'll need some additional historical perspective here again. could you review what @tivac shared and comment?

@lukastaegert
Copy link
Member

lukastaegert commented Aug 3, 2020

I guess it can be considered a breaking change as it is always possible that people were relying on e.g. **/something not matching files above the working directory. I guess better to be safe here, even though it means that plugins will themselves need to do major versions if they were relying on the "filter" functionality. It's a pity that the approach implemented here did not come up in the original discussion, I think it would have solved the original issue as well.

@shellscape shellscape changed the title fix(pluginutils): don't add cwd to absolute or patterns that start with a glob fix(pluginutils)!: don't add cwd to absolute or patterns that start with a glob Aug 4, 2020
@shellscape
Copy link
Collaborator

@lukastaegert with it being a breaking change, would you approve of this change?

@lukastaegert
Copy link
Member

Yes I would. This is a recurring issue, and the solution looks to me like it fits the situations where people had complaints. Of course this means that any plugin updating here will also need a major version if it relies on this. We should keep this in mind when doing major versions of plugins to use the chance to update this dependency as well.

@shellscape shellscape merged commit d9d2900 into rollup:master Aug 6, 2020
LarsDenBakker added a commit to LarsDenBakker/plugins that referenced this pull request Sep 12, 2020
dominikg added a commit to dominikg/rollup-plugin-svelte that referenced this pull request Feb 1, 2021
This includes 2 major version bumps:
2-3: updates minimum rollup version to 1.20 and node version to 8, not a problem
3-4: fixes/changes behavior of createFilter with absolute paths or globs at start, see rollup/plugins#517
dominikg added a commit to dominikg/rollup-plugin-svelte that referenced this pull request Feb 1, 2021
This includes 2 major version bumps:
2-3: updates minimum rollup version to 1.20 and node version to 8, not a problem
3-4: fixes/changes behavior of createFilter with absolute paths or globs at start, see rollup/plugins#517
agilgur5 added a commit to agilgur5/rpt2-issue-295 that referenced this pull request May 27, 2022
- microbundle is using a relatively older version
  - 0.29.0: https://github.com/developit/microbundle/blob/555088d17c97860a51ce43808853f4d4f0146a4c/package.json#L111
  - meanwhile, 0.30.0 updated the `@rollup/pluginutils` dep: ezolenko/rollup-plugin-typescript2@c6f6e52
    - and `@rollup/pluginutils` v4 contains this breaking change: rollup/plugins#517
    - with that change, the `filter` now resolves files outside of the cwd

- now rpt2 resolves the file correctly and there is no error anymore
  - that being said, it does produce an empty chunk, but that is correct
    behavior because Rollup applies treeshaking and the export does nothing
    - `named` exports are set (https://rollupjs.org/guide/en/#exporting)
    - and `export * from` actually _doesn't_ export the `default` export
    - changing this `export { default } from` gets it to output something

- note: had to set overrides in root package.json as that's what
  pnpm requires: https://pnpm.io/package_json#pnpmoverrides
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[pluginutils] strange behavior for include/exclude pattern
4 participants