Code Monkey home page Code Monkey logo

Comments (8)

gksander avatar gksander commented on May 22, 2024 2

Okay, this fix has been released as 2.1.3! Thanks, all, for reporting, putting a solution together, and nudging this across the finish line!

from babel-plugin-transform-define.

Titozzz avatar Titozzz commented on May 22, 2024 1

Thanks for opening that issue @tomekzaw .

I can see different cases:

const obj = {
  __DEV__
};
const obj = {
  __DEV__: __DEV__
};
const obj = {
  "__DEV__": __DEV__
};
const obj = {
  ["__DEV__"]: __DEV__
};

Should output:

var obj = {
  "__DEV__": true
};

Meanwhile

const obj = {
  [__DEV__]: __DEV__
};

Should be the only one that also affect the key

from babel-plugin-transform-define.

carloskelly13 avatar carloskelly13 commented on May 22, 2024 1

Agreed, in my view [__DEV__]: __DEV__ should see the key being replaced as the [] indicate to me, it is calculated where the others are just strings or non replaceable keys.

from babel-plugin-transform-define.

gksander avatar gksander commented on May 22, 2024 1

Hi @Titozzz - thanks for resurfacing this. I'm a bit swamped this week, but will try to check this out first thing next week!

from babel-plugin-transform-define.

ryan-roemer avatar ryan-roemer commented on May 22, 2024

This behavior description is accurate.

So, we tackled things with bindings in #81

I'm not totally sure if we should skip object keys or if there are legitimate use cases to replace those.... Thoughts @carloskelly13 @gksander ?

As an aside, if you switch to string keys, you can get an equivalent, non-error output:

const obj = {
  "__DEV__": __DEV__
};

outputs to:

var obj = {
  "__DEV__": true
};

from babel-plugin-transform-define.

Titozzz avatar Titozzz commented on May 22, 2024

Hello there, gentle nudge to the issue, since I feel we all agree on the problem, what are the steps moving forward, should we expect you guys to fix it at some time or will you want a pull request?
No idea what this issue would take to be fixed, but happy to give a hand!

cc @ryan-roemer @carloskelly13

from babel-plugin-transform-define.

Titozzz avatar Titozzz commented on May 22, 2024

Went ahead and created the PR

from babel-plugin-transform-define.

Titozzz avatar Titozzz commented on May 22, 2024

gentle nudge @ryan-roemer @carloskelly13 @gksander

from babel-plugin-transform-define.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.