-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an option to Babylon to have decorators before export (#7869)
* Add support for plugin options in Babylon They work similarly to how they work in Babel. e.g. babylon.parse({ options: [ "plugin1", ["plugin2", { option: true }] ] }); The inernal api to get an option is this.getPluginOption("pluginName", "option") If the plugin isn't defined, it returns undefined. * Add Babylon option decorators.secoratorsBeforeExport * Nit
- Loading branch information
1 parent
a955efa
commit e45d5c3
Showing
17 changed files
with
490 additions
and
25 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
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
1 change: 1 addition & 0 deletions
1
...rators-2/decoratorsBeforeExport-export-default-decorated-expression-with-parens/input.mjs
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 @@ | ||
export default (@decorator class Foo {}) |
6 changes: 6 additions & 0 deletions
6
...ors-2/decoratorsBeforeExport-export-default-decorated-expression-with-parens/options.json
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 @@ | ||
{ | ||
"sourceType": "module", | ||
"plugins": [ | ||
["decorators", { "decoratorsBeforeExport": true }] | ||
] | ||
} |
136 changes: 136 additions & 0 deletions
136
...tors-2/decoratorsBeforeExport-export-default-decorated-expression-with-parens/output.json
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,136 @@ | ||
{ | ||
"type": "File", | ||
"start": 0, | ||
"end": 40, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 40 | ||
} | ||
}, | ||
"program": { | ||
"type": "Program", | ||
"start": 0, | ||
"end": 40, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 40 | ||
} | ||
}, | ||
"sourceType": "module", | ||
"body": [ | ||
{ | ||
"type": "ExportDefaultDeclaration", | ||
"start": 0, | ||
"end": 40, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 0 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 40 | ||
} | ||
}, | ||
"declaration": { | ||
"type": "ClassExpression", | ||
"start": 16, | ||
"end": 39, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 16 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 39 | ||
} | ||
}, | ||
"decorators": [ | ||
{ | ||
"type": "Decorator", | ||
"start": 16, | ||
"end": 26, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 16 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 26 | ||
} | ||
}, | ||
"callee": { | ||
"type": "Identifier", | ||
"start": 17, | ||
"end": 26, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 17 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 26 | ||
}, | ||
"identifierName": "decorator" | ||
}, | ||
"name": "decorator" | ||
} | ||
} | ||
], | ||
"id": { | ||
"type": "Identifier", | ||
"start": 33, | ||
"end": 36, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 33 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 36 | ||
}, | ||
"identifierName": "Foo" | ||
}, | ||
"name": "Foo" | ||
}, | ||
"superClass": null, | ||
"body": { | ||
"type": "ClassBody", | ||
"start": 37, | ||
"end": 39, | ||
"loc": { | ||
"start": { | ||
"line": 1, | ||
"column": 37 | ||
}, | ||
"end": { | ||
"line": 1, | ||
"column": 39 | ||
} | ||
}, | ||
"body": [] | ||
}, | ||
"extra": { | ||
"parenthesized": true, | ||
"parenStart": 15 | ||
} | ||
} | ||
} | ||
], | ||
"directives": [] | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...ors-2/decoratorsBeforeExport-export-default-decorated-expression-without-parens/input.mjs
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 @@ | ||
export default @decorator class Foo {} |
7 changes: 7 additions & 0 deletions
7
...-2/decoratorsBeforeExport-export-default-decorated-expression-without-parens/options.json
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,7 @@ | ||
{ | ||
"sourceType": "module", | ||
"plugins": [ | ||
["decorators", { "decoratorsBeforeExport": true }] | ||
], | ||
"throws": "Unexpected token (1:15)" | ||
} |
2 changes: 2 additions & 0 deletions
2
...n/test/fixtures/experimental/decorators-2/decoratorsBeforeExport-export-default/input.mjs
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 @@ | ||
@decorator | ||
export default class Foo {} |
6 changes: 6 additions & 0 deletions
6
...est/fixtures/experimental/decorators-2/decoratorsBeforeExport-export-default/options.json
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 @@ | ||
{ | ||
"sourceType": "module", | ||
"plugins": [ | ||
["decorators", { "decoratorsBeforeExport": true }] | ||
] | ||
} |
Oops, something went wrong.