From ff2dd443641ad2b72b1e22c2075a20099222e2c6 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Wed, 4 May 2022 12:23:10 +0200 Subject: [PATCH] feat(rollup): fail build when externals are not allowed and cannot resolve id --- src/rollup/config.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/rollup/config.ts b/src/rollup/config.ts index 3faeb5f33a..0e87175793 100644 --- a/src/rollup/config.ts +++ b/src/rollup/config.ts @@ -275,6 +275,16 @@ export const plugins = [ 'import' ] }))) + } else { + rollupConfig.plugins.push({ + name: 'no-externals', + async resolveId (id, from, options) { + const resolved = await this.resolve(id, from, { ...options, skipSelf: true }) + if (!resolved || resolved.external) { + throw new Error(`Cannot resolve ${JSON.stringify(id)} from ${JSON.stringify(from)} and externals are not allowed!`) + } + } + }) } // https://github.com/rollup/plugins/tree/master/packages/node-resolve