babel-plugin-replace-import-extension
babel-plugin-replace-import-extension copied to clipboard
v1.1.4 generates code with syntax error
v1.1.4 generates code with syntax error. The follow code is injected in the built files:
function (filepath, extMapping) {
if (!filepath.startsWith('./') && !filepath.startsWith('../')) {
// Package import
return filepath;
}
const idx = filepath.lastIndexOf('.');
if (idx === -1 || filepath.includes('/', idx)) {
// No extension
const newExt = extMapping[''];
if (newExt) {
return filepath + newExt;
}
return filepath;
}
for (let [origExt, newExt] of Object.entries(extMapping).sort((a, b) => b[0].length - a[0].length)) {
if (filepath.endsWith(origExt)) {
return filepath.slice(0, -origExt.length) + newExt;
}
}
return filepath;
}
Which is invalid JS, since the function has no name. v1.1.3 works great.