-
-
Notifications
You must be signed in to change notification settings - Fork 645
Description
Do you want to request a feature or report a bug?
Feature
What is the current behavior?
Poorly formatted configs, or new ast nodes that are generated appear inline and hard to read after --migrate.
If the current behavior is a bug, please provide the steps to reproduce.
What is the expected behavior?
Be prettier (put intended) than what is output now.
If this is a feature request, what is motivation or use case for changing the behavior?
I was able to add @jlongster's prettier and pass the string in to be formatted:
Below is how I implemented this feature (at a very rough level).
transformations/index.js
return pretty.format(ast.toSource(recastOptions), {singleQuote: true, tabWidth: 4});The results were, damn fine looking!
var path = require('path');
var webpack = require('webpack');
// lets take this webpack v1 config and migrate it to v2 !!! <3333
module.exports = {
debug: true,
devtool: 'eval',
entry: ['./src/index'],
output: {
path: path.join(__dirname, 'dist'),
filename: 'index.js'
},
plugins: [
new webpack.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true
}),
new webpack.optimize.LoaderOptionsPlugin({
debug: true,
minimize: true
})
],
resolve: {
modules: ['foo']
},
module: {
rules: [
{
test: /\.js$/,
use: 'babel-loader',
include: path.join(__dirname, 'src')
}
]
}
};Thoughts @pksjce @ev1stensberg @kenwheeler @okonet? Spoke with folks at prettier and they said if passing a direct string is a concern and overhead we could look into the future passing a direct AST.