This repository has been archived by the owner on Mar 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 55
chore(babel): switch to Babel in distribution #1404
Merged
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7ab4d33
chore(package): use Babel
layershifter 7bcfc47
Merge branches 'chore/babel' and 'master' of https://github.com/stard…
layershifter e62e229
Merge branches 'chore/babel' and 'master' of https://github.com/stard…
layershifter 77e0a82
remove default false
layershifter e8a9e3e
update name
layershifter 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
### Browsers that we support | ||
|
||
>0.2% | ||
not dead | ||
not ie < 11 | ||
not op_mini all |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,18 +1,23 @@ | ||
const isBabelRegister = caller => { | ||
return !!(caller && caller.name === '@babel/register') | ||
const isNodeCaller = caller => { | ||
return caller && (caller.name === '@babel/register' || caller.name === 'babel-jest') | ||
} | ||
const isJest = caller => { | ||
return !!(caller && caller.name === 'babel-jest') | ||
const isDistCaller = caller => { | ||
return !!(caller && caller.name === 'babel-gulp') | ||
} | ||
const supportsESM = caller => { | ||
return !!((caller && caller.name === 'babel-loader') || caller.useESModules) | ||
} | ||
|
||
module.exports = api => { | ||
const isNode = api.caller(isBabelRegister) || api.caller(isJest) | ||
const isDistBuild = api.caller(isDistCaller) | ||
const isNode = api.caller(isNodeCaller) | ||
const useESModules = !isNode && api.caller(supportsESM) | ||
|
||
const presets = [ | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
modules: isNode ? 'cjs' : false, | ||
modules: useESModules ? false : 'cjs', | ||
targets: isNode ? { node: '8' } : undefined, | ||
exclude: ['transform-async-to-generator'], | ||
}, | ||
|
@@ -23,8 +28,10 @@ module.exports = api => { | |
const plugins = [ | ||
'@babel/plugin-proposal-class-properties', | ||
'@babel/plugin-syntax-dynamic-import', | ||
'@babel/plugin-transform-runtime', | ||
] | ||
['@babel/plugin-transform-runtime', { corejs: false, useESModules }], | ||
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.
|
||
|
||
isDistBuild && 'lodash', | ||
].filter(Boolean) | ||
|
||
return { | ||
presets, | ||
|
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
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
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
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
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.
nit: probably,
isDistBundle
name will better reflect semantics and related optimizations applied for this scenario