Skip to content

Commit

Permalink
Warn about duplicate api.mainModule paths, like api.addFiles does.
Browse files Browse the repository at this point in the history
This would have helped catch the underlying problem in #10234.
  • Loading branch information
benjamn committed Oct 3, 2018
1 parent 8f8e2a0 commit dd00c6b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tools/isobuild/package-api.js
Expand Up @@ -366,6 +366,8 @@ export class PackageAPI {
mainModule(path, arch, fileOptions = {}) {
arch = toArchArray(arch);

const errors = [];

forAllMatchingArchs(arch, a => {
const filesForArch = this.files[a];
const source = {
Expand All @@ -392,11 +394,19 @@ export class PackageAPI {
}
}

if (filesForArch.sources.some(old => source.relPath === old.relPath)) {
errors.push(`Duplicate api.mainModule: ${path}`);
}

filesForArch.main = source;
filesForArch.sources.push(source);

this._forbidExportWithLazyMain(a);
});

errors.forEach(error => {
buildmessage.error(error, { useMyCaller: 1 });
});
}

_forbidExportWithLazyMain(arch) {
Expand Down

0 comments on commit dd00c6b

Please sign in to comment.