diff --git a/packages/build/bin/compile-package.js b/packages/build/bin/compile-package.js index e1012068681a..7b4859778e5f 100755 --- a/packages/build/bin/compile-package.js +++ b/packages/build/bin/compile-package.js @@ -71,7 +71,11 @@ function run(argv, options) { var outDir; - if (!isOutDirSet) { + if (isOutDirSet) { + const outDirIx = compilerOpts.indexOf('--outDir'); + outDir = path.resolve(process.cwd(), compilerOpts[outDirIx + 1]); + compilerOpts.splice(outDirIx, 2); + } else { outDir = path.join(packageDir, utils.getDistribution(target)); } @@ -121,7 +125,7 @@ function run(argv, options) { } if (outDir) { - args.push('--outDir', outDir); + args.push('--outDir', path.relative(cwd, outDir)); // Since outDir is set, ts files are compiled into that directory. // If ignore-resources flag is not passed, copy resources (non-ts files) diff --git a/packages/build/test/integration/scripts.integration.js b/packages/build/test/integration/scripts.integration.js index 376cd10fd446..7de1ad547e27 100644 --- a/packages/build/test/integration/scripts.integration.js +++ b/packages/build/test/integration/scripts.integration.js @@ -156,7 +156,7 @@ describe('build', function() { true, ); assert( - command.indexOf('--outDir ./dist') !== -1, + command.indexOf('--outDir dist') !== -1, '--outDir should be honored', ); });