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

Commit

Permalink
release: react-tv 0.2.0rc
Browse files Browse the repository at this point in the history
- Simple DOM renderer (ref: #11)
- New test architecture (using Jest)
- Add node (umd) version
- Add minified version
- Update .editorconfig to Facebook/react
  • Loading branch information
raphamorim committed Nov 3, 2017
1 parent 8b2ddd2 commit dd31f8c
Show file tree
Hide file tree
Showing 8 changed files with 238 additions and 116 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
*.log

package-lock.json
build/**
dist/**
node_modules
cli/generators/app/yarn.lock
13 changes: 13 additions & 0 deletions examples/clock-vanilla/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "clock-react-tv",
"version": "1.0.0",
"author": "Raphael Amorim",
"license": "MIT",
"scripts": {
"start": "react-tv run-webos-dev"
},
"dependencies": {
"react": "^16.0.0",
"react-tv": "^0.1.4-rc.1"
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<div id="root"></div>

<script src="../../node_modules/react/dist/react.min.js"></script>
<script src="../../build/react-tv.js"></script>
<script src="../../build/react-tv.min.js"></script>
<script src="./example.js"></script>
<script>
</script>
Expand Down
24 changes: 16 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
{
"name": "react-tv",
"version": "0.2.0",
"version": "0.2.0-rc",
"description": "React development for TV (WebOS, Tizen, Orsay)",
"main": "src/ReactTVEntry.js",
"main": "dist/react-tv.umd.js",
"bin": {
"react-tv": "./cli"
},
"files": [
"LICENSE",
"README.md",
"cli/",
"build/"
],
"scripts": {
"build": "node scripts/rollup/build.js",
"test": "yarn flow && jest",
Expand All @@ -18,28 +24,30 @@
"express": "^4.15.4",
"fbjs": "^0.8.4",
"fs-extra": "^4.0.1",
"node-replace": "^0.3.1",
"react": "16.0.0-alpha.3",
"react-dom": "16.0.0-alpha.3"
"node-replace": "^0.3.1"
},
"devDependencies": {
"babel-jest": "20.1.0-delta.1",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-transform-flow-strip-types": "^6.22.0",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"babel-register": "^6.26.0",
"commitplease": "^3.1.0",
"flow-bin": "^0.57.3",
"jest": "20.1.0-delta.1",
"prettier": "^1.5.3",
"react": "16.0.0-alpha.3",
"react-dom": "16.0.0-alpha.3",
"react-fiber-types": "file:src/renderer/types",
"rollup": "^0.41.6",
"rollup": "^0.50.0",
"rollup-plugin-babel": "^2.7.1",
"rollup-plugin-commonjs": "^8.0.2",
"rollup-plugin-flow": "^1.1.1",
"rollup-plugin-node-resolve": "^2.0.0",
"rollup-plugin-replace": "^2.0.0"
"rollup-plugin-optimize-js": "^0.0.4",
"rollup-plugin-replace": "^2.0.0",
"rollup-plugin-uglify": "^2.0.1"
},
"repository": {
"type": "git",
Expand Down
125 changes: 68 additions & 57 deletions scripts/rollup/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ const babel = require('rollup-plugin-babel');
const flow = require('rollup-plugin-flow');
const commonjs = require('rollup-plugin-commonjs');
const resolve = require('rollup-plugin-node-resolve');
const uglify = require('rollup-plugin-uglify');
const replace = require('rollup-plugin-replace');
const optimizeJs = require('rollup-plugin-optimize-js');
const chalk = require('chalk');

const REACT_TV_VERSION = require('../../package.json').version;

const Header = require('./header');
let tasks = [];

function stripEnvVariables(production) {
return {
Expand All @@ -20,70 +22,79 @@ function stripEnvVariables(production) {
};
}

function getBanner(filename, moduleType) {
return Header.getHeader(filename, REACT_TV_VERSION);
}
function createBundle({ entryPath, bundleType, destName }) {
entryPath = path.resolve(entryPath);
const logKey = chalk.white.bold(entryPath) + chalk.dim(` (${REACT_TV_VERSION})`);
console.log(`${chalk.blue(bundleType)} ${logKey} -> dist/${destName}`);

function runWaterfall(promiseFactories) {
if (promiseFactories.length === 0) {
return Promise.resolve();
}
let plugins = [
flow(),
babel({
babelrc: false,
exclude: 'node_modules/**',
externalHelpers: true,
presets: [
[ 'env', { 'modules': false } ],
'react',
'stage-2'
],
plugins: [
'transform-flow-strip-types',
'external-helpers'
]
})
]

const head = promiseFactories[0];
const tail = promiseFactories.slice(1);
if (bundleType.indexOf('PROD') >= 0)
plugins = plugins.concat([
uglify(),
optimizeJs(),
replace(stripEnvVariables())
])

const nextPromiseFactory = head;
const nextPromise = nextPromiseFactory();
if (!nextPromise || typeof nextPromise.then !== 'function') {
throw new Error('runWaterfall() received something that is not a Promise.');
}
plugins = plugins.concat([
commonjs(),
resolve({
jsnext: true,
main: true,
browser: true,
})
]);

return nextPromise.then(() => {
return runWaterfall(tail);
});
rollup({
input: entryPath,
plugins: plugins,
external: ['react'],
sourcemap: false,
}).then(bundle => {
tasks.push(
bundle.write({
format: (bundleType === 'PROD-UMD') ? 'umd' : 'iife',
name: 'ReactTV',
file: `dist/${destName}`,
})
)
})
}

function createBundle({ entryPath, bundleType }) {
console.log(`${chalk.bgGreen.white(REACT_TV_VERSION)}`);

entryPath = path.resolve(entryPath);
const logKey = chalk.white.bold(entryPath) + chalk.dim(` (${bundleType.toLowerCase()})`);
console.log(`${chalk.bgYellow.black(' BUILDING ')} ${logKey}`);
createBundle({
entryPath: 'src/ReactTVEntry.js',
bundleType: 'DEV',
destName: 'react-tv.js',
});

rollup({
entry: entryPath,
plugins: [
flow(),
babel({
babelrc: false,
exclude: 'node_modules/**',
presets: [
[ 'env', { 'modules': false } ],
'react',
'stage-2'
],
plugins: [
'transform-flow-strip-types'
]
}),
commonjs(),
resolve({
jsnext: true,
}),
replace(stripEnvVariables())
]
}).then(bundle => Promise.all([
bundle.write({
banner: getBanner('react-tv.js'),
format: 'iife',
moduleName: 'ReactTV',
sourceMap: 'inline',
dest: 'build/react-tv.js',
})
])).catch(error => console.log(error));
}
createBundle({
entryPath: 'src/ReactTVEntry.js',
bundleType: 'PROD',
destName: 'react-tv.min.js',
});

createBundle({
entryPath: 'src/ReactTVEntry.js',
bundleType: 'DEV'
bundleType: 'PROD-UMD',
destName: 'react-tv.umd.js',
});

Promise.all(tasks).catch(error => {
Promise.reject(error);
});
32 changes: 0 additions & 32 deletions scripts/rollup/header.js

This file was deleted.

Loading

0 comments on commit dd31f8c

Please sign in to comment.