From a356356d6b73c8163106997f7c472460e039e57e Mon Sep 17 00:00:00 2001 From: Bogdan Chadkin Date: Tue, 11 Apr 2017 20:28:42 +0300 Subject: [PATCH] Add commonjs bundle as main entry point (#351) --- scripts/release.js | 1 + scripts/rollup.config.js | 10 ++++++---- src/basePackage.json | 1 - src/packages/recompose-relay/createContainer.js | 3 +-- src/packages/recompose-relay/package.json | 1 + src/packages/recompose/package.json | 1 + 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/scripts/release.js b/scripts/release.js index c1a630f6..2e694e7d 100644 --- a/scripts/release.js +++ b/scripts/release.js @@ -127,6 +127,7 @@ const run = async () => { `--environment BUILD:${build},PACKAGE_NAME:${packageName}` if (exec([ runRollup('es'), + runRollup('cjs'), runRollup('umd'), runRollup('min') ].join(' && ')).code !== 0) { diff --git a/scripts/rollup.config.js b/scripts/rollup.config.js index 58aee954..9e025635 100644 --- a/scripts/rollup.config.js +++ b/scripts/rollup.config.js @@ -29,15 +29,17 @@ const config = { ] } -if (build === 'es') { +if (build === 'es' || build === 'cjs') { config.external.push( 'fbjs/lib/shallowEqual', 'hoist-non-react-statics', 'change-emitter', - 'symbol-observable' + 'symbol-observable', + 'react-relay', + 'recompose' ) - config.dest = `${outDir}/es/${libraryName}.js` - config.format = 'es' + config.dest = `${outDir}/${build}/${libraryName}.js` + config.format = build } if (build === 'umd') { diff --git a/src/basePackage.json b/src/basePackage.json index 2b0280a8..b9b001b0 100644 --- a/src/basePackage.json +++ b/src/basePackage.json @@ -4,7 +4,6 @@ "type": "git", "url": "https://github.com/acdlite/recompose.git" }, - "main": "index.js", "license": "MIT", "bugs": { "url": "https://github.com/acdlite/recompose/issues" diff --git a/src/packages/recompose-relay/createContainer.js b/src/packages/recompose-relay/createContainer.js index 33255866..26bf8755 100644 --- a/src/packages/recompose-relay/createContainer.js +++ b/src/packages/recompose-relay/createContainer.js @@ -1,6 +1,5 @@ import Relay from 'react-relay' -import toClass from 'recompose/toClass' -import createHelper from 'recompose/createHelper' +import { toClass, createHelper } from 'recompose' const createContainer = options => BaseComponent => Relay.createContainer(toClass(BaseComponent), options) diff --git a/src/packages/recompose-relay/package.json b/src/packages/recompose-relay/package.json index dbc11016..acbaa444 100644 --- a/src/packages/recompose-relay/package.json +++ b/src/packages/recompose-relay/package.json @@ -14,6 +14,7 @@ "utilities", "composition" ], + "main": "cjs/RecomposeRelay.js", "module": "es/RecomposeRelay.js", "dependencies": { "lodash": "^4.0.0" diff --git a/src/packages/recompose/package.json b/src/packages/recompose/package.json index 647170e6..e8d505e0 100644 --- a/src/packages/recompose/package.json +++ b/src/packages/recompose/package.json @@ -9,6 +9,7 @@ "utilities", "composition" ], + "main": "cjs/Recompose.js", "module": "es/Recompose.js", "dependencies": { "change-emitter": "^0.1.2",