Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move uglify into own worker for every chunk
Moved uglify call into worker which may significantly reduce build time in projects with code splitting. This required to remove `minifier` option. Prefer using `terser` plugin instead.
- Loading branch information
Showing
8 changed files
with
92 additions
and
40 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
|
@@ -33,6 +33,6 @@ | |
"babel-jest": "^22.4.4", | ||
"jest": "^22.4.4", | ||
"prettier": "^1.12.1", | ||
"rollup": "^0.59.1" | ||
"rollup": "^0.65.0" | ||
} | ||
} |
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,40 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`works with code splitting 1`] = ` | ||
Object { | ||
"chunk-1.js": Object { | ||
"code": "var chunk1=\\"chunk-1\\";console.log(chunk1); | ||
", | ||
"exports": Array [], | ||
"fileName": "chunk-1.js", | ||
"imports": Array [], | ||
"isEntry": true, | ||
"map": null, | ||
"modules": Object { | ||
"/Users/trysound/host/rollup-plugin-uglify/test/fixtures/chunk-1.js": Object { | ||
"originalLength": 44, | ||
"removedExports": Array [], | ||
"renderedExports": Array [], | ||
"renderedLength": 44, | ||
}, | ||
}, | ||
}, | ||
"chunk-2.js": Object { | ||
"code": "var chunk2=\\"chunk-2\\";console.log(chunk2); | ||
", | ||
"exports": Array [], | ||
"fileName": "chunk-2.js", | ||
"imports": Array [], | ||
"isEntry": true, | ||
"map": null, | ||
"modules": Object { | ||
"/Users/trysound/host/rollup-plugin-uglify/test/fixtures/chunk-2.js": Object { | ||
"originalLength": 44, | ||
"removedExports": Array [], | ||
"renderedExports": Array [], | ||
"renderedLength": 44, | ||
}, | ||
}, | ||
}, | ||
} | ||
`; |
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,2 @@ | ||
var chunk1 = 'chunk-1'; | ||
console.log(chunk1) |
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,2 @@ | ||
var chunk2 = 'chunk-2'; | ||
console.log(chunk2) |
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
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,12 @@ | ||
const { minify } = require("uglify-js"); | ||
|
||
const transform = (code, options) => { | ||
const result = minify(code, options); | ||
if (result.error) { | ||
throw result.error; | ||
} else { | ||
return result; | ||
} | ||
}; | ||
|
||
exports.transform = transform; |
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