Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

strictMode disabled causes SyntaxError with exportDefaultFrom #9858

sebdeckers opened this Issue Apr 14, 2019 · 4 comments


None yet
3 participants
Copy link

commented Apr 14, 2019

Bug Report

Current Behavior
Fails with strictMode: false, passes with strictMode: true.

Input Code

const parser = require('@babel/parser')
const source = `
  export { f }
  function f () {}
const options = {
  sourceType: 'module',
  plugins: ['exportDefaultFrom']

parser.parse(source, { ...options, strictMode: true })
// OK

parser.parse(source, { ...options, strictMode: false })
// SyntaxError: Export 'f' is not defined (2:11)

Expected behavior/code
Disabling strict mode should not cause a syntax error for code that parses with strict mode enabled.

Babel Configuration (.babelrc, package.json, cli command)

N/A, see example code above


  • Babel version(s): v7.4.3
  • Node/npm version: Node 11.13.0/npm 6.7.0
  • OS: macOS 10.13.6 (High Sierra)
  • Monorepo: no
  • How you are using Babel: parser

Possible Solution


Additional context/Screenshots

Originally came across this problem while parsing Moment.js source code.



This comment has been minimized.

Copy link

commented Apr 14, 2019

Hey @sebdeckers! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
that typically always has someone willing to help. You can sign-up here
for an invite.


This comment has been minimized.

Copy link

commented Apr 14, 2019

Are you sure @babel/parser is 7.4.3? It should have been fixed by #9725


This comment has been minimized.

Copy link
Contributor Author

commented Apr 15, 2019

@nicolo-ribaudo I can confirm that it is 7.4.3 and that patch is included.


  "name": "test-babel-parser",
  "version": "1.0.0",
  "lockfileVersion": 1,
  "requires": true,
  "dependencies": {
    "@babel/parser": {
      "version": "7.4.3",
      "resolved": "",
      "integrity": "sha512-gxpEUhTS1sGA63EGQGuA+WESPR/6tz6ng7tSHFCmaTJK/cGK8y37cBTspX+U2xCAue2IQVvF6Z0oigmjwD8YGQ=="


  checkLocalExport(id) {
    if (this.scopeStack[0].lexical.indexOf( === -1 && this.scopeStack[0].var.indexOf( === -1 && this.scopeStack[0].functions.indexOf( === -1) {
      this.undefinedExports.set(, id.start);

This comment has been minimized.

Copy link
Contributor Author

commented Apr 15, 2019

@nicolo-ribaudo nicolo-ribaudo referenced a pull request that will close this issue Apr 16, 2019


Always register global bindings as exportable #9865

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.