-
-
Notifications
You must be signed in to change notification settings - Fork 625
Closed
Description
- Rollup Plugin Name: alias
- Rollup Plugin Version: latest
- Rollup Version: latest
- Operating System (or Browser): win64 win10
- Node Version: 15
- Link to reproduction (
⚠️ read below): https://repl.it/@LoveofRedMoon/rollup-plugin-repro
Expected Behavior
file /output/bundle.js needs required('src/index');
Actual Behavior
file /output/bundle.js shows require('../../../@/index');
Additional Information
In alias plugin, the following code will return false when pass paramters ('/@/', '/@/vue/Button.vue')
function matches(pattern: string | RegExp, importee: string) {
if (pattern instanceof RegExp) {
return pattern.test(importee);
}
if (importee.length < pattern.length) {
return false;
}
if (importee === pattern) {
return true;
}
const importeeStartsWithKey = importee.indexOf(pattern) === 0;
const importeeHasSlashAfterKey = importee.substring(pattern.length)[0] === '/';
return importeeStartsWithKey && importeeHasSlashAfterKey;
}I guess it is necessary to remove the trailing slash with pattern
for example:
function getEntries({ entries }: RollupAliasOptions): readonly Alias[] {
if (!entries) {
return [];
}
if (Array.isArray(entries)) {
return entries;
}
return Object.entries(entries).map(([key, value]) => {
// return { find: key, replacement: value };
return { find: key.replace?.(/\/+$/, '') , replacement: value };
});
}Reactions are currently unavailable