question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug]: plugin-transform-modules-systemjs transformation is unsafe

See original GitHub issue

💻

  • Would you like to work on a fix?

How are you using Babel?

Programmatic API (babel.transform, babel.parse)

Input code

REPL.

import { x } from './x.js';

if (true) {
	const x = 1;
	console.log(x);
}

new (class extends x {})();

Configuration file name

No response

Configuration

Using @babel/plugin-transform-modules-systemjs, nothing else

Current and expected behavior

I would expect the x = 1 to declare a local constant, as it does in the original code. Instead, it assigns to a new module-level variable (which in this case has the same name as an import, causing an error).

Environment

  System:
    OS: macOS 10.15.7
  Binaries:
    Node: 16.5.0 - ~/.nvm/versions/node/v16.5.0/bin/node
    Yarn: 1.22.5 - /usr/local/bin/yarn
    npm: 7.19.1 - ~/.nvm/versions/node/v16.5.0/bin/npm
  npmPackages:
    @babel/core: ^7.15.8 => 7.15.8 
    @babel/plugin-proposal-dynamic-import: ^7.14.5 => 7.14.5 
    @babel/plugin-transform-modules-systemjs: ^7.15.4 => 7.15.4 

Possible solution

No response

Additional context

cc @guybedford 😃

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
The-x-Theoristcommented, Dec 15, 2021

I’d like to work on this issue?

0reactions
The-x-Theoristcommented, Dec 21, 2021

Can you keep the name for var declarations, and only rename const/let ?

Yeah, I can do that.

Read more comments on GitHub >

github_iconTop Results From Across the Web

A Bug Undergoes One of Nature's More Startling ... - YouTube
The salmon fly nymph is in a race against time: in order to breathe, it will need to break out of its hardened...
Read more >
Transformation for "A Dangerous Harvest" while on Taxi bugs ...
The Ardenweald WQ “A Dangerous Harvest” transforms you into a moth with a vehicle bar. While taking a taxi from Glitterfall Basin to...
Read more >
Wrong rendering of transformed fonts on Windows with Java 6
JDK-6591278 : Wrong rendering of transformed fonts on Windows with Java 6. Type: Bug; Component: client-libs; Sub-Component: 2d; Affected Version: 6.
Read more >
Learning Graph Transformations to Detect and Fix Bugs in ...
We present a learning-based approach to detect and fix a broad range of bugs in. Javascript programs. We frame the problem in terms...
Read more >
The next step towards a bug bounty program for the ... - 18F
The TTS Bug Bounty will be a security initiative to pay people for identifying bugs and security holes in software operated by the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found