Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update UglifyJS transformation #416

Merged
merged 9 commits into from
Apr 24, 2018
64 changes: 24 additions & 40 deletions lib/migrate/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -61,40 +61,32 @@ module.exports = {
exports[`transform should respect recast options 1`] = `
"
module.exports = {
devtool: 'eval',

entry: [
devtool: 'eval',
entry: [
'./src/index'
],

output: {
output: {
path: path.join(__dirname, 'dist'),
filename: 'index.js'
},

module: {
module: {
rules: [{
test: /\.js$/,
test: /.js$/,
use: [{
loader: \\"babel-loader\\",
}],
include: path.join(__dirname, 'src')
}]
},

resolve: {
resolve: {
modules: ['node_modules', path.resolve('/src')],
},

plugins: [
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
}),
new webpack.LoaderOptionsPlugin({
debug: true,
minimize: true,
})
],
plugins: [new webpack.LoaderOptionsPlugin({
debug: true,
})],
optimization: {
minimize: true,
}
};
"
`;
Expand Down Expand Up @@ -135,40 +127,32 @@ module.exports = {
exports[`transform should transform using all transformations 1`] = `
"
module.exports = {
devtool: 'eval',

entry: [
devtool: 'eval',
entry: [
'./src/index'
],

output: {
output: {
path: path.join(__dirname, 'dist'),
filename: 'index.js'
},

module: {
module: {
rules: [{
test: /\.js$/,
test: /.js$/,
use: [{
loader: 'babel-loader'
}],
include: path.join(__dirname, 'src')
}]
},

resolve: {
resolve: {
modules: ['node_modules', path.resolve('/src')]
},

plugins: [
new webpack.optimize.UglifyJsPlugin({
sourceMap: true
}),
new webpack.LoaderOptionsPlugin({
debug: true,
minimize: true
})
]
plugins: [new webpack.LoaderOptionsPlugin({
debug: true
})],
optimization: {
minimize: true
}
};
"
`;
118 changes: 100 additions & 18 deletions lib/migrate/uglifyJsPlugin/__snapshots__/uglifyJsPlugin.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,118 @@

exports[`uglifyJsPlugin transforms correctly using "uglifyJsPlugin-0" data 1`] = `
"module.exports = {
plugins: [
new webpack.optimize.UglifyJsPlugin({
sourceMap: true
})
]
optimization: {
minimize: true
}
}
"
`;

exports[`uglifyJsPlugin transforms correctly using "uglifyJsPlugin-1" data 1`] = `
"module.exports = {
"const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
module.exports = {
devtool: \\"source-map\\",
plugins: [
new webpack.optimize.UglifyJsPlugin({
sourceMap: true
})
]
optimization: {
minimize: true,

minimizer: [new UglifyJsPlugin({
sourceMap: true,
compress: {}
})]
}
}
"
`;

exports[`uglifyJsPlugin transforms correctly using "uglifyJsPlugin-2" data 1`] = `
"const Uglify = require('uglifyjs-webpack-plugin');
module.exports = {
devtool: \\"source-map\\",
optimization: {
minimize: true,

minimizer: [new Uglify({
sourceMap: true,
compress: {}
})]
}
}
"
`;

exports[`uglifyJsPlugin transforms correctly using "uglifyJsPlugin-3" data 1`] = `
"module.exports = {
devtool: \\"cheap-source-map\\",
plugins: [
new webpack.optimize.UglifyJsPlugin({
compress: {},
devtool: 'eval',

entry: [
'./src/index'
],

output: {
path: path.join(__dirname, 'dist'),
filename: 'index.js'
},

module: {
loaders: [{
test: /.js$/,
loaders: ['babel'],
include: path.join(__dirname, 'src')
}]
},

resolve: {
root: path.resolve('/src'),
modules: ['node_modules']
},

plugins: [new webpack.optimize.OccurrenceOrderPlugin()],
debug: true,

optimization: {
minimize: true
}
};
"
`;

exports[`uglifyJsPlugin transforms correctly using "uglifyJsPlugin-4" data 1`] = `
"const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
module.exports = {
devtool: 'eval',

entry: [
'./src/index'
],

output: {
path: path.join(__dirname, 'dist'),
filename: 'index.js'
},

module: {
loaders: [{
test: /.js$/,
loaders: ['babel'],
include: path.join(__dirname, 'src')
}]
},

resolve: {
root: path.resolve('/src'),
modules: ['node_modules']
},

plugins: [new webpack.optimize.OccurrenceOrderPlugin()],
debug: true,

optimization: {
minimize: true,

minimizer: [new UglifyJsPlugin({
sourceMap: true
})
]
}
})]
}
};
"
`;
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');

module.exports = {
plugins: [
new webpack.optimize.UglifyJsPlugin()
new UglifyJsPlugin()
]
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
module.exports = {
devtool: "source-map",
plugins: [
new webpack.optimize.UglifyJsPlugin({})
new UglifyJsPlugin({
sourceMap: true,
compress: {}
})
]
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const Uglify = require('uglifyjs-webpack-plugin');
module.exports = {
devtool: "cheap-source-map",
devtool: "source-map",
plugins: [
new webpack.optimize.UglifyJsPlugin({
new Uglify({
sourceMap: true,
compress: {}
})
]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module.exports = {
devtool: 'eval',
entry: [
'./src/index'
],
output: {
path: path.join(__dirname, 'dist'),
filename: 'index.js'
},
module: {
loaders: [{
test: /.js$/,
loaders: ['babel'],
include: path.join(__dirname, 'src')
}]
},
resolve: {
root: path.resolve('/src'),
modules: ['node_modules']
},
plugins: [
new webpack.optimize.UglifyJsPlugin(),
new webpack.optimize.OccurrenceOrderPlugin()
],
debug: true
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
module.exports = {
devtool: 'eval',
entry: [
'./src/index'
],
output: {
path: path.join(__dirname, 'dist'),
filename: 'index.js'
},
module: {
loaders: [{
test: /.js$/,
loaders: ['babel'],
include: path.join(__dirname, 'src')
}]
},
resolve: {
root: path.resolve('/src'),
modules: ['node_modules']
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
sourceMap: true
}),
new webpack.optimize.OccurrenceOrderPlugin()
],
debug: true
};
Loading