Skip to content

Instantly share code, notes, and snippets.

@cjies
Created Mar 26, 2017
Embed
What would you like to do?
es module bundling with babel
{
"presets": [
["env", { "modules": false }]
],
"env": {
"es": {},
"lib": {
"plugins": [
"transform-es2015-modules-commonjs"
]
}
}
}
{
"name": "es-module-bundling-demo",
"version": "1.0.0",
"description": " es module bundling with babel",
"main": "lib/index.js",
"module": "es/index.js",
"jsnext:main": "es/index.js",
"scripts": {
"build": "npm run build:lib && npm run build:es",
"build:lib": "BABEL_ENV=lib babel ./src --out-dir ./lib",
"build:es": "BABEL_ENV=es babel ./src --out-dir ./es"
},
"dependencies": {},
"devDependencies": {
"babel-cli": "^6.24.0",
"babel-core": "^6.24.0",
"babel-preset-env": "^1.2.2"
}
}
// Located in src directory
function helloWorld() {
console.log('Hello World!');
}
export default helloWorld();
// Located in src directory
export helloWorld from './hello_world';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment