@pkgr/es-modules
Version:
Union collections of es modules mappings for pkgs without or with incorrect `module` field
35 lines • 996 B
JavaScript
export const MODULE_DEFINITIONS = {
dayjs: {
target: 'dayjs/esm',
exact: false,
},
lodash: {
target: 'lodash-es',
exact: false,
},
};
const defEntries = Object.entries(MODULE_DEFINITIONS);
export const entries = defEntries.reduce((acc, [module, definition]) => {
const { target, exact } = typeof definition === 'string'
? { target: definition, exact: true }
: definition;
acc.push({
find: module,
replacement: target,
});
if (!exact) {
acc.push({
find: new RegExp('^' + module + '/(.*)$'),
replacement: target + '/$1',
});
}
return acc;
}, []);
export const alias = defEntries.reduce((acc, [module, definition]) => {
const { target, exact } = typeof definition === 'string'
? { target: definition, exact: true }
: definition;
acc[exact ? module + '$' : module] = target;
return acc;
}, {});
//# sourceMappingURL=index.js.map