Closed mitel closed 6 years ago
UPDATE: using Babili minification i'm now able to minify ES6 code with generator functions:
if (options.minify) {
const minifyOptions = typeof options.minify === 'object'
? options.minify
: {};
// config.plugins.push(new Webpack.optimize.UglifyJsPlugin(minifyOptions));
const babiliPluginOptions = {
babili: [
require.resolve('babel-preset-babili'), {
"mangle": {
"blacklist": {
"ctx": true,
"cb": true
},
// "keepFnName": true
},
// disables babel-plugin-minify-dead-code-elimination
// Inlines bindings when possible. Tries to evaluate expressions
// and prunes unreachable as a result.
"deadcode": false,
}
]
}
const opts = Object.assign({}, minifyOptions, babiliPluginOptions);
config.plugins.push(new BabiliPlugin(opts));
}
How do you setup with webtask-bundle? Is there a tutorial on this?
@pencilcheck webtask-bundle
exists primarily as a library that provides the --bundle
functionality to wt-cli
and is not intended to be directly consumed.
Yes this would be incredibly helpful. I've just realized that I don't think I can use regeneratorRuntime
either :( from here.
Also, here: https://github.com/auth0/wt-cli/issues/141
@ggoodman hey - any plans to add the transform-runtime
to the webpack config as suggested in the issue mentioned by @heymartinadams above?
Also @mrwillis if you use the sandbox environment from Webtask as explained here you can use Node 8 ;)
Hi Everyone,
Webtask.io now runs on Node 8 directly. Async/Away is supported. I am going to close this issue. Feel free to respond and reopen if you have any questions.
Hey @NotMyself, should this be supported now?
module.exports = async function(context) {
return { hello: context.query.name || 'Jeff' };
};
It seems to time out.
Hi @wearhere,
I think the bare minimum async webtask would look like this:
module.exports = async function(context, cb) {
const example = await Promise.resolve({
hello: context.query.name || 'Anonymous'
});
cb(null, example);
};
In your example code, the context parameter will actually be a callback function not the webtask context. See the programming models documentation for details.
In my example, we use the async
keyword to enable us to use await
sematics within the body of the function. You still need to resolve the function using the callback function.
Ah thanks for clarifying current support. I filed https://github.com/auth0/webtask-bundle/issues/31 as a follow-up.
I found a mistake regarding this issue in webtask web interface: Create new > Select a template > Async function You'll see:
Instructions: Simply export an async function and return a result directly to indicate completion. Code:
/** * @param context {WebtaskContext} */ module.exports = async function (context) { return { hello: context.query.name || 'Anonymous' }; };
But this doesn't wirk and we still need call cb rather just returning
Hello, it would be nice to have support for async/await in Webtasks. If we use babel/transform-async-to-generator, async functions will be compiled to generator functions, which are supported natively by node 4.4.5. the only drawback would be that Uglify.js will not be able to minify code with generator functions.