Skip to content

Instantly share code, notes, and snippets.

@cjies
Created March 26, 2017 08:26
Show Gist options
  • Save cjies/31b602b53adf22320936663756abd61f to your computer and use it in GitHub Desktop.
Save cjies/31b602b53adf22320936663756abd61f to your computer and use it in GitHub Desktop.
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