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

After upgrading babel core, preset-env, babel-loader, preset-react, preset-typescript export from not working #11308

Closed
1 task done
brneto opened this issue Mar 21, 2020 · 5 comments
Labels
i: bug i: needs triage outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@brneto
Copy link

brneto commented Mar 21, 2020

Bug Report

After updating the following dependencies ESLint started to complains about all imports from export-from files:

  • @babel/core: 7.9.0

  • @babel/preset-env: 7.9.1

  • @babel/preset-react: 7.9.0

  • @babel/preset-typescript: 7.9.0

  • I would like to work on a fix!

Current Behavior
When I run ESLint src, it throws a "not found in" error the message.

Input Code

// actions/index.js
export * as effects from './effects';
export * as commands from './commands';
export * as events from './events';
export * as documents from './documents';

// sagas/todo-workers.js
import { commands, events, documents } from '../actions';
//  3:10  error  commands not found in '../actions'             import/named
//   3:20  error  events not found in '../actions'               import/named
//   3:28  error  documents not found in '../actions'            import/named

Expected behavior/code
I expect ESLint recognize those import without any complaints.

Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)

  • Filename: babel.config.js
{
  "plugins": [
    ["@babel/plugin-proposal-decorators", { "legacy": true }],
    ["@babel/plugin-proposal-class-properties", { "loose": true }],
    ["@babel/plugin-proposal-private-methods", { "loose": true }],
    "@babel/plugin-proposal-export-namespace-from",
    "@babel/plugin-proposal-export-default-from",
    "@babel/plugin-proposal-function-bind",
    "@babel/plugin-proposal-throw-expressions"
  ],
  "presets": [
    ["@babel/preset-env", {
      "targets": { "node": "current" },
      "useBuiltIns": "usage",
      "corejs": 3,
      "bugfixes": true
    }],
    "@babel/preset-react",
    "@babel/preset-typescript",
    "@emotion/babel-preset-css-prop"
  ]
}

Environment

System:
    OS: Linux 4.15 elementary OS 5.1.2 Hera
    CPU: (3) x64 Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
    Memory: 15.14 GB / 21.43 GB
    Container: Yes
    Shell: 4.4.20 - /bin/bash
  Binaries:
    Node: 12.16.1 - /usr/bin/node
    Yarn: 1.22.4 - /usr/bin/yarn
    npm: 6.13.4 - /usr/bin/npm
    Watchman: 4.9.0 - /home/linuxbrew/.linuxbrew/bin/watchman
  Managers:
    Apt: 1.6.12 - /usr/bin/apt
    Gradle: 4.4.1 - /usr/bin/gradle
    Maven: 3.6.0 - /usr/bin/mvn
    pip2: 9.0.1 - /usr/bin/pip2
    pip3: 19.0.3 - /home/linuxbrew/.linuxbrew/bin/pip3
  Utilities:
    Make: 4.1 - /usr/bin/make
    GCC: 7.5.0 - /usr/bin/gcc
    Git: 2.17.1 - /usr/bin/git
    FFmpeg: 3.4.6 - /usr/bin/ffmpeg
  Virtualization:
    Docker: 19.03.6 - /usr/bin/docker
  IDEs:
    Nano: 2.9.3 - /bin/nano
    VSCode: 1.43.1 - /usr/bin/code
    Vim: 8.0 - /usr/bin/vim
  Languages:
    Bash: 4.4.20 - /bin/bash
    Go: 1.12.4 - /home/linuxbrew/.linuxbrew/bin/go
    Java: 1.8.0_211 - /usr/bin/javac
    Perl: 5.28.1 - /home/linuxbrew/.linuxbrew/bin/perl
    Python: 2.7.17 - /usr/bin/python
    Python3: 3.7.3 - /home/linuxbrew/.linuxbrew/bin/python3
  Databases:
    SQLite: 3.28.0 - /home/linuxbrew/.linuxbrew/bin/sqlite3
  Browsers:
    Chrome: 80.0.3987.149
    Firefox: 74.0

Possible Solution
No idea.

Additional context/Screenshots
image

@babel-bot
Copy link
Collaborator

Hey @brneto! 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 community that typically always has someone willing to help. You can sign-up here for an invite."

@nicolo-ribaudo
Copy link
Member

nicolo-ribaudo commented Mar 21, 2020

What is your ESLint config? Nvm, I can check it in the repo

@nicolo-ribaudo
Copy link
Member

nicolo-ribaudo commented Mar 21, 2020

I'm sorry but this is "working as intended".

When using ESLint (without Babel), the ESLint parser produces an AST which matches the ESTree specification.

When using Babel's parser (without ESLint), there is an option ("estree") to make Babel's output match the ESTree specification. However, Babel implements new features years before that they are specified in ESTree: for every AST node that isn't specified, we keep our own format. However, when a new AST node is specified, we must align it. Not doing so (and thus keep using our own AST format) would be the opposite of what @babel/parser users are asking with the "estree" option.

When using babel-eslint, it enables the "estree" option of Babel's parser. This is needed necessary all the ESLint plugins expect an AST conformant to the ESTree specification because it's what ESLint uses. If we used our own AST format, all the ESLint plugins wouldn't work with babel-eslint.

Since export * as foo from "module" recently became part of the ECMAScript standard (it will be included in ES2020), the ESTree specification defined its AST format (estree/estree#205).
For this reason, @babel/parser with the "estree" plugin (and thus babel-estree) aligned to the new format: it's what the "estree" option is explicitly asking for. ESLint will soon support export * as foo by default (eslint/eslint#12629), and it will use the same AST format defined in the ESTree specification.

However, eslint-plugin-import relies on the Babel-specific format, so it doesn't recognize the export * as foo declarations. Note that not only it doesn't work with babel-eslint, but it will not work with ESLint alone as soon as eslint/eslint#12629 is fixed.

For this reason, I suggest asking in the eslint-plugin-import repository to align to the recently specified format, which is something that all the ESLint plugins should do ASAP to ensure their compatibility with "pure" ESLint.


As a workaround, add this to your package.json:

  "resolutions": {
    "@babel/parser": "~7.8.0"
  }

it will force the older parser version, which doesn't respect the ESTree format (because it wasn't defined yet).

@brneto
Copy link
Author

brneto commented Mar 21, 2020

@nicolo-ribaudo, would have something I could do in meantime to stop this issue in my project? Some workaround?

@nicolo-ribaudo
Copy link
Member

Yes! I edited the end of my comment a few minutes ago (maybe you missed it)

@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jun 21, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: bug i: needs triage outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

No branches or pull requests

3 participants