Skip to content

[7.0] Remove babel-runtime from babel-x packages (check if we can) #5118

Closed

Description

@hzoo

What

Almost every babel-x package right now has a dependency on babel-runtime.

Example with babel-plugin-check-es2015-constants:

Being able to remove this from all packages would help save time to install (especially npm 2/yarn).

react/create-react-app#1397
Yarn has known issues deduplicating dependencies, sometimes failing to hoist dependencies shared between a ton of packages (such as babel-runtime) and producing installs 5 times bigger than npm: yarnpkg/yarn#2306.

The reason for doing this in the first place has to do with wanting to use built-ins like Symbol/Promise, etc which are not native to node 0.10/0.12. Now that we are on >= Node 4 we should be able to use the native ones.

We don't want to use a polyfill, so we choose to use babel-runtime + babel-plugin-transform-runtime. For more context: http://babeljs.io/docs/plugins/transform-runtime/#why

I think if we don't do this there will be a babel-runtime 7.0 and that won't dedupe correctly etc or we rename to babel-runtime-internal


How to:

Wins

  • less dependencies, use native, might be faster to run/install

cc @sindresorhus, @insin since I think I recall both of you wanting a solution this even from #3438.

Activity

  1. added this to the Babel 7 milestone on Jan 14, 2017
  2. hzoo commented on Jan 14, 2017

    @hzoo
    MemberAuthor

    And I think @kaicataldo said he might be interested

  3. changed the title [-][7.0] Possibly remove `babel-runtime` from babel-x packages[/-] [+][7.0] Remove `babel-runtime` from babel-x packages (check if we can)[/+] on Jan 14, 2017
  4. sindresorhus commented on Jan 16, 2017

    @sindresorhus
    Member

    Yes please. Babel is always the biggest dependency in my projects because deduping never works and I end up with a gadzillion copies of babel-runtime.

  5. hzoo commented on Jan 16, 2017

    @hzoo
    MemberAuthor

    Yep I realized this could probably work since we probably only use node 4 supported ones anyway. Might be hairy but just need to figure it out.

  6. loganfsmyth commented on Jan 16, 2017

    @loganfsmyth
    Member

    We should make extra sure our tests are running on native Node 4 with no polyfills loaded, otherwise we could run into issues.

  7. hzoo commented on Jan 16, 2017

    @hzoo
    MemberAuthor

    This part has to do with babel-helper-transform-fixture-test-runner/src/index.js:

    function runExec(opts, execCode, execDirname) {
      const sandbox = {
        ...helpers,
        babelHelpers,
        assert: chai.assert,
        transform: babel.transform,
        opts,
        exports: {},
        require(id) {
          return require(id[0] === "." ? path.resolve(execDirname, id) : id);
        }
      };
    
      const fn = new Function(...Object.keys(sandbox), execCode);
      return fn.apply(null, Object.values(sandbox));
    }

    we run tests with new Function and also use require('babel-polyfill') so one solution is to use vm.runInNewContext instead

  8. chicoxyzzy commented on Jan 16, 2017

    @chicoxyzzy
    Member

    Does someone works on this already?

    I think we should mention #5135 in the checklist

  9. hzoo commented on Jan 16, 2017

    @hzoo
    MemberAuthor

    ^ Can be in 6.x since its internal so not necessary, not sure if anyone working on it, I just asked @kaicataldo if he wanted to look into

    I did find we need to remove the asf extends Map { in store.js

  10. chicoxyzzy commented on Jan 16, 2017

    @chicoxyzzy
    Member

    @hzoo there are some other modules in babel-core where we extend Store from store.js. I'll try to realise how to refactor all these.

  11. hzoo commented on Jan 16, 2017

    @hzoo
    MemberAuthor

    Yeah was just talking to Logan about that yesterday haha it's everywhere

  12. kaicataldo commented on Jan 16, 2017

    @kaicataldo
    Member

    I'm planning to start looking at this today

  13. chicoxyzzy commented on Jan 16, 2017

    @chicoxyzzy
    Member

    @kaicataldo FYI classes that extend native Map in babel-core package are blocker for this :(

    https://babeljs.io/docs/usage/caveats/#classes

  14. hzoo commented on Jan 16, 2017

    @hzoo
    MemberAuthor

    Yeah we need to make a wrapper instead of extending

  15. mswiecicki commented on Jan 19, 2017

    @mswiecicki
    Contributor

    So what's the status here ? I'd be willing to help with that.

  16. hzoo commented on Jan 20, 2017

    @hzoo
    MemberAuthor

    If you'd like to start looking into this, can go ahead. Might need to do it myself if its too involved but we'll see how it goes for you?

    Immediately you should see an error

    I did find we need to remove the asf extends Map { in store.js.

    Basically for that we need to not extend a native built-in? Or I guess we could just not compile classes for that specific fix.

  17. mswiecicki commented on Jan 20, 2017

    @mswiecicki
    Contributor

    Ok, so i'll look into that and do my best, but i'll proceed with caution and probably consult a lot.

  18. kaicataldo commented on Jan 21, 2017

    @kaicataldo
    Member

    @4rlekin Please feel free to take this on if you're willing. I have some personal things that I have to attend to at the moment and won't be able to get to this until next week at the earliest.

  19. hzoo commented on Jan 28, 2017

    @hzoo
    MemberAuthor

    Oops done in #5218!

  20. added
    outdated
    on May 5, 2018
  21. locked as resolved and limited conversation to collaborators on May 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Has PRhelp wantedoutdated

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions