Skip to content

Commit

Permalink
Revert "Add support for yarn and lerna monorepos. (facebook#3741)"
Browse files Browse the repository at this point in the history
This reverts commit b43ad04.
  • Loading branch information
Timer committed Sep 18, 2018
1 parent 92e40c3 commit 50b4857
Show file tree
Hide file tree
Showing 33 changed files with 49 additions and 548 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ script:
- 'if [ $TEST_SUITE = "installs" ]; then tasks/e2e-installs.sh; fi'
- 'if [ $TEST_SUITE = "kitchensink" ]; then tasks/e2e-kitchensink.sh; fi'
- 'if [ $TEST_SUITE = "kitchensink-eject" ]; then tasks/e2e-kitchensink-eject.sh; fi'
- 'if [ $TEST_SUITE = "monorepos" ]; then tasks/e2e-monorepos.sh; fi'
- 'if [ $TEST_SUITE = "old-node" ]; then tasks/e2e-old-node.sh; fi'
env:
matrix:
- TEST_SUITE=simple
- TEST_SUITE=installs
- TEST_SUITE=kitchensink
- TEST_SUITE=kitchensink-eject
- TEST_SUITE=monorepos
matrix:
include:
- node_js: 4
Expand Down
4 changes: 0 additions & 4 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ environment:
test_suite: "kitchensink"
- nodejs_version: 10
test_suite: "kitchensink-eject"
- nodejs_version: 10
test_suite: "monorepos"
- nodejs_version: 8
test_suite: "simple"
- nodejs_version: 8
Expand All @@ -20,8 +18,6 @@ environment:
test_suite: "kitchensink"
- nodejs_version: 8
test_suite: "kitchensink-eject"
- nodejs_version: 8
test_suite: "monorepos"
cache:
- node_modules -> appveyor.cleanup-cache.txt
- packages\react-scripts\node_modules -> appveyor.cleanup-cache.txt
Expand Down
5 changes: 1 addition & 4 deletions packages/react-scripts/config/jest/babelTransform.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
// @remove-on-eject-begin
// @remove-file-on-eject
/**
* Copyright (c) 2014-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// @remove-on-eject-end
'use strict';

const babelJest = require('babel-jest');

module.exports = babelJest.createTransformer({
presets: [require.resolve('babel-preset-react-app')],
// @remove-on-eject-begin
babelrc: false,
// @remove-on-eject-end
});
59 changes: 11 additions & 48 deletions packages/react-scripts/config/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
const path = require('path');
const fs = require('fs');
const url = require('url');
const findPkg = require('find-pkg');
const globby = require('globby');

// Make sure any symlinks in the project folder are resolved:
// https://github.com/facebook/create-react-app/issues/637
Expand Down Expand Up @@ -65,8 +63,6 @@ module.exports = {
servedPath: getServedPath(resolveApp('package.json')),
};

let checkForMonorepo = true;

// @remove-on-eject-begin
const resolveOwn = relativePath => path.resolve(__dirname, '..', relativePath);

Expand All @@ -90,13 +86,17 @@ module.exports = {
ownNodeModules: resolveOwn('node_modules'), // This is empty on npm 3
};

// detect if template should be used, ie. when cwd is react-scripts itself
const useTemplate =
appDirectory === fs.realpathSync(path.join(__dirname, '..'));

checkForMonorepo = !useTemplate;

if (useTemplate) {
const ownPackageJson = require('../package.json');
const reactScriptsPath = resolveApp(`node_modules/${ownPackageJson.name}`);
const reactScriptsLinked =
fs.existsSync(reactScriptsPath) &&
fs.lstatSync(reactScriptsPath).isSymbolicLink();

// config before publish: we're in ./packages/react-scripts/config/
if (
!reactScriptsLinked &&
__dirname.indexOf(path.join('packages', 'react-scripts', 'config')) !== -1
) {
module.exports = {
dotenv: resolveOwn('template/.env'),
appPath: resolveApp('.'),
Expand All @@ -117,40 +117,3 @@ if (useTemplate) {
};
}
// @remove-on-eject-end

module.exports.srcPaths = [module.exports.appSrc];

const findPkgs = (rootPath, globPatterns) => {
const globOpts = {
cwd: rootPath,
strict: true,
absolute: true,
};
return globPatterns
.reduce(
(pkgs, pattern) =>
pkgs.concat(globby.sync(path.join(pattern, 'package.json'), globOpts)),
[]
)
.map(f => path.dirname(path.normalize(f)));
};

const getMonorepoPkgPaths = () => {
const monoPkgPath = findPkg.sync(path.resolve(appDirectory, '..'));
if (monoPkgPath) {
// get monorepo config from yarn workspace
const pkgPatterns = require(monoPkgPath).workspaces;
const pkgPaths = findPkgs(path.dirname(monoPkgPath), pkgPatterns);
// only include monorepo pkgs if app itself is included in monorepo
if (pkgPaths.indexOf(appDirectory) !== -1) {
return pkgPaths.filter(f => fs.realpathSync(f) !== appDirectory);
}
}
return [];
};

if (checkForMonorepo) {
// if app is in a monorepo (lerna or yarn workspace), treat other packages in
// the monorepo as if they are app source
Array.prototype.push.apply(module.exports.srcPaths, getMonorepoPkgPaths());
}
10 changes: 4 additions & 6 deletions packages/react-scripts/config/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,19 +182,18 @@ module.exports = {
options: {
formatter: require.resolve('react-dev-utils/eslintFormatter'),
eslintPath: require.resolve('eslint'),
// @remove-on-eject-begin
baseConfig: {
extends: [require.resolve('eslint-config-react-app')],
},
// @remove-on-eject-begin
ignore: false,
useEslintrc: false,
// @remove-on-eject-end
},
loader: require.resolve('eslint-loader'),
},
],
include: paths.srcPaths,
exclude: [/[/\\\\]node_modules[/\\\\]/],
include: paths.appSrc,
},
{
// "oneOf" will traverse all following loaders until one will
Expand All @@ -216,8 +215,7 @@ module.exports = {
// The preset includes JSX, Flow, and some ESnext features.
{
test: /\.(js|jsx|mjs)$/,
include: paths.srcPaths,
exclude: [/[/\\\\]node_modules[/\\\\]/],
include: paths.appSrc,
use: [
// This loader parallelizes code compilation, it is optional but
// improves compile time on larger projects
Expand All @@ -232,8 +230,8 @@ module.exports = {
options: {
// @remove-on-eject-begin
babelrc: false,
// @remove-on-eject-end
presets: [require.resolve('babel-preset-react-app')],
// @remove-on-eject-end
plugins: [
[
require.resolve('babel-plugin-named-asset-import'),
Expand Down
10 changes: 4 additions & 6 deletions packages/react-scripts/config/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,21 +220,20 @@ module.exports = {
options: {
formatter: require.resolve('react-dev-utils/eslintFormatter'),
eslintPath: require.resolve('eslint'),
// @remove-on-eject-begin
// TODO: consider separate config for production,
// e.g. to enable no-console and no-debugger only in production.
baseConfig: {
extends: [require.resolve('eslint-config-react-app')],
},
// @remove-on-eject-begin
ignore: false,
useEslintrc: false,
// @remove-on-eject-end
},
loader: require.resolve('eslint-loader'),
},
],
include: paths.srcPaths,
exclude: [/[/\\\\]node_modules[/\\\\]/],
include: paths.appSrc,
},
{
// "oneOf" will traverse all following loaders until one will
Expand All @@ -255,8 +254,7 @@ module.exports = {
// The preset includes JSX, Flow, and some ESnext features.
{
test: /\.(js|jsx|mjs)$/,
include: paths.srcPaths,
exclude: [/[/\\\\]node_modules[/\\\\]/],
include: paths.appSrc,
use: [
// This loader parallelizes code compilation, it is optional but
// improves compile time on larger projects
Expand All @@ -266,8 +264,8 @@ module.exports = {
options: {
// @remove-on-eject-begin
babelrc: false,
// @remove-on-eject-end
presets: [require.resolve('babel-preset-react-app')],
// @remove-on-eject-end
plugins: [
[
require.resolve('babel-plugin-named-asset-import'),
Expand Down
3 changes: 0 additions & 3 deletions packages/react-scripts/fixtures/kitchensink/.babelrc

This file was deleted.

21 changes: 0 additions & 21 deletions packages/react-scripts/fixtures/monorepos/packages/comp1/index.js

This file was deleted.

This file was deleted.

This file was deleted.

11 changes: 0 additions & 11 deletions packages/react-scripts/fixtures/monorepos/packages/comp2/index.js

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.
Loading

0 comments on commit 50b4857

Please sign in to comment.