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

Unnecessary require with transform runtime? #8675

Open
ibreathebsb opened this Issue Sep 11, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@ibreathebsb

ibreathebsb commented Sep 11, 2018

Problem

My target environment is chrome 67, but still corejs/promise is required.

Config

package.json

{
  "name": "play-with-babel",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "devDependencies": {
    "@babel/cli": "^7.0.0",
    "@babel/core": "^7.0.0",
    "@babel/plugin-transform-runtime": "^7.0.0",
    "@babel/preset-env": "^7.0.0"
  },
  "dependencies": {
    "@babel/runtime": "^7.0.0",
    "@babel/runtime-corejs2": "^7.0.0"
  }
}

babel.config.js

"use strict";

module.exports = function (api) {
  const env = api.env()
  const envOpts = {
    loose: true,
    modules: false,
    useBuiltIns: 'usage',
    targets: {
      chrome: "67"
    },
    debug: true
  }
  const config = {
    sourceType: "script",
    comments: false,
    presets: [
      ["@babel/preset-env", envOpts]
    ],
    plugins: [
      ["@babel/plugin-transform-runtime", {
        corejs: 2 //  <= avoid polluting global environment
      }]
    ]
  };
  return config;
};

Input

const p = Promise.resolve(1)

Output

// as you can see,  **const** is not transformed which is correct

// but promise should not be imported right?

var _Promise = require("@babel/runtime-corejs2/core-js/promise"); 

const p = _Promise.resolve(1);
@babel-bot

This comment has been minimized.

Show comment
Hide comment
@babel-bot

babel-bot Sep 11, 2018

Collaborator

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

Collaborator

babel-bot commented Sep 11, 2018

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

@ibreathebsb ibreathebsb changed the title from unnecessary require with transform runtime? to Unnecessary `require` with transform runtime? Sep 11, 2018

@ibreathebsb ibreathebsb changed the title from Unnecessary `require` with transform runtime? to Unnecessary require with transform runtime? Sep 11, 2018

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