From dd00c6b0c12f8e0a032168b4832b0cba622bf131 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Wed, 3 Oct 2018 13:56:27 -0400 Subject: [PATCH] Warn about duplicate api.mainModule paths, like api.addFiles does. This would have helped catch the underlying problem in #10234. --- tools/isobuild/package-api.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/isobuild/package-api.js b/tools/isobuild/package-api.js index 6239cfa7c17..4fff4a2d8ca 100644 --- a/tools/isobuild/package-api.js +++ b/tools/isobuild/package-api.js @@ -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 = { @@ -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) {