From 6fce2ed032349a3cc14baa4af54b771f4cc2224e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marius=20Lundga=CC=8Ard?= Date: Tue, 30 Aug 2022 16:35:05 +0200 Subject: [PATCH] fix: target parsing --- src/build/build.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/build/build.ts b/src/build/build.ts index 2d4d5b0d..409e71ff 100644 --- a/src/build/build.ts +++ b/src/build/build.ts @@ -49,6 +49,17 @@ export async function build(options: { const srcPath = path.resolve(cwd, config?.src || 'src') const distPath = path.resolve(cwd, config?.dist || 'dist') + const nodeTarget = _parseNodeTarget(targetVersions) + const webTarget = _parseWebTarget(targetVersions) + + if (!nodeTarget) { + throw new Error('no matching `node` target') + } + + if (!webTarget) { + throw new Error('no matching `web` target') + } + const context: _BuildContext = { config, cwd, @@ -59,10 +70,7 @@ export async function build(options: { dist: path.relative(cwd, distPath), pkg, src: path.relative(cwd, srcPath), - target: { - node: _parseNodeTarget(targetVersions) || _DEFAULTS.target.node, - web: _parseWebTarget(targetVersions) || _DEFAULTS.target.web, - }, + target: {node: nodeTarget, web: webTarget}, tsconfig, }