plugins: [plugin-dynamic-import-vars] non-normalized paths no longer work
- Rollup Plugin Name: plugin-dynamic-import-vars
- Rollup Plugin Version: 2.1.4
- Rollup Version: *
- Operating System (or Browser): *
- Node Version: *
- Link to reproduction: https://stackblitz.com/edit/rollup-repro-blsfye?file=src%2Fmain.js
Expected Behavior
Imports passed non-normalized paths resolve the bundled file
Actual Behavior
Imports passed non-normalized paths produce a Unknown variable dynamic import error
Additional Information
#1780 breaks any code that doesn’t build normalized paths because tinyglobby always outputs normalized glob paths but the plugin doesn’t touch the original code.
Given this code:
import(`./../${myFile}.js`)
tinyglobby produces ../*.js -> ../myFile.js-> case '../myFile.js', which now doesn’t match ./../myFile.js.
I think the only reasonable options are:
- Revert
- Ask
tinyglobbyto make normalization optional (will take time and maybe isn’t even feasible/desired) - Normalize the path inside
__variableDynamicImportRuntime__before theswitchwithpath-normalize
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (7 by maintainers)
Making the decision to revert the changes. The only tangible benefit was a reduction of dependencies, but the juice isn’t worth the squeeze.
So then the issue is with the crawler then. I don’t think it’s actually an issue, though. Certainly not from its perspective. It might be best to just normalize the paths at runtime in the plugin.
that normalizes the pattern to match, not the way the results from the directory crawler are generated. the only case where the patterns can modify the result is if any of the patterns start with
../, but that’s just because the crawler can’t find any files outside the root without a workaroundthe crawler library generates a result that’s always the exact same no matter the patterns, and each possible result that’s generated is filtered by the (normalized) patterns
if you have a directory that has
a/a.txtfor example, no matter what pattern you use, the crawler will see that file asa/a.txtwhen filtering and producing results