From a4eb94ec04caeaf0122f72368b677336939e2667 Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig Date: Tue, 15 Jan 2019 03:02:58 +0100 Subject: [PATCH] Fix and reenable windows scope-hoisting tests (#2537) --- .../integration-tests/test/scope-hoisting.js | 9 ---- .../src/packagers/JSConcatPackager.js | 54 ++++++++++--------- 2 files changed, 30 insertions(+), 33 deletions(-) diff --git a/packages/core/integration-tests/test/scope-hoisting.js b/packages/core/integration-tests/test/scope-hoisting.js index 16f90cb5e4b..0632164f044 100644 --- a/packages/core/integration-tests/test/scope-hoisting.js +++ b/packages/core/integration-tests/test/scope-hoisting.js @@ -7,15 +7,6 @@ const bundle = (name, opts = {}) => _bundle(name, Object.assign({scopeHoist: true}, opts)); describe('scope hoisting', function() { - if (process.platform === 'win32') { - // eslint-disable-next-line no-console - console.warn( - 'WARNING: Scope hoisting tests are disabled on windows due to ' + - 'filesystem errors. Feel free to look into this and contribute a fix!' - ); - return; - } - describe('es6', function() { it('supports default imports and exports of expressions', async function() { let b = await bundle( diff --git a/packages/core/parcel-bundler/src/packagers/JSConcatPackager.js b/packages/core/parcel-bundler/src/packagers/JSConcatPackager.js index 5500b648667..bffd16ed9e8 100644 --- a/packages/core/parcel-bundler/src/packagers/JSConcatPackager.js +++ b/packages/core/parcel-bundler/src/packagers/JSConcatPackager.js @@ -513,36 +513,42 @@ class JSConcatPackager extends Packager { `); } - let ast = t.file(t.program(this.statements)); - let {code: output} = concat(this, ast); + try { + let ast = t.file(t.program(this.statements)); + let {code: output} = concat(this, ast); - if (!this.options.minify) { - output = '\n' + output + '\n'; - } + if (!this.options.minify) { + output = '\n' + output + '\n'; + } - let preludeCode = this.options.minify ? prelude.minified : prelude.source; - if (this.needsPrelude) { - output = preludeCode + '(function (require) {' + output + '});'; - } else { - output = '(function () {' + output + '})();'; - } + let preludeCode = this.options.minify ? prelude.minified : prelude.source; + if (this.needsPrelude) { + output = preludeCode + '(function (require) {' + output + '});'; + } else { + output = '(function () {' + output + '})();'; + } - this.size = output.length; + this.size = output.length; - let {sourceMaps} = this.options; - if (sourceMaps) { - // Add source map url if a map bundle exists - let mapBundle = this.bundle.siblingBundlesMap.get('map'); - if (mapBundle) { - let mapUrl = urlJoin( - this.options.publicURL, - path.basename(mapBundle.name) - ); - output += `\n//# sourceMappingURL=${mapUrl}`; + let {sourceMaps} = this.options; + if (sourceMaps) { + // Add source map url if a map bundle exists + let mapBundle = this.bundle.siblingBundlesMap.get('map'); + if (mapBundle) { + let mapUrl = urlJoin( + this.options.publicURL, + path.basename(mapBundle.name) + ); + output += `\n//# sourceMappingURL=${mapUrl}`; + } } - } - await super.write(output); + await super.write(output); + } catch (e) { + throw e; + } finally { + await super.end(); + } } resolveModule(id, name) {