Repository navigation
fix: filter should not stabilize args.specifier - #3972
Conversation
✅ Deploy Preview for rolldown-rs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Benchmarks Rust |
2c20a45 to
d555693
Compare
d555693 to
53f5dc8
Compare
53f5dc8 to
365ad09
Compare
hi-ogawa
left a comment
There was a problem hiding this comment.
Porting get_matcher_string would break a following pattern, so I'm not sure if aligning with createFilter is necessary.
{
name: 'repro',
resolveId: {
filter: {
id: 'virtual:foo'
},
handler(...args) {
console.log("[resolveId]", args)
return '\0virtual:foo'
}
},
load: {
filter: {
id: '\0virtual:foo'
},
handler(...args) {
console.log("[load]", args)
return `console.log("ok")`;
}
},
}I didn't know createFilter is aware of cwd and, from what I've seen, I think people normally don't rely on that and explicitly uses ** for string pattern instead, so breaking that away from createFilter might be fine in practice. Any thoughts? @sapphi-red
Maybe we should also handle any string prefix with |
|
In this case we recommended user to use regexp instead |
365ad09 to
c2ecda4
Compare
Another reason I prefer to align with rollup is user may have less mental burden when migrating from rollup to rolldown |
Virtual module naming is not restricted to
I understand both ways. I'm also wondering which is less mental burden for users, either 1. exactly same as |
|
It seems createFilter of pluginutils recommends setting |
|
I wonder if which is more common, matching a virtual module or filtering under |
|
Probably depends on how the filter is used. If the value is passed from the user, aligning with createFilter is useful I guess: https://github.com/search?q=path%3Arollup.config.js+%2Finclude%3A%2F&type=code&p=1 |
|
My personal conclusion is: I prefer this PR, maybe good to add a export const extactRegExp = str => new RegExp(`^${RegExp.escape(str)}$`)
export const prefixRegExp = str => new RegExp(`^${RegExp.escape(str)}`)
export const suffixRegExp = str => new RegExp(`${RegExp.escape(str)}$`) |
Merge activity
|
hi-ogawa
left a comment
There was a problem hiding this comment.
I'm good with this too as intended behavior is clear now 👍
A relative glob like `filter: { id: 'src/**' }` matches nothing when
`cwd` contains glob characters or is relative. The default `cwd` is
`process.cwd()`, so running Rolldown from such a folder is enough.
```diff
cwd: /w/my[app]
glob: src/**
-/w/my[app]/src/** # [app] is a character class, so /w/my[app]/src/main.js doesn't match
+/w/my\[app\]/src/** # cwd is escaped first
```
`get_matcher_string` now does what Rollup's `getMatcherString` does.
#3972 ported it without these two steps:
```diff
get_matcher_string(glob, cwd)
if glob starts with ** or is absolute
return glob
+ if cwd is relative, make it absolute
+ escape \ * ? [ ] { } ! in cwd
join glob onto cwd, resolving . and ..
```
Every relative glob filter goes through it:
```text
get_matcher_string
├── hook filters (id, importerId)
├── watch.include / watch.exclude
└── include/exclude of the native Vite plugins (transform, dynamic-import-vars)
```
Repro:
https://github.com/onmax/repros/tree/repro/rolldown-cwd-glob/rolldown-cwd-glob
An empty `cwd` still keeps the glob relative, because `test_filter`
relies on it. I haven't tested on Windows, so a `ci: windows` run would
help.
---------
Co-authored-by: IWANABETHATGUY <[email protected]>

Description
createFilterutil #3970