Skip to content

Commit

Permalink
Add do expressions proposal plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
pascalduez committed Dec 1, 2018
1 parent 3841d3e commit 1387424
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Change log

## [Unreleased]
### Added
* Added "do expressions" proposal plugin.

## 3.0.0 - 2018-11-26

Expand Down
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* [Proposals]
* https://babeljs.io/docs/en/babel-plugin-syntax-dynamic-import
* https://babeljs.io/docs/en/babel-plugin-proposal-class-properties
* https://babeljs.io/docs/en/babel-plugin-proposal-do-expressions
* https://babeljs.io/docs/en/babel-plugin-proposal-decorators
*
* [React]
Expand Down Expand Up @@ -44,6 +45,7 @@ module.exports = (context, options) => {
let plugins = [
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-do-expressions',
['@babel/plugin-proposal-decorators', { legacy: true }],
['@babel/plugin-transform-runtime', runtimeOpts],
];
Expand Down
17 changes: 17 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"dependencies": {
"@babel/plugin-proposal-class-properties": "^7.1.0",
"@babel/plugin-proposal-decorators": "^7.1.6",
"@babel/plugin-proposal-do-expressions": "^7.0.0",
"@babel/plugin-syntax-dynamic-import": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.1.0",
"@babel/preset-env": "^7.1.6",
Expand Down
8 changes: 8 additions & 0 deletions test/__snapshots__/index.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ var A = decorated(_class = function A() {
}) || _class;"
`;

exports[`do expressions 1`] = `
"\\"use strict\\";
var a = b ? 'yep' : 'nope';"
`;

exports[`dynamic imports 1`] = `
"\\"use strict\\";
Expand Down Expand Up @@ -85,6 +91,8 @@ var A = decorated(_class = function A() {
}) || _class;"
`;

exports[`esm: do expressions 1`] = `"var a = b ? 'yep' : 'nope';"`;

exports[`esm: dynamic imports 1`] = `"import('./a');"`;

exports[`esm: flow 1`] = `"var a = 'hello';"`;
Expand Down
13 changes: 13 additions & 0 deletions test/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ let cases = [
class A { a = () => 'hello' }
`,
],
[
'do expressions',
`
let a = do {
if (b) {
'yep';
}
else {
'nope';
}
};
`,
],
[
'decorators legacy',
`
Expand Down

0 comments on commit 1387424

Please sign in to comment.