3

I'm building a frontend app boilerplate to set up projects that use ES6 and Fetch with Gulp and Babel + Browserify for modules.

I know how to import both babel-polyfill and core-js (in case I don't want the Generator Runtime) but they are both 80 to 90 kilobytes minified in comparison to something like lodash or jQuery (less than 40 Kb minified).

My question is, how can I use ES6 import syntax (I'm using browserify) to only import the things I want from core-js instead of throwing them all together?

For example, say I import lodash so I have ES5 array features covered but I also want ES6 Promises, Map and Object (which includes assign, freeze, etc) without importing the whole { ES5, Es6, Es7 } set of modules.

For example, how would I only import all modules from the /es6 folder?

import * from 'core-js/es6'?? I have no idea, really; please help!

It'd be lovely to do something like import { Promise, Map, WeakMap } from 'core-js/es6' as well.

Luís Hendrix
  • 156
  • 2
  • 6

1 Answers1

2

Related Answer import modules from files in directory

What it says is

Create a Manifest file named es6-index.js and reference everything inside corejs/es6 there.

export * from 'path-to-corejs/es6/array'; export * from 'path-to-corejs/es6/date';

and then

import {Array, Date} from 'es6-index.js';

Community
  • 1
  • 1
Pankaj Phartiyal
  • 1,691
  • 1
  • 12
  • 23