-
-
Notifications
You must be signed in to change notification settings - Fork 601
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: replace uglifyJsPlugin with terserPlugin in migrate
- Loading branch information
1 parent
2106e70
commit d467f3b
Showing
8 changed files
with
209 additions
and
7 deletions.
There are no files selected for viewing
117 changes: 117 additions & 0 deletions
117
packages/migrate/terserPlugin/__snapshots__/terserPlugin.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`terserPlugin transforms correctly using "terserPlugin-0" data 1`] = ` | ||
"module.exports = { | ||
optimization: { | ||
minimize: true | ||
} | ||
}; | ||
" | ||
`; | ||
|
||
exports[`terserPlugin transforms correctly using "terserPlugin-1" data 1`] = ` | ||
"const TerserPlugin = require(\\"terser-webpack-plugin\\"); | ||
module.exports = { | ||
devtool: \\"source-map\\", | ||
optimization: { | ||
minimize: true, | ||
minimizer: [new TerserPlugin({ | ||
sourceMap: true, | ||
compress: {} | ||
})] | ||
} | ||
}; | ||
" | ||
`; | ||
|
||
exports[`terserPlugin transforms correctly using "terserPlugin-2" data 1`] = ` | ||
"const TerserPlugin = require(\\"terser-webpack-plugin\\"); | ||
module.exports = { | ||
devtool: \\"source-map\\", | ||
optimization: { | ||
minimize: true, | ||
minimizer: [new TerserPlugin({ | ||
sourceMap: true, | ||
compress: {} | ||
})] | ||
} | ||
}; | ||
" | ||
`; | ||
|
||
exports[`terserPlugin transforms correctly using "terserPlugin-3" data 1`] = ` | ||
"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 | ||
} | ||
}; | ||
" | ||
`; | ||
|
||
exports[`terserPlugin transforms correctly using "terserPlugin-4" data 1`] = ` | ||
"const TerserPlugin = require('terser-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 TerserPlugin({ | ||
sourceMap: true | ||
})] | ||
} | ||
}; | ||
" | ||
`; |
5 changes: 5 additions & 0 deletions
5
packages/migrate/terserPlugin/__testfixtures__/terserPlugin-0.input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const TerserPlugin = require("terser-webpack-plugin"); | ||
|
||
module.exports = { | ||
plugins: [new TerserPlugin()] | ||
}; |
10 changes: 10 additions & 0 deletions
10
packages/migrate/terserPlugin/__testfixtures__/terserPlugin-1.input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const TerserPlugin = require("terser-webpack-plugin"); | ||
module.exports = { | ||
devtool: "source-map", | ||
plugins: [ | ||
new TerserPlugin({ | ||
sourceMap: true, | ||
compress: {} | ||
}) | ||
] | ||
}; |
10 changes: 10 additions & 0 deletions
10
packages/migrate/terserPlugin/__testfixtures__/terserPlugin-2.input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const TerserPlugin = require("terser-webpack-plugin"); | ||
module.exports = { | ||
devtool: "source-map", | ||
plugins: [ | ||
new TerserPlugin({ | ||
sourceMap: true, | ||
compress: {} | ||
}) | ||
] | ||
}; |
23 changes: 23 additions & 0 deletions
23
packages/migrate/terserPlugin/__testfixtures__/terserPlugin-3.input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
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.TerserPlugin(), new webpack.optimize.OccurrenceOrderPlugin()], | ||
debug: true | ||
}; |
28 changes: 28 additions & 0 deletions
28
packages/migrate/terserPlugin/__testfixtures__/terserPlugin-4.input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.TerserPlugin({ | ||
sourceMap: true | ||
}), | ||
new webpack.optimize.OccurrenceOrderPlugin() | ||
], | ||
debug: true | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
"use strict"; | ||
|
||
const defineTest = require("@webpack-cli/utils/defineTest").default; | ||
|
||
defineTest(__dirname, "terserPlugin", "terserPlugin-0"); | ||
defineTest(__dirname, "terserPlugin", "terserPlugin-1"); | ||
defineTest(__dirname, "terserPlugin", "terserPlugin-2"); | ||
defineTest(__dirname, "terserPlugin", "terserPlugin-3"); | ||
defineTest(__dirname, "terserPlugin", "terserPlugin-4"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters