From d55c0381b21f2b10b7d1600c5673d59bc3e62489 Mon Sep 17 00:00:00 2001 From: Fabio Crisci Date: Fri, 30 Jun 2017 18:07:10 +0900 Subject: [PATCH] compile with rollup --- .babelrc | 12 +++++++++++- .gitignore | 1 + .npmignore | 1 + package.json | 14 ++++++++++++-- rollup.config.js | 15 +++++++++++++++ 5 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 .npmignore create mode 100644 rollup.config.js diff --git a/.babelrc b/.babelrc index 4ffef06..f4a33ae 100644 --- a/.babelrc +++ b/.babelrc @@ -1,3 +1,13 @@ { - "presets": ["env", "react"] + "presets": [ + ["env", { + "modules": false + }], + "react" + ], + "env": { + "test": { + "presets": ["env", "react"] + } + } } diff --git a/.gitignore b/.gitignore index ba2a97b..9c62828 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules coverage +dist diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..c912533 --- /dev/null +++ b/.npmignore @@ -0,0 +1 @@ +__tests__ diff --git a/package.json b/package.json index 284e57a..a584e11 100644 --- a/package.json +++ b/package.json @@ -10,16 +10,24 @@ ], "homepage": "https://github.com/en-japan-air/react-intl-formatted-duration", "license": "MIT", - "main": "index.js", + "main": "dist/bundle.js", + "module": "dist/module.js", "repository": { "type": "git", "url": "https://github.com/en-japan-air/react-intl-formatted-duration" }, + "files": [ + "dist", + "index.js", + "messages.js" + ], "scripts": { + "compile": "rollup -c rollup.config.js", "lint": "eslint index.js", "test": "jest", "test:coverage": "jest --coverage", "test:watch": "jest --watchAll", + "prepublish": "npm run compile", "posttest": "npm run lint" }, "devDependencies": { @@ -35,7 +43,9 @@ "react": "^15.6.1", "react-dom": "^15.6.1", "react-intl": "^2.3.0", - "react-test-renderer": "^15.6.1" + "react-test-renderer": "^15.6.1", + "rollup": "0.43.0", + "rollup-plugin-babel": "2.7.1" }, "peerDependencies": { "prop-types": ">= 15.0", diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 0000000..113371c --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,15 @@ +import babel from 'rollup-plugin-babel'; +import pkg from './package.json'; + +export default { + entry: 'index.js', + plugins: [ + babel(), + ], + external: Object.keys(pkg.peerDependencies), + exports: 'named', + targets: [ + { dest: 'dist/bundle.js', format: 'cjs' }, + { dest: 'dist/module.js', format: 'es' }, + ], +};