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

transform-commonjs's 'lazy' option is incorrectly negated for in the case of arrays of strings #9447

Open
kdy1 opened this Issue Feb 3, 2019 · 5 comments

Comments

Projects
None yet
5 participants
@kdy1
Copy link

kdy1 commented Feb 3, 2019

Bug Report

Current Behavior
lazy option acts like a blacklist.

"use strict";
var _white = babelHelpers.interopRequireDefault(require("white"));
function _black() {
const data = babelHelpers.interopRequireDefault(require("black"));
_black = function () {
return data;
};
return data;
}
console.log(_white.default);
console.log(_black().default);

Input Code

import foo1 from "white";
console.log(foo1);
import foo2 from "black";
console.log(foo2);

Expected behavior/code
lazy: ["white"] make "white" lazy-loaded.

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

{
"plugins": [
"external-helpers",
["transform-modules-commonjs", { "lazy": ["white"] }]
]
}

Environment

  • Babel version(s): master
  • Node/npm version: N/A
  • OS: N/A
  • Monorepo: yes
  • How you are using Babel: internal tester

Possible Solution

Additional context/Screenshots

I'm currently porting babel to rust (swc), and I'm confused by test suite.

@babel-bot

This comment has been minimized.

Copy link
Collaborator

babel-bot commented Feb 3, 2019

Hey @kdy1! 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.

@loganfsmyth

This comment has been minimized.

Copy link
Member

loganfsmyth commented Feb 3, 2019

This is 100% just a bug in the implementation. Those tests are wrong.

@loganfsmyth

This comment has been minimized.

Copy link
Member

loganfsmyth commented Feb 3, 2019

Yeah this is a bug at

Looks like I forgot the !== -1 on the test.

@loganfsmyth loganfsmyth changed the title CommonJs.lazy option is misleading transform-commonjs's 'lazy' option is incorrectly negated for in the case of arrays of strings Feb 3, 2019

@nicolo-ribaudo nicolo-ribaudo added Has PR and removed Has PR labels Feb 8, 2019

@Taym95

This comment has been minimized.

Copy link

Taym95 commented Feb 8, 2019

I'm new to the babel world and I would like to take this issue!

@nicolo-ribaudo nicolo-ribaudo added claimed and removed help wanted labels Feb 9, 2019

@nicolo-ribaudo

This comment has been minimized.

Copy link
Member

nicolo-ribaudo commented Feb 9, 2019

If you need help you can contact me or any other team member on Slack :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment