Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect rendering of export declarations in SystemJS #4202

Merged
merged 1 commit into from Aug 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ast/nodes/VariableDeclaration.ts
Expand Up @@ -176,6 +176,7 @@ export default class VariableDeclaration extends NodeBase {
code.remove(start, end);
continue;
}
node.render(code, options);
leadingString = '';
nextSeparatorString = '';
if (
Expand Down Expand Up @@ -217,7 +218,6 @@ export default class VariableDeclaration extends NodeBase {
code.overwrite(lastSeparatorPos, lastSeparatorPos + 1, separatorString);
code.appendLeft(renderedContentEnd, leadingString);
}
node.render(code, options);
actualContentEnd = contentEnd;
renderedContentEnd = end;
hasRenderedContent = true;
Expand Down
4 changes: 4 additions & 0 deletions test/form/samples/simplified-initializer/_config.js
@@ -0,0 +1,4 @@
module.exports = {
description: 'handles simplified variable initializers',
options: { output: { name: 'bundle' } }
};
13 changes: 13 additions & 0 deletions test/form/samples/simplified-initializer/_expected/amd.js
@@ -0,0 +1,13 @@
define(['exports'], function (exports) { 'use strict';

const a = window.config ? 1 : 2;
const b = 1 ;
const c = 2;

exports.a = a;
exports.b = b;
exports.c = c;

Object.defineProperty(exports, '__esModule', { value: true });

});
11 changes: 11 additions & 0 deletions test/form/samples/simplified-initializer/_expected/cjs.js
@@ -0,0 +1,11 @@
'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const a = window.config ? 1 : 2;
const b = 1 ;
const c = 2;

exports.a = a;
exports.b = b;
exports.c = c;
5 changes: 5 additions & 0 deletions test/form/samples/simplified-initializer/_expected/es.js
@@ -0,0 +1,5 @@
const a = window.config ? 1 : 2;
const b = 1 ;
const c = 2;

export { a, b, c };
16 changes: 16 additions & 0 deletions test/form/samples/simplified-initializer/_expected/iife.js
@@ -0,0 +1,16 @@
var bundle = (function (exports) {
'use strict';

const a = window.config ? 1 : 2;
const b = 1 ;
const c = 2;

exports.a = a;
exports.b = b;
exports.c = c;

Object.defineProperty(exports, '__esModule', { value: true });

return exports;

}({}));
12 changes: 12 additions & 0 deletions test/form/samples/simplified-initializer/_expected/system.js
@@ -0,0 +1,12 @@
System.register('bundle', [], function (exports) {
'use strict';
return {
execute: function () {

const a = exports('a', window.config ? 1 : 2);
const b = exports('b', 1 );
const c = exports('c', 2);

}
};
});
17 changes: 17 additions & 0 deletions test/form/samples/simplified-initializer/_expected/umd.js
@@ -0,0 +1,17 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bundle = {}));
}(this, (function (exports) { 'use strict';

const a = window.config ? 1 : 2;
const b = 1 ;
const c = 2;

exports.a = a;
exports.b = b;
exports.c = c;

Object.defineProperty(exports, '__esModule', { value: true });

})));
3 changes: 3 additions & 0 deletions test/form/samples/simplified-initializer/main.js
@@ -0,0 +1,3 @@
export const a = window.config ? 1 : 2
export const b = true ? 1 : 2
export const c = false ? 1 : 2
Expand Up @@ -21,7 +21,6 @@ module.exports = {
},
before() {
fs.readFile = (path, options, callback) => {
console.log('mock read');
currentReads++;
maxReads = Math.max(maxReads, currentReads);
fsReadFile(path, options, (err, data) => {
Expand Down