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

Incorrect global scope #12406

Closed
1 task
mo36924 opened this issue Nov 27, 2020 · 4 comments · Fixed by #12429
Closed
1 task

Incorrect global scope #12406

mo36924 opened this issue Nov 27, 2020 · 4 comments · Fixed by #12429
Labels
i: bug i: needs triage outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@mo36924
Copy link

mo36924 commented Nov 27, 2020

Bug Report

  • I would like to work on a fix!

Current behavior

node index.js
hasGlobal: fetch

Input Code

index.js

const { transformSync } = require("@babel/core");

transformSync(`export { fetch } from "node-fetch"`, {
  babelrc: false,
  configFile: false,
  plugins: [
    () => ({
      visitor: {
        Program(path) {
          if (path.scope.hasGlobal("fetch")) {
            console.log("hasGlobal: fetch");
          }
        },
      },
    }),
  ],
});

Expected behavior

node index.js

Environment

System:
  OS: macOS 10.15.7
Binaries:
  Node: 14.13.1 - ~/.nvm/versions/node/v14.13.1/bin/node
  Yarn: 1.22.4 - /usr/local/bin/yarn
  npm: 6.14.8 - ~/.nvm/versions/node/v14.13.1/bin/npm
npmPackages:
  @babel/core: ^7.12.9 => 7.12.9 
@babel-bot
Copy link
Collaborator

Hey @mo36924! 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

This should be fixed by #12395, but we can add a test for the scope.

@mischnic
Copy link
Contributor

Was that the underlying problem for #9266 as well?

@nicolo-ribaudo
Copy link
Member

Uh probably yes.

@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 Mar 8, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 8, 2021
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

Successfully merging a pull request may close this issue.

4 participants