This repository has been archived by the owner on May 11, 2018. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 159
Add uglify as a target #178
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7177810
Add uglify as a target.
yavorsky bc3f958
targetOps -> targetOpts. Clean uglify for plugins.
yavorsky ed71e2a
Tests: Check Uglify values for true false and null
yavorsky e99866c
Add fixtures for uglify.
yavorsky ab0d0d5
Add test for isPluginRequired with uglify.
yavorsky 739ece5
Add semi after getBuiltInTargets.
yavorsky 5d97b4e
Add targets.uglify to docs.
yavorsky 3e8d73c
Fix grammar for README.
yavorsky 831c472
Add debug test for uglify
existentialism File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 |
---|---|---|
|
@@ -94,29 +94,33 @@ const _extends = Object.assign || function (target) { | |
|
||
|
||
export const getTargets = (targets = {}) => { | ||
const targetOps = _extends({}, targets); | ||
const targetOpts = _extends({}, targets); | ||
|
||
if (targetOps.node === true || targetOps.node === "current") { | ||
targetOps.node = getCurrentNodeVersion(); | ||
if (targetOpts.node === true || targetOpts.node === "current") { | ||
targetOpts.node = getCurrentNodeVersion(); | ||
} | ||
|
||
if (targetOpts.hasOwnProperty("uglify") && !targetOpts.uglify) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we didn't have to do this, would be good? doesn't seem necessary There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It will allow |
||
delete targetOpts.uglify; | ||
} | ||
|
||
// Replace Electron target with its Chrome equivalent | ||
if (targetOps.electron) { | ||
const electronChromeVersion = getElectronChromeVersion(targetOps.electron); | ||
if (targetOpts.electron) { | ||
const electronChromeVersion = getElectronChromeVersion(targetOpts.electron); | ||
|
||
targetOps.chrome = targetOps.chrome | ||
? Math.min(targetOps.chrome, electronChromeVersion) | ||
targetOpts.chrome = targetOpts.chrome | ||
? Math.min(targetOpts.chrome, electronChromeVersion) | ||
: electronChromeVersion; | ||
|
||
delete targetOps.electron; | ||
delete targetOpts.electron; | ||
} | ||
|
||
const browserOpts = targetOps.browsers; | ||
const browserOpts = targetOpts.browsers; | ||
if (isBrowsersQueryValid(browserOpts)) { | ||
const queryBrowsers = getLowestVersions(browserslist(browserOpts)); | ||
return mergeBrowsers(queryBrowsers, targetOps); | ||
return mergeBrowsers(queryBrowsers, targetOpts); | ||
} | ||
return targetOps; | ||
return targetOpts; | ||
}; | ||
|
||
let hasBeenLogged = false; | ||
|
@@ -143,6 +147,14 @@ const filterItem = (targets, exclusions, list, item) => { | |
return isRequired && notExcluded; | ||
}; | ||
|
||
const getBuiltInTargets = (targets) => { | ||
const builtInTargets = _extends({}, targets); | ||
if (builtInTargets.uglify != null) { | ||
delete builtInTargets.uglify; | ||
} | ||
return builtInTargets; | ||
}; | ||
|
||
export const transformIncludesAndExcludes = (opts) => ({ | ||
all: opts, | ||
plugins: opts.filter((opt) => !opt.match(/^(es\d+|web)\./)), | ||
|
@@ -157,15 +169,17 @@ export default function buildPreset(context, opts = {}) { | |
const include = transformIncludesAndExcludes(validatedOptions.include); | ||
const exclude = transformIncludesAndExcludes(validatedOptions.exclude); | ||
|
||
|
||
const filterPlugins = filterItem.bind(null, targets, exclude.plugins, pluginList); | ||
const transformations = Object.keys(pluginList) | ||
.filter(filterPlugins) | ||
.concat(include.plugins); | ||
|
||
let polyfills; | ||
let polyfillTargets; | ||
if (useBuiltIns) { | ||
const filterBuiltIns = filterItem.bind(null, targets, exclude.builtIns, builtInsList); | ||
|
||
polyfillTargets = getBuiltInTargets(targets); | ||
const filterBuiltIns = filterItem.bind(null, polyfillTargets, exclude.builtIns, builtInsList); | ||
polyfills = Object.keys(builtInsList) | ||
.concat(defaultInclude) | ||
.filter(filterBuiltIns) | ||
|
@@ -185,7 +199,7 @@ export default function buildPreset(context, opts = {}) { | |
if (useBuiltIns && polyfills.length) { | ||
console.log("\nUsing polyfills:"); | ||
polyfills.forEach((polyfill) => { | ||
logPlugin(polyfill, targets, builtInsList); | ||
logPlugin(polyfill, polyfillTargets, builtInsList); | ||
}); | ||
} | ||
} | ||
|
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,13 @@ | ||
{ | ||
"presets": [ | ||
["../../lib", { | ||
"debug": true, | ||
"targets": { | ||
"chrome": 55, | ||
"uglify": true | ||
}, | ||
"useBuiltIns": true, | ||
"modules": false | ||
}] | ||
] | ||
} |
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,41 @@ | ||
babel-preset-env: `DEBUG` option | ||
|
||
Using targets: | ||
{ | ||
"chrome": 55, | ||
"uglify": true | ||
} | ||
|
||
Modules transform: false | ||
|
||
Using plugins: | ||
transform-es2015-arrow-functions {"uglify":true} | ||
transform-es2015-block-scoped-functions {"uglify":true} | ||
transform-es2015-block-scoping {"uglify":true} | ||
transform-es2015-classes {"uglify":true} | ||
transform-es2015-computed-properties {"uglify":true} | ||
check-es2015-constants {"uglify":true} | ||
transform-es2015-destructuring {"uglify":true} | ||
transform-es2015-for-of {"uglify":true} | ||
transform-es2015-function-name {"uglify":true} | ||
transform-es2015-literals {"uglify":true} | ||
transform-es2015-object-super {"uglify":true} | ||
transform-es2015-parameters {"uglify":true} | ||
transform-es2015-shorthand-properties {"uglify":true} | ||
transform-es2015-spread {"uglify":true} | ||
transform-es2015-sticky-regex {"uglify":true} | ||
transform-es2015-template-literals {"uglify":true} | ||
transform-es2015-typeof-symbol {"uglify":true} | ||
transform-es2015-unicode-regex {"uglify":true} | ||
transform-regenerator {"uglify":true} | ||
transform-exponentiation-operator {"uglify":true} | ||
transform-async-to-generator {"uglify":true} | ||
syntax-trailing-function-commas {"chrome":55,"uglify":true} | ||
|
||
Using polyfills: | ||
es7.string.pad-start {"chrome":55} | ||
es7.string.pad-end {"chrome":55} | ||
web.timers {"chrome":55} | ||
web.immediate {"chrome":55} | ||
web.dom.iterable {"chrome":55} | ||
src/in.js -> lib/in.js |
File renamed without changes.
File renamed without changes.
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,3 @@ | ||
import "babel-polyfill"; | ||
|
||
const a = 1; |
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 @@ | ||
import "core-js/modules/es7.string.pad-start"; | ||
import "core-js/modules/es7.string.pad-end"; | ||
import "core-js/modules/web.timers"; | ||
import "core-js/modules/web.immediate"; | ||
import "core-js/modules/web.dom.iterable"; | ||
import "regenerator-runtime/runtime"; | ||
|
||
|
||
var a = 1; |
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 @@ | ||
{ | ||
"presets": [ | ||
["../../../../lib", { | ||
"targets": { | ||
"chrome": 55, | ||
"uglify": true | ||
}, | ||
"modules": false, | ||
"useBuiltIns": 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
although currently we only support uglify2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hzoo I think 1 also. No?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I just mean it's the same for whatever value