Skip to content

Commit ffe2de6

Browse files
committed
feat(babel): Add option to switch between the two decorator modes.
1 parent 5ae12e8 commit ffe2de6

File tree

4 files changed

+699
-27
lines changed

4 files changed

+699
-27
lines changed

bin/react-docgen.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ argv
4545
'--legacy-decorators',
4646
'Enable parsing of legacy decorators proposal. By default only the new decorators syntax will be parsable.'
4747
)
48+
.option(
49+
'--decorators-before-export',
50+
'Switches the decorators proposal to allow decorators before the export statement. By default this is false.'
51+
)
4852
.option(
4953
'-i, --ignore <path>',
5054
'Folders to ignore. Default: ' + JSON.stringify(defaultIgnore),
@@ -111,6 +115,7 @@ if (argv.resolver) {
111115
function parse(source) {
112116
return parser.parse(source, resolver, null, {
113117
legacyDecorators: argv.legacyDecorators,
118+
decoratorsBeforeExport: argv.decoratorsBeforeExport,
114119
});
115120
}
116121

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"author": "Felix Kling",
3737
"license": "BSD-3-Clause",
3838
"dependencies": {
39-
"@babel/parser": "^7.0.0",
39+
"@babel/parser": "^7.1.3",
4040
"async": "^2.1.4",
4141
"babel-runtime": "^6.9.2",
4242
"commander": "^2.9.0",

src/babelParser.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const babelParserOptions = {
4343

4444
export type Options = {
4545
legacyDecorators?: boolean,
46+
decoratorsBeforeExport?: boolean,
4647
};
4748

4849
function buildOptions(options?: Options = {}) {
@@ -55,7 +56,7 @@ function buildOptions(options?: Options = {}) {
5556
} else {
5657
parserOptions.plugins.push([
5758
'decorators',
58-
{ decoratorsBeforeExport: false },
59+
{ decoratorsBeforeExport: options.decoratorsBeforeExport || false },
5960
]);
6061
}
6162

0 commit comments

Comments
 (0)