-
Notifications
You must be signed in to change notification settings - Fork 84
Add tests and basic support for batch exports. #177
base: master
Are you sure you want to change the base?
Conversation
yeah, that should be it for now. maybe adding an extra export I can't find any reference in the specs about overruling /cc @guybedford @ericf |
Also, I wonder why is this not enough for commonjs format, or any other format? |
@caridy commonjs seems to need more explicit work to support this since we may have to bake the indirection provided by batch exports into the output. That is, with the bundle format we know exactly where the terminal export is and what its identifier will be in the final output. For commonjs I believe we may have to go back to using getters to support this, i.e. // a.js
export var a = 1;
// b.js
export * from './a';
// c.js
import { a } from './b';
console.log(a); would output to this: // a.js
var a = 1;
exports.a = a;
// b.js
var $$a = require('./a');
Object.defineProperties(exports, {
a: {
get: function() {
return $$a.a;
}
}
});
// c.js
var $$b = require('./b');
console.log($$b.a); An alternative approach would involve trying to reference the terminal export directly, which would get rid of the // a.js
var a = 1;
exports.a = 1;
// b.js
// in this scenario this becomes a no-op
// c.js
var $$a = require('./a');
console.log($$a.a); Thoughts? |
@caridy looking at the spec it seems like Would these changes support an output format like System.registerDynamic? |
@guybedford thanks for lookup this in the specs. @eventualbuddha I think an alternative option is to modify the internals of export. Essentially, |
After some discussion in IRC, it seems we will explorer the solution of computing the "terminal export" and make the |
@eventualbuddha any update on this one? |
cc @caridy @dominic
This is enough to make batch exports work for the bundle format, but not for CommonJS. Are there any tests that I should add that aren't covered by the pretty simple case I have here?