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

transform-runtime plugin option ignored for "polyfill":false #5382

Closed
sudo-suhas opened this issue Feb 26, 2017 · 5 comments
Closed

transform-runtime plugin option ignored for "polyfill":false #5382

sudo-suhas opened this issue Feb 26, 2017 · 5 comments
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@sudo-suhas
Copy link

transform-runtime plugin usage option for disabling polyfills is ignored when used to transpile code with async functions.

Input Code

I am able to reproduce the bug using the vue webpack template starter pack.

To create a fresh project:

$ npm install -g vue-cli
$ vue init webpack vue-test

  This will install Vue 2.x version of the template.

  For Vue 1.x use: vue init webpack#1.0 vue-test

? Project name vue-test
? Project description Playground for Vue!
? Author Suhas Karanth <sudo.suhas@gmail.com>
? Vue build runtime
? Install vue-router? Yes
? Use ESLint to lint your code? No
? Setup unit tests with Karma + Mocha? No
? Setup e2e tests with Nightwatch? No

   vue-cli · Generated "vue-test".

   To get started:
   
     cd vue-test
     npm install
     npm run dev
   
   Documentation can be found at https://vuejs-templates.github.io/webpack

$ cd vue-test/
$ npm install

Modify .babelrc to have ["transform-runtime", { "polyfill": false }].

Add the following to src/main.js:

async function test() {
    await Promise.resolve(true);
}

Babel Configuration (.babelrc, cli command)

// .babelrc
{
  "presets": [
    ["env", { "modules": false }],
    "stage-2"
  ],
  "plugins": [["transform-runtime", { "polyfill": false }]],
  "comments": false,
  "env": {
    "test": {
      "plugins": [ "istanbul" ]
    }
  }
}

// cli command
npm run build --report

Expected Behavior

Since polyfill option is disabled, core-js modules should not be exported.

Current Behavior

The polyfills are added despite the .babelrc config
image

Context

I am tying to export my choice of polyfill of promise library but the build ends up exporting both the polyfill library as well as the core-js promise version.

Your Environment

software version
Babel 6.22.1
node 6.9.4
npm 3.10.10
Operating System ubuntu 16.04
@babel-bot
Copy link
Collaborator

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

@hzoo
Copy link
Member

hzoo commented Mar 20, 2017

this is because the helpers pull in core-js as well. should be fixed in #5442 with the useBuiltIns option in 7.0 so that the helpers don't also import core-js, #5481 (docs prs)

@hzoo hzoo closed this as completed Mar 20, 2017
@sudo-suhas
Copy link
Author

Great 😄 If you don't mind, could you also tell me by when 7.0 might be released?

@hzoo
Copy link
Member

hzoo commented Mar 20, 2017

No schedule, we will be releasing alpha/rc versions over time though, probably another one with that PR this week.

@sudo-suhas
Copy link
Author

@hzoo I think we need to reopen this issue. I tried the steps with the latest beta for babel packages but the issue still persists.

.babelrc

{
  "presets": [
    ["@babel/preset-env", {
      "modules": false,
      "useBuiltIns": false, // I also tried it with `"usage"`
      "debug": true
    }],
    "@babel/preset-stage-2"
  ],
  "plugins": [["@babel/plugin-transform-runtime", { "polyfill": false }]],
  "env": {
    "test": {
      "presets": ["@babel/preset-env", "@babel/preset-stage-2"],
      "plugins": ["@babel/plugin-transform-modules-commonjs", "dynamic-import-node"]
    }
  }
}

package.json snippet

{
  // ...
  "devDependencies": {
    "@babel/core": "^7.0.0-beta.32",
    "@babel/plugin-transform-modules-commonjs": "^v7.0.0-beta.32",
    "@babel/plugin-transform-runtime": "^7.0.0-beta.32",
    "@babel/preset-env": "^v7.0.0-beta.32",
    "@babel/preset-stage-2": "^7.0.0-beta.32",
    "@babel/register": "^7.0.0-beta.32",
    "@babel/runtime": "^7.0.0-beta.32",
    "babel-loader": "^8.0.0-beta.0",
    "babel-plugin-dynamic-import-node": "^1.2.0",
    // ...
  }
}

