fryorcraken.eth 0b93fdd76d
chore: extract exports path from package.json for rollup
Also sort eslint to lint JavaScript ESM files successfully.

Fixes #933
2023-03-01 15:46:21 +11:00

22 lines
521 B
JavaScript

export function extractExports(packageJson) {
const exportsMap = packageJson.default.exports;
let input = {};
for (const exportPath in exportsMap) {
const filePath = exportsMap[exportPath].import;
let entry;
if (exportPath === ".") {
entry = "index";
} else {
if (!exportPath.startsWith("./")) {
throw `export path should start with \`./\` but starts with ${exportPath}`;
}
entry = exportPath.substring(2);
}
input[entry] = filePath;
}
return input;
}