intentionally not using .babelrc
npm i
npm start
| import * as Lib from 'lib'; | |
| console.log('APP'); | |
| console.log(Lib); | |
| console.log(Lib.capitalize('hello world')); |
| <!doctype html> | |
| <title>test split lib and app</title> | |
| <meta charset="utf-8"> | |
| <main></main> | |
| <script src="build/lib.js"></script> | |
| <script src="build/app.js"></script> |
| // used as entry point to build the common lib | |
| console.log('LIB ENTRY POINT'); | |
| import capitalize from 'string-capitalize'; | |
| export default { capitalize }; |
| { | |
| "name": "test-split-app-lib", | |
| "version": "0.1.0", | |
| "description": "", | |
| "scripts": { | |
| "start": "npm run build-app & npm run build-lib", | |
| "build-app": "babel-node --presets es2015 rollup.app.js", | |
| "build-lib": "babel-node --presets es2015 rollup.lib.js" | |
| }, | |
| "author": "Enrique Erne", | |
| "license": "MIT", | |
| "dependencies": { | |
| "string-capitalize": "^1.0.1" | |
| }, | |
| "devDependencies": { | |
| "babel-cli": "^6.3.17", | |
| "babel-eslint": "^4.1.6", | |
| "babel-preset-es2015-rollup": "^1.1.1", | |
| "rollup": "^0.24.1", | |
| "rollup-plugin-babel": "^2.3.9", | |
| "rollup-plugin-commonjs": "^2.1.0", | |
| "rollup-plugin-npm": "^1.2.0" | |
| } | |
| } |
| import { rollup } from 'rollup'; | |
| import npm from 'rollup-plugin-npm'; | |
| import commonjs from 'rollup-plugin-commonjs'; | |
| import babel from 'rollup-plugin-babel'; | |
| rollup({ | |
| 'entry': 'app.js', | |
| 'external': ['lib'], | |
| 'plugins': [ | |
| npm({ 'jsnext': true, 'main': true/*, skip: ['lib']*/}), | |
| commonjs(), | |
| babel({ 'babelrc': false, 'presets': ['es2015-rollup'] }) | |
| ] | |
| }) | |
| .then( bundle => bundle.write({ | |
| 'banner': '/* APP */', | |
| 'dest': 'build/app.js', | |
| 'format': 'iife', | |
| 'globals': { | |
| 'lib': 'Lib' | |
| }, | |
| 'sourceMap': true | |
| }) ) | |
| .catch( error => console.log(error) ); |
| import { rollup } from 'rollup'; | |
| import npm from 'rollup-plugin-npm'; | |
| import commonjs from 'rollup-plugin-commonjs'; | |
| import babel from 'rollup-plugin-babel'; | |
| // import uglify from 'rollup-plugin-uglify'; | |
| rollup({ | |
| 'entry': 'lib.js', | |
| 'plugins': [ | |
| babel({ 'babelrc': false, 'presets': ['es2015-rollup'] }), | |
| npm({ 'jsnext': true, 'main': true}), | |
| commonjs() | |
| // uglify() | |
| ] | |
| }) | |
| .then( bundle => bundle.write({ | |
| 'dest': 'build/lib.js', | |
| // 'exports': 'named', | |
| 'format': 'iife', | |
| 'moduleName': 'Lib', | |
| 'banner': '/* Lib */', | |
| 'sourceMap': true | |
| }) ) | |
| .catch( error => console.log(error) ); |
Is it necessary to run
rollup.app.jsandrollup.lib.jsinsidebabel-node?