kneden
kneden copied to clipboard
Usage alongside babel-preset-stage-*
I could not get kneden working with babel-preset-stage-0 despite my efforts, does anyone know of the proper way to achieve that?
https://github.com/julien-f/kneden-stage-0
You could simply include all plugins from stage-0, stage-1, stage-2, stage-3 except of transform-async-to-generator alongside with kneden
I know but it's far from perfect, I know have to monitor changes in stage-* by myself to reflect them in my project…
@julien-f I will be releasing a reasonably decent solution for this issue soon. Crawls a babel preset tree and serializes it to relative filepaths, which you can then mutate as you please via modify-babel-preset:
var modify = require('modify-babel-preset');
module.exports = modify('stage-0', {
'transform-async-to-generator': false, // remove it
'kneden': true // add it
});
@developit Nice! :)
@developit 's solution looks great, would be nice to add a note on it to the README.
I will try to publish the recursive preset fix ASAP.
The solution there isn't working for me. It continues to transform it using generators. If I remove the modified-stage-1-preset then it works (but of course, I lose the other stuff in stages 1-3).
// dev/modified-stage-1-preset.js
var modify = require('modify-babel-preset');
module.exports = modify('stage-1', {
'transform-async-to-generator': false, // remove it
});
// .babelrc
{
"presets": [
"es2015",
"./dev/modified-stage-1-preset.js",
"react"
],
"plugins": [
"babel-plugin-async-to-promises"
]
}
@brigand Correct, the current version of modify-babel-preset does not support recursive transformations. Since the stage-0 stage-1 or stage-2 babel presets all rely on recursion (eg: stage-1 includes 2, which includes 3), we are all waiting on me to release the update.
Perhaps it'd be worth skipping the last test replication I've been having issues with and publishing it under a beta tag? The new version would support exactly what you described.
@brigand Just a note, I've published modify-babel-preset@beta (2.0.0), which should support what you posted.
@developit Getting an error. Same code as I posted above.
resolve failed: [TypeError: Cannot read property 'substring' of undefined] undefined
/Users/fb/github/client2/node_modules/modify-babel-preset/lib/serialize.js:76
if (!mod) throw new Error('Preset "'+name+'" not found.');
^
Error: Preset "undefined" not found.
at loadPreset (/Users/fb/github/client2/node_modules/modify-babel-preset/lib/serialize.js:76:18)
@brigand Do you have babel-preset-stage-1 installed directly in /Users/fb/github/client2, or is it installed within babel-preset-stage-0?
I have it installed directly.
I want kneden 😫
Tried below piece of code
"babel": {
"plugins": ["async-to-promises"],
"presets": ["react", "es2015", "stage-0-kneden"],
}
But no luck for me
Hi everyone, I solved this issue by creating a custom preset.
https://github.com/nodegin/babel-preset-stage-0-promises
In your .babelrc:
{
"babel": {
"presets": ["react", "es2015", "stage-0-promises"]
}
}
Now the plugin works perfectly
@nodegin nice work! It's even using modify-babel-preset 😍
@developit lol thanks but why you don't update your preset
What do you mean?
@developit I mean the babel-preset-stage-0-kneden
Ah - so it was broken when using modify-babel-preset 1.x, which lead me down the rabbit hole that resulted in 2.x, but I never went back and updated it haha.