Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Commit

Permalink
all: adjust build for production/development and add support devTools
Browse files Browse the repository at this point in the history
  • Loading branch information
raphamorim committed Jun 3, 2018
1 parent 970719a commit 45d1818
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 13 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
"linc": "node ./scripts/eslint/only-changed.js",
"benchmark-memory": "node scripts/benchmark/memory.js",
"build": "node scripts/rollup/build.js",
"build:prod": "cross-env NODE_ENV=PROD node scripts/rollup/build.js",
"build:stats": "node scripts/rollup/stats.js",
"prepublishOnly": "yarn test && yarn build:prod",
"prepublishOnly": "yarn test && yarn build",
"prettier:stat": "node ./scripts/prettier/index.js",
"clean-node-modules": "find ./ -name 'node_modules' -exec rm -rf '{}' +",
"test": "yarn lint && yarn prettier:stat && yarn flow && yarn jest:ci",
Expand Down
5 changes: 5 additions & 0 deletions packages/react-tv/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if (process.env.NODE_ENV === 'production') {
module.exports = require('./dist/react-tv.production.js');
} else {
module.exports = require('./dist/react-tv.development.js');
}
5 changes: 3 additions & 2 deletions packages/react-tv/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
"name": "react-tv",
"version": "0.3.4",
"description": "React renderer for low memory applications",
"main": "dist/react-tv.production.js",
"main": "index.js",
"files": [
"dist/"
"dist/",
"index.js"
],
"repository": {
"type": "git",
Expand Down
7 changes: 7 additions & 0 deletions packages/react-tv/renderer/ReactTVFiberEntry.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,13 @@ const ReactTVRenderer = {
}

ReactTVFiberRenderer.updateContainer((element: any), root, null, callback);

ReactTVFiberRenderer.injectIntoDevTools({
bundleType: (process.env.NODE_ENV === 'production') ? 0 : 1,
rendererPackageName: 'ReactTV',
findHostInstanceByFiber: ReactTVFiberRenderer.findHostInstance
})

return ReactTVFiberRenderer.getPublicRootInstance(root);
},
findDOMNode(componentOrElement: React$Element<any>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ describe('findDOMNode', () => {

class Sure extends React.Component {
componentDidMount() {
expect(findDOMNode(this)).toEqual(expectedNode);
expect(findDOMNode(this.input)).toEqual(expectedNode);
}

render() {
return <p>Sure!</p>;
return <p ref={node => this.input = node}>Sure!</p>;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export type HostConfig<T, P, I, TI, PI, C, CX, PL> = {
scheduleAnimationCallback(callback : () => void) : number | void,
scheduleDeferredCallback(callback : (deadline : Deadline) => void) : number | void,

prepareForCommit() : void,
resetAfterCommit() : void,

useSyncScheduling ?: boolean,
Expand Down
14 changes: 7 additions & 7 deletions scripts/rollup/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ const packagePath = 'packages/react-tv';

let tasks = [];

function stripEnvVariables(production) {
function stripEnvVariables(env) {
return {
__DEV__: production ? 'false' : 'true',
'process.env.NODE_ENV': production ? "'production'" : "'development'",
__DEV__: env === 'production' ? 'false' : 'true',
'process.env.NODE_ENV': "'" + env + "'",
};
}

Expand All @@ -29,7 +29,7 @@ function createBundle({entryPath, bundleType, destName}) {

let plugins = [
flow(),
replace(stripEnvVariables()),
replace(stripEnvVariables(bundleType)),
babel({
exclude: 'node_modules/**',
externalHelpers: false,
Expand All @@ -44,7 +44,7 @@ function createBundle({entryPath, bundleType, destName}) {
}),
];

if (bundleType.indexOf('PROD') >= 0) {
if (bundleType.indexOf('production') >= 0) {
plugins = plugins.concat([optimizeJs(), uglify()]);
}

Expand All @@ -65,13 +65,13 @@ function createBundle({entryPath, bundleType, destName}) {

createBundle({
entryPath: `${packagePath}/ReactTVEntry.js`,
bundleType: 'PROD',
bundleType: 'production',
destName: 'react-tv.production.js',
});

createBundle({
entryPath: `${packagePath}/ReactTVEntry.js`,
bundleType: 'DEV',
bundleType: 'development',
destName: 'react-tv.development.js',
});

Expand Down

0 comments on commit 45d1818

Please sign in to comment.