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

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

Closed
5 tasks
hzoo opened this issue Jan 14, 2017 · 17 comments
Closed
5 tasks

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

hzoo opened this issue Jan 14, 2017 · 17 comments
Labels
Has PR help wanted outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Milestone

Comments

@hzoo
Copy link
Member

hzoo commented Jan 14, 2017

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).

facebook/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.

@hzoo hzoo added this to the Babel 7 milestone Jan 14, 2017
@hzoo
Copy link
Member Author

hzoo commented Jan 14, 2017

And I think @kaicataldo said he might be interested

@hzoo hzoo 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) Jan 14, 2017
@sindresorhus
Copy link
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.

@hzoo
Copy link
Member Author

hzoo commented Jan 16, 2017

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.

@loganfsmyth
Copy link
Member

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

@hzoo
Copy link
Member Author

hzoo commented Jan 16, 2017

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

@chicoxyzzy
Copy link
Member

Does someone works on this already?

I think we should mention #5135 in the checklist

@hzoo
Copy link
Member Author

hzoo commented Jan 16, 2017

^ 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

@chicoxyzzy
Copy link
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.

@hzoo
Copy link
Member Author

hzoo commented Jan 16, 2017

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

@kaicataldo
Copy link
Member

I'm planning to start looking at this today

@chicoxyzzy
Copy link
Member

chicoxyzzy commented Jan 16, 2017

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

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

@hzoo
Copy link
Member Author

hzoo commented Jan 16, 2017

Yeah we need to make a wrapper instead of extending

@mswiecicki
Copy link
Contributor

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

@hzoo
Copy link
Member Author

hzoo commented Jan 20, 2017

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.

@mswiecicki
Copy link
Contributor

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

@hzoo hzoo mentioned this issue Jan 21, 2017
4 tasks
@kaicataldo
Copy link
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.

@hzoo
Copy link
Member Author

hzoo commented Jan 28, 2017

Oops done in #5218!

@hzoo hzoo closed this as completed Jan 28, 2017
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label May 5, 2018
@lock lock bot locked as resolved and limited conversation to collaborators May 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Has PR help wanted 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

7 participants