Skip to content

Commit

Permalink
Fix and reenable windows scope-hoisting tests (#2537)
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic authored and devongovett committed Jan 15, 2019
1 parent 58a0348 commit a4eb94e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 33 deletions.
9 changes: 0 additions & 9 deletions packages/core/integration-tests/test/scope-hoisting.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
54 changes: 30 additions & 24 deletions packages/core/parcel-bundler/src/packagers/JSConcatPackager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit a4eb94e

Please sign in to comment.