From 3c1c7db9559771af7df9f39ead4513b56afd3c9b Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Tue, 5 May 2020 22:34:11 +0200 Subject: [PATCH] Write sourcemaps for the serve mode's default target again (#4569) * Add test * Fix * Update packages/core/core/test/TargetResolver.test.js Co-authored-by: Jasper De Moor Co-authored-by: Will Binns-Smith Co-authored-by: Jasper De Moor --- packages/core/core/src/TargetResolver.js | 1 + .../core/core/test/TargetResolver.test.js | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/packages/core/core/src/TargetResolver.js b/packages/core/core/src/TargetResolver.js index 011a4bf9134..420b4a8366f 100644 --- a/packages/core/core/src/TargetResolver.js +++ b/packages/core/core/src/TargetResolver.js @@ -175,6 +175,7 @@ export default class TargetResolver { name: 'default', distDir: this.options.distDir, publicUrl: this.options.publicUrl ?? '/', + sourceMap: this.options.sourceMaps ? {} : undefined, env: createEnvironment({ context: 'browser', engines: { diff --git a/packages/core/core/test/TargetResolver.test.js b/packages/core/core/test/TargetResolver.test.js index 7573e6d9aa7..83897bb9a84 100644 --- a/packages/core/core/test/TargetResolver.test.js +++ b/packages/core/core/test/TargetResolver.test.js @@ -547,6 +547,44 @@ describe('TargetResolver', () => { ); }); + it('generates a default target in serve mode', async () => { + let targetResolver = new TargetResolver({ + ...DEFAULT_OPTIONS, + serve: {port: 1234}, + }); + + assert.deepEqual( + await targetResolver.resolve(COMMON_TARGETS_FIXTURE_PATH), + { + targets: [ + { + name: 'default', + distDir: DEFAULT_OPTIONS.distDir, + publicUrl: '/', + env: { + context: 'browser', + engines: { + browsers: [ + 'last 1 Chrome version', + 'last 1 Safari version', + 'last 1 Firefox version', + 'last 1 Edge version', + ], + }, + includeNodeModules: true, + outputFormat: 'global', + isLibrary: false, + minify: false, + scopeHoist: false, + }, + sourceMap: {}, + }, + ], + files: [], + }, + ); + }); + it('rejects invalid or unknown fields', async () => { let code = '{\n' +