Open davidblurton opened 10 years ago
I just ran into this as well.
I fixed this problem using the following in my Brocfile:
var options = {
esnextOptions: {
includeRuntime: true
}
};
var app = new EmberApp(options);
The downside of this is that any file will include the regenerator runtime, which increase the file size.
@marcioj - Does this include the runtime in each file or only once?
@rwjblue for each file. This is the output of a development build with wrapInEval: false https://gist.github.com/marcioj/fe66d033e020840ee40f
Ok, I'll update this to add it once so it doesn't get embedded so many times.
I know you're very busy these days because htmlbars so I gave a look in this problem.
I believe we will need to include runtime.js in broccoli and in each file, prepend a import regeneratorRuntime from 'regenerator'
or leave the user add this by hand. My only concern is how to include this file, because it isn't a direct dependency of ember-cli-esnext but instead is ember-cli-esnext => broccoli-esnext => esnext => regenerator
. Regenerator itself saves the path in require('regenerator').path, but this info isn't passed up. The only thing that comes to my mind is to require broccoli-esnext/node_modules/esnext/node_modules/regenerator
but it's very hacky.
Generally, I think we would vendor the runtime here, and use app.import
once to add it to the vendor bundle (and not for each file). I am not 100% sure how the esnext transpiled code looks for the wrapGenerator
function though.
@marcioj - Can you gist a sample (non-eval'ed) my-app.js
file (so we can make a gameplan)?
@rwjblue sure. Basically
model: async function() {
var users = await this.store.find('user');
console.log(users.get('firstObject.name'));
}
becomes
model: function callee$0$0() {
var users;
return regeneratorRuntime.async(function callee$0$0$(context$1$0) {
while (1) switch (context$1$0.prev = context$1$0.next) {
case 0:
context$1$0.next = 2;
return this.store.find('user');
case 2:
users = context$1$0.sent;
console.log(users.get('firstObject.name'));
case 4:
case "end":
return context$1$0.stop();
}
}, null, this);
}
Full code https://gist.github.com/marcioj/f32d833a702a49230afb. That time I taked just the index route, to keep the file smaller.
just ran into this issue also
Not sure why this is happening but the wrapGenerator function is undefined. Fixed by manually including https://github.com/facebook/regenerator/blob/master/runtime/min.js in the ember app