Skip to content

Commit

Permalink
docs(@babel/parser): Document allowUndeclaredExports option. (#2047)
Browse files Browse the repository at this point in the history
* docs(@babel/parser): Document allowUndeclaredExports option.

Documents the changes from babel/babel#9864
implemented by @nicolo-ribaudo.

* Clarify when allowUndeclaredExports is intended to be used.
  • Loading branch information
benjamn authored and nicolo-ribaudo committed Jul 4, 2019
1 parent 7a7f46e commit f2eb092
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/parser.md
Expand Up @@ -46,6 +46,14 @@ mind. When in doubt, use `.parse()`.
outside of class and object methods. Set this to `true` to accept such
code.

- **allowUndeclaredExports**: By default, exporting an identifier that was
not declared in the current module scope will raise an error. While this
behavior is required by the ECMAScript modules specification, Babel's
parser cannot anticipate transforms later in the plugin pipeline that
might insert the appropriate declarations, so it is sometimes important
to set this option to `true` to prevent the parser from prematurely
complaining about undeclared exports that will be added later.

- **sourceType**: Indicate the mode the code should be parsed in. Can be
one of `"script"`, `"module"`, or `"unambiguous"`. Defaults to `"script"`. `"unambiguous"` will make @babel/parser attempt to _guess_, based on the presence of ES6 `import` or `export` statements. Files with ES6 `import`s and `export`s are considered `"module"` and are otherwise `"script"`.

Expand Down

0 comments on commit f2eb092

Please sign in to comment.