mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
added NPM package creation and copying into build chain
This commit is contained in:
@@ -72,6 +72,7 @@
|
||||
"loose-envify": "^1.1.0",
|
||||
"merge-stream": "^1.0.0",
|
||||
"minimist": "^1.2.0",
|
||||
"ncp": "^2.0.0",
|
||||
"object-assign": "^4.1.1",
|
||||
"platform": "^1.1.0",
|
||||
"prettier": "^0.22.0",
|
||||
|
||||
Vendored
+5
-1
@@ -1,3 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = require('./lib/ReactDOMFiber');
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
module.exports = require('./react-dom.node-prod.js');
|
||||
} else {
|
||||
module.exports = require('./react-dom.node-dev.js');
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = require('./lib/ReactNative');
|
||||
module.exports = require('./ReactNative');
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
module.exports = require('./react.node-prod.js');
|
||||
} else {
|
||||
module.exports = require('./react.node-dev.js');
|
||||
}
|
||||
@@ -17,7 +17,7 @@
|
||||
"dist/",
|
||||
"lib/"
|
||||
],
|
||||
"main": "react.js",
|
||||
"main": "index.js",
|
||||
"repository": "facebook/react",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
|
||||
Vendored
-3
@@ -1,3 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = require('./lib/React');
|
||||
@@ -7,9 +7,11 @@ const alias = require('rollup-plugin-alias');
|
||||
const filesize = require('rollup-plugin-filesize');
|
||||
const uglify = require('rollup-plugin-uglify');
|
||||
const replace = require('rollup-plugin-replace');
|
||||
const ncp = require('ncp').ncp;
|
||||
const chalk = require('chalk');
|
||||
const boxen = require('boxen');
|
||||
const { resolve, join } = require('path');
|
||||
const { mkdirSync, unlinkSync, existsSync } = require('fs');
|
||||
const rimraf = require('rimraf');
|
||||
const argv = require('minimist')(process.argv.slice(2));
|
||||
const {
|
||||
@@ -173,6 +175,53 @@ function getCommonJsConfig(bundleType) {
|
||||
}
|
||||
}
|
||||
|
||||
function copyNodePackageTemplate(packageName) {
|
||||
const from = resolve(`./packages/${packageName}`);
|
||||
const to = resolve(`./build/rollup/packages/${packageName}`);
|
||||
|
||||
// if the package directory already exists, we skip copying to it
|
||||
if (!existsSync(to)) {
|
||||
return new Promise((res, rej) => {
|
||||
ncp(from, to, error => {
|
||||
if (error) {
|
||||
rej(error);
|
||||
}
|
||||
res();
|
||||
});
|
||||
});
|
||||
} else {
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
|
||||
function copyBundleIntoNodePackage(packageName, filename) {
|
||||
const from = resolve(`./build/rollup/${filename}`);
|
||||
const to = resolve(`./build/rollup/packages/${packageName}/${filename}`);
|
||||
|
||||
return new Promise((res, rej) => {
|
||||
ncp(from, to, error => {
|
||||
if (error) {
|
||||
rej(error);
|
||||
}
|
||||
// delete the old file
|
||||
unlinkSync(from);
|
||||
res();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function createNodePackage(bundleType, packageName, filename) {
|
||||
const { NODE_DEV, NODE_PROD, RN } = bundleTypes;
|
||||
|
||||
// we only copy packages for NODE_DEV, NODE_PROD and FB bundle types
|
||||
if (bundleType === NODE_DEV || bundleType === NODE_PROD || bundleType === RN) {
|
||||
return copyNodePackageTemplate(packageName).then(
|
||||
() => copyBundleIntoNodePackage(packageName, filename)
|
||||
);
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
function getPlugins(entry, babelOpts, paths, filename, bundleType, isRenderer) {
|
||||
const plugins = [
|
||||
replace(
|
||||
@@ -243,6 +292,8 @@ function createBundle({
|
||||
plugins: getPlugins(entry, babelOpts, paths, filename, bundleType, isRenderer),
|
||||
}).then(({write}) => write(
|
||||
updateBundleConfig(config, filename, format, bundleType, hasteName)
|
||||
)).then(() => (
|
||||
createNodePackage(bundleType, name, filename)
|
||||
)).catch(error => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
@@ -251,6 +302,10 @@ function createBundle({
|
||||
|
||||
// clear the build folder
|
||||
rimraf(join('build', 'rollup'), () => {
|
||||
// TODO: this line can go away once we remove rollup folder
|
||||
mkdirSync(resolve(`./build/rollup`));
|
||||
// create the packages folder
|
||||
mkdirSync(resolve(`./build/rollup/packages/`));
|
||||
bundles.forEach(bundle =>
|
||||
Promise.resolve()
|
||||
.then(() => createBundle(bundle, bundleTypes.DEV))
|
||||
|
||||
@@ -57,7 +57,7 @@ const bundles = [
|
||||
/******* React DOM *******/
|
||||
{
|
||||
babelOpts: babelOptsReact,
|
||||
bundleTypes: [DEV, PROD, NODE_DEV, NODE_PROD, FB],
|
||||
bundleTypes: [DEV, PROD, FB],
|
||||
config: {
|
||||
destDir: 'build/rollup/',
|
||||
globals: {
|
||||
@@ -71,7 +71,7 @@ const bundles = [
|
||||
fbEntry: 'src/fb/ReactDOMFBEntry.js',
|
||||
hasteName: 'ReactDOMStack-fb',
|
||||
isRenderer: true,
|
||||
name: 'react-dom',
|
||||
name: 'react-dom-stack',
|
||||
paths: [
|
||||
'src/umd/ReactDOMUMDEntry.js',
|
||||
|
||||
@@ -99,7 +99,7 @@ const bundles = [
|
||||
fbEntry: 'src/fb/ReactDOMFiberFBEntry.js',
|
||||
hasteName: 'ReactDOMFiber-fb',
|
||||
isRenderer: true,
|
||||
name: 'react-dom-fiber',
|
||||
name: 'react-dom',
|
||||
paths: [
|
||||
'src/renderers/dom/**/*.js',
|
||||
'src/renderers/shared/**/*.js',
|
||||
@@ -113,7 +113,8 @@ const bundles = [
|
||||
/******* React DOM Server *******/
|
||||
{
|
||||
babelOpts: babelOptsReact,
|
||||
bundleTypes: [DEV, PROD, NODE_DEV, NODE_PROD, FB],
|
||||
// TODO: deal with the Node version of react-dom-server package
|
||||
bundleTypes: [DEV, PROD, FB],
|
||||
config: {
|
||||
destDir: 'build/rollup/',
|
||||
globals: {
|
||||
@@ -145,7 +146,9 @@ const bundles = [
|
||||
/******* React ART *******/
|
||||
{
|
||||
babelOpts: babelOptsReactART,
|
||||
bundleTypes: [DEV, PROD, NODE_DEV, NODE_PROD, FB],
|
||||
// TODO: we merge react-art repo into this repo so the NODE_DEV and NODE_PROD
|
||||
// builds sync up to the building of the package directories
|
||||
bundleTypes: [DEV, PROD, FB],
|
||||
config: {
|
||||
destDir: 'build/rollup/',
|
||||
globals: {
|
||||
@@ -164,6 +167,7 @@ const bundles = [
|
||||
hasteName: 'ReactARTStack',
|
||||
isRenderer: true,
|
||||
name: 'react-art',
|
||||
nodePackageName: 'react-art',
|
||||
paths: [
|
||||
// TODO: it relies on ReactDOMFrameScheduling. Need to move to shared/?
|
||||
'src/renderers/dom/**/*.js',
|
||||
@@ -176,7 +180,9 @@ const bundles = [
|
||||
},
|
||||
{
|
||||
babelOpts: babelOptsReactART,
|
||||
bundleTypes: [DEV, PROD, NODE_DEV, NODE_PROD, FB],
|
||||
// TODO: we merge react-art repo into this repo so the NODE_DEV and NODE_PROD
|
||||
// builds sync up to the building of the package directories
|
||||
bundleTypes: [DEV, PROD, FB],
|
||||
config: {
|
||||
destDir: 'build/rollup/',
|
||||
globals: {
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var ReactNative = require('ReactNative');
|
||||
var ReactNativeFeatureFlags = require('ReactNativeFeatureFlags');
|
||||
var ReactNativeAttributePayload = require('ReactNativeAttributePayload');
|
||||
var TextInputState = require('TextInputState');
|
||||
@@ -20,6 +19,12 @@ var UIManager = require('UIManager');
|
||||
var invariant = require('fbjs/lib/invariant');
|
||||
var findNodeHandle = require('findNodeHandle');
|
||||
|
||||
var ReactNative;
|
||||
|
||||
function injectReactNative(RN) {
|
||||
ReactNative = RN;
|
||||
}
|
||||
|
||||
var {
|
||||
mountSafeCallback,
|
||||
throwOnStylesProp,
|
||||
@@ -133,7 +138,7 @@ var NativeMethodsMixin = {
|
||||
// Without having executed ReactNative.
|
||||
// Defer the factory function until now to avoid a cycle with UIManager.
|
||||
// TODO (bvaughn) Remove this once ReactNativeStack is dropped.
|
||||
require('ReactNative');
|
||||
// require('ReactNative');
|
||||
|
||||
injectedSetNativeProps(this, nativeProps);
|
||||
},
|
||||
|
||||
@@ -10,12 +10,15 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
const ReactNativeFeatureFlags = require('ReactNativeFeatureFlags');
|
||||
var ReactNativeFeatureFlags = require('ReactNativeFeatureFlags');
|
||||
var NativeMethodsMixin = require('NativeMethodsMixin');
|
||||
|
||||
var ReactNative = ReactNativeFeatureFlags.useFiber
|
||||
? require('ReactNativeFiber')
|
||||
: require('ReactNativeStack');
|
||||
|
||||
NativeMethodsMixin.__injectReactNative(ReactNative);
|
||||
|
||||
ReactNative.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {
|
||||
createReactNativeComponentClass: require('createReactNativeComponentClass'),
|
||||
findNodeHandle: require('findNodeHandle'),
|
||||
|
||||
Reference in New Issue
Block a user