Build output:

λ npm run build --report

> vue-webpack-dev@1.0.0 build E:\Projects\experiments\vue-webpack-dev
> node build/build.js

/ building for production...@babel/preset-env: `DEBUG` option

Using targets:
{
  "android": "4.4.3",
  "chrome": "60",
  "edge": "15",
  "firefox": "56",
  "ie": "10",
  "ios": "10.3",
  "safari": "10.1"
}

Using modules transform: false

Using plugins:
  check-constants { "android":"4.4.3", "ie":"10" }
  transform-arrow-functions { "android":"4.4.3", "ie":"10" }
  transform-block-scoped-functions { "android":"4.4.3", "ie":"10" }
  transform-block-scoping { "android":"4.4.3", "ie":"10" }
  transform-classes { "android":"4.4.3", "ie":"10" }
  transform-computed-properties { "android":"4.4.3", "ie":"10" }
  transform-destructuring { "android":"4.4.3", "edge":"15", "ie":"10" }
  transform-duplicate-keys { "android":"4.4.3", "ie":"10" }
  transform-for-of { "android":"4.4.3", "ie":"10" }
  transform-function-name { "android":"4.4.3", "edge":"15", "ie":"10" }
  transform-literals { "android":"4.4.3", "ie":"10" }
  transform-object-super { "android":"4.4.3", "ie":"10" }
  transform-parameters { "android":"4.4.3", "ie":"10" }
  transform-shorthand-properties { "android":"4.4.3", "ie":"10" }
  transform-spread { "android":"4.4.3", "ie":"10" }
  transform-sticky-regex { "android":"4.4.3", "ie":"10" }
  transform-template-literals { "android":"4.4.3", "ie":"10" }
  transform-typeof-symbol { "android":"4.4.3", "ie":"10" }
  transform-unicode-regex { "android":"4.4.3", "ie":"10" }
  transform-new-target { "android":"4.4.3", "ie":"10" }
  transform-regenerator { "android":"4.4.3", "ie":"10" }
  transform-exponentiation-operator { "android":"4.4.3", "ie":"10" }
  transform-async-to-generator { "android":"4.4.3", "ie":"10" }

Using polyfills: No polyfills were added, since the `useBuiltIns` option was not set.
Hash: 42945cf67871b2638c12
Version: webpack 3.8.1
Time: 8183ms
                                                  Asset       Size  Chunks             Chunk Names
               static/js/vendor.f2c85cd40521aad61df7.js     119 kB       0  [emitted]  vendor
                  static/js/app.75db56a85be54c0ad27c.js    11.8 kB       1  [emitted]  app
             static/js/manifest.e332e65c5c9f65ce1973.js    1.51 kB       2  [emitted]  manifest
    static/css/app.d90fac408992be41cff8ba63f004fedd.css  432 bytes       1  [emitted]  app
static/css/app.d90fac408992be41cff8ba63f004fedd.css.map  828 bytes          [emitted]
           static/js/vendor.f2c85cd40521aad61df7.js.map     971 kB       0  [emitted]  vendor
              static/js/app.75db56a85be54c0ad27c.js.map    39.3 kB       1  [emitted]  app
         static/js/manifest.e332e65c5c9f65ce1973.js.map    14.4 kB       2  [emitted]  manifest
                                             index.html  517 bytes          [emitted]

  Build complete.

  Tip: built files are meant to be served over an HTTP server.
  Opening index.html over file:// won't work.

Webpack Bundle Analyzer is started at http://127.0.0.1:8888
Use Ctrl+C to close it

@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label May 4, 2018
@lock lock bot locked as resolved and limited conversation to collaborators May 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

No branches or pull requests

3 participants