diff --git a/test/fixtures/build-withConfig/src/index.ts b/test/fixtures/build-withConfig/src/index.ts index 90a62171f..b93cbd2ec 100644 --- a/test/fixtures/build-withConfig/src/index.ts +++ b/test/fixtures/build-withConfig/src/index.ts @@ -6,4 +6,4 @@ export const sum = (a: number, b: number) => { const bar = split('bar'); -console.log(`${split('bar').join('')} ${sum(bar.length, -3)}`); +export const signature = `${split('bar').join('')} ${sum(bar.length, -3)}`; diff --git a/test/fixtures/build-withConfig/tsdx.config.closure-advanced.js b/test/fixtures/build-withConfig/tsdx.config.closure-advanced.js index 59c86e9f3..1decbc3ab 100644 --- a/test/fixtures/build-withConfig/tsdx.config.closure-advanced.js +++ b/test/fixtures/build-withConfig/tsdx.config.closure-advanced.js @@ -1,11 +1,4 @@ -const fs = require('fs-extra'); - module.exports = { - rollup(config, options) { - const plugins = config.plugins.map(plugin => plugin.name); - fs.writeJSON('./plugins.json', plugins); - return config; - }, closureCompilerOptions: { compilation_level: 'ADVANCED_OPTIMIZATIONS', }, diff --git a/test/fixtures/build-withConfig/tsdx.config.closure-simple.js b/test/fixtures/build-withConfig/tsdx.config.closure-simple.js index 70b8801be..8d88cf212 100644 --- a/test/fixtures/build-withConfig/tsdx.config.closure-simple.js +++ b/test/fixtures/build-withConfig/tsdx.config.closure-simple.js @@ -1,7 +1,6 @@ module.exports = { - /* SIMPLE_OPTIMIZATIONS by default closureCompilerOptions: { - compilation_level: 'SIMPLE_OPTIMIZATIONS', + //SIMPLE_OPTIMIZATIONS level is default option + //compilation_level: 'SIMPLE_OPTIMIZATIONS', }, - */ }; diff --git a/test/tests/tsdx-build-closure-compiler.test.js b/test/tests/tsdx-build-closure-compiler.test.js index f81fda9e6..c9ef19c1c 100644 --- a/test/tests/tsdx-build-closure-compiler.test.js +++ b/test/tests/tsdx-build-closure-compiler.test.js @@ -14,7 +14,7 @@ describe('tsdx build with closure compiler', () => { util.teardownStage(stageName); }); - it('should compile files with default options', () => { + it('should minify bundle with default options', () => { util.setupStageWithFixture(stageName, 'build-withConfig'); shell.mv('-f', 'tsdx.config.closure-simple.js', 'tsdx.config.js'); @@ -36,12 +36,14 @@ describe('tsdx build with closure compiler', () => { expect(shell.test('-f', 'dist/index.d.ts')).toBeTruthy(); - output = shell.exec('node dist/index.js'); - expect(output.code).toBe(0); + // only closure compiler minifies bundle to `signature="bar 0"` + output = shell.grep('bar 0', [ + 'dist/build-withconfig.esm.production.min.js', + ]); expect(/bar 0/.test(output.stdout)).toBeTruthy(); }); - it('should compile files with advanced options', () => { + it('should minify bundle with advanced options', () => { util.setupStageWithFixture(stageName, 'build-withConfig'); shell.mv('-f', 'tsdx.config.closure-advanced.js', 'tsdx.config.js'); @@ -50,11 +52,6 @@ describe('tsdx build with closure compiler', () => { ); expect(output.code).toBe(0); - // ensure we use closure-compiler instead of terser - const plugins = require(`../../${stageName}/plugins.json`); - expect(plugins.includes('closure-compiler')).toBeTruthy(); - expect(plugins.includes('terser')).toBeFalsy(); - expect(shell.test('-f', 'dist/index.js')).toBeTruthy(); expect( shell.test('-f', 'dist/build-withconfig.cjs.development.js') @@ -68,8 +65,10 @@ describe('tsdx build with closure compiler', () => { expect(shell.test('-f', 'dist/index.d.ts')).toBeTruthy(); - output = shell.exec('node dist/index.js'); - expect(output.code).toBe(0); + // only closure compiler minifies bundle to `signature="bar 0"` + output = shell.grep('bar 0', [ + 'dist/build-withconfig.esm.production.min.js', + ]); expect(/bar 0/.test(output.stdout)).toBeTruthy(); });