Skip to content

Commit 50b4857

Browse files
committed
Revert "Add support for yarn and lerna monorepos. (facebook#3741)"
This reverts commit b43ad04.
1 parent 92e40c3 commit 50b4857

33 files changed

+49
-548
lines changed

.travis.yml

-2
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,13 @@ script:
1818
- 'if [ $TEST_SUITE = "installs" ]; then tasks/e2e-installs.sh; fi'
1919
- 'if [ $TEST_SUITE = "kitchensink" ]; then tasks/e2e-kitchensink.sh; fi'
2020
- 'if [ $TEST_SUITE = "kitchensink-eject" ]; then tasks/e2e-kitchensink-eject.sh; fi'
21-
- 'if [ $TEST_SUITE = "monorepos" ]; then tasks/e2e-monorepos.sh; fi'
2221
- 'if [ $TEST_SUITE = "old-node" ]; then tasks/e2e-old-node.sh; fi'
2322
env:
2423
matrix:
2524
- TEST_SUITE=simple
2625
- TEST_SUITE=installs
2726
- TEST_SUITE=kitchensink
2827
- TEST_SUITE=kitchensink-eject
29-
- TEST_SUITE=monorepos
3028
matrix:
3129
include:
3230
- node_js: 4

appveyor.yml

-4
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ environment:
1010
test_suite: "kitchensink"
1111
- nodejs_version: 10
1212
test_suite: "kitchensink-eject"
13-
- nodejs_version: 10
14-
test_suite: "monorepos"
1513
- nodejs_version: 8
1614
test_suite: "simple"
1715
- nodejs_version: 8
@@ -20,8 +18,6 @@ environment:
2018
test_suite: "kitchensink"
2119
- nodejs_version: 8
2220
test_suite: "kitchensink-eject"
23-
- nodejs_version: 8
24-
test_suite: "monorepos"
2521
cache:
2622
- node_modules -> appveyor.cleanup-cache.txt
2723
- packages\react-scripts\node_modules -> appveyor.cleanup-cache.txt
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
// @remove-on-eject-begin
1+
// @remove-file-on-eject
22
/**
33
* Copyright (c) 2014-present, Facebook, Inc.
44
*
55
* This source code is licensed under the MIT license found in the
66
* LICENSE file in the root directory of this source tree.
77
*/
8-
// @remove-on-eject-end
98
'use strict';
109

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

1312
module.exports = babelJest.createTransformer({
1413
presets: [require.resolve('babel-preset-react-app')],
15-
// @remove-on-eject-begin
1614
babelrc: false,
17-
// @remove-on-eject-end
1815
});

packages/react-scripts/config/paths.js

+11-48
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
const path = require('path');
1212
const fs = require('fs');
1313
const url = require('url');
14-
const findPkg = require('find-pkg');
15-
const globby = require('globby');
1614

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

68-
let checkForMonorepo = true;
69-
7066
// @remove-on-eject-begin
7167
const resolveOwn = relativePath => path.resolve(__dirname, '..', relativePath);
7268

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

93-
// detect if template should be used, ie. when cwd is react-scripts itself
94-
const useTemplate =
95-
appDirectory === fs.realpathSync(path.join(__dirname, '..'));
96-
97-
checkForMonorepo = !useTemplate;
98-
99-
if (useTemplate) {
89+
const ownPackageJson = require('../package.json');
90+
const reactScriptsPath = resolveApp(`node_modules/${ownPackageJson.name}`);
91+
const reactScriptsLinked =
92+
fs.existsSync(reactScriptsPath) &&
93+
fs.lstatSync(reactScriptsPath).isSymbolicLink();
94+
95+
// config before publish: we're in ./packages/react-scripts/config/
96+
if (
97+
!reactScriptsLinked &&
98+
__dirname.indexOf(path.join('packages', 'react-scripts', 'config')) !== -1
99+
) {
100100
module.exports = {
101101
dotenv: resolveOwn('template/.env'),
102102
appPath: resolveApp('.'),
@@ -117,40 +117,3 @@ if (useTemplate) {
117117
};
118118
}
119119
// @remove-on-eject-end
120-
121-
module.exports.srcPaths = [module.exports.appSrc];
122-
123-
const findPkgs = (rootPath, globPatterns) => {
124-
const globOpts = {
125-
cwd: rootPath,
126-
strict: true,
127-
absolute: true,
128-
};
129-
return globPatterns
130-
.reduce(
131-
(pkgs, pattern) =>
132-
pkgs.concat(globby.sync(path.join(pattern, 'package.json'), globOpts)),
133-
[]
134-
)
135-
.map(f => path.dirname(path.normalize(f)));
136-
};
137-
138-
const getMonorepoPkgPaths = () => {
139-
const monoPkgPath = findPkg.sync(path.resolve(appDirectory, '..'));
140-
if (monoPkgPath) {
141-
// get monorepo config from yarn workspace
142-
const pkgPatterns = require(monoPkgPath).workspaces;
143-
const pkgPaths = findPkgs(path.dirname(monoPkgPath), pkgPatterns);
144-
// only include monorepo pkgs if app itself is included in monorepo
145-
if (pkgPaths.indexOf(appDirectory) !== -1) {
146-
return pkgPaths.filter(f => fs.realpathSync(f) !== appDirectory);
147-
}
148-
}
149-
return [];
150-
};
151-
152-
if (checkForMonorepo) {
153-
// if app is in a monorepo (lerna or yarn workspace), treat other packages in
154-
// the monorepo as if they are app source
155-
Array.prototype.push.apply(module.exports.srcPaths, getMonorepoPkgPaths());
156-
}

packages/react-scripts/config/webpack.config.dev.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -182,19 +182,18 @@ module.exports = {
182182
options: {
183183
formatter: require.resolve('react-dev-utils/eslintFormatter'),
184184
eslintPath: require.resolve('eslint'),
185+
// @remove-on-eject-begin
185186
baseConfig: {
186187
extends: [require.resolve('eslint-config-react-app')],
187188
},
188-
// @remove-on-eject-begin
189189
ignore: false,
190190
useEslintrc: false,
191191
// @remove-on-eject-end
192192
},
193193
loader: require.resolve('eslint-loader'),
194194
},
195195
],
196-
include: paths.srcPaths,
197-
exclude: [/[/\\\\]node_modules[/\\\\]/],
196+
include: paths.appSrc,
198197
},
199198
{
200199
// "oneOf" will traverse all following loaders until one will
@@ -216,8 +215,7 @@ module.exports = {
216215
// The preset includes JSX, Flow, and some ESnext features.
217216
{
218217
test: /\.(js|jsx|mjs)$/,
219-
include: paths.srcPaths,
220-
exclude: [/[/\\\\]node_modules[/\\\\]/],
218+
include: paths.appSrc,
221219
use: [
222220
// This loader parallelizes code compilation, it is optional but
223221
// improves compile time on larger projects
@@ -232,8 +230,8 @@ module.exports = {
232230
options: {
233231
// @remove-on-eject-begin
234232
babelrc: false,
235-
// @remove-on-eject-end
236233
presets: [require.resolve('babel-preset-react-app')],
234+
// @remove-on-eject-end
237235
plugins: [
238236
[
239237
require.resolve('babel-plugin-named-asset-import'),

packages/react-scripts/config/webpack.config.prod.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -220,21 +220,20 @@ module.exports = {
220220
options: {
221221
formatter: require.resolve('react-dev-utils/eslintFormatter'),
222222
eslintPath: require.resolve('eslint'),
223+
// @remove-on-eject-begin
223224
// TODO: consider separate config for production,
224225
// e.g. to enable no-console and no-debugger only in production.
225226
baseConfig: {
226227
extends: [require.resolve('eslint-config-react-app')],
227228
},
228-
// @remove-on-eject-begin
229229
ignore: false,
230230
useEslintrc: false,
231231
// @remove-on-eject-end
232232
},
233233
loader: require.resolve('eslint-loader'),
234234
},
235235
],
236-
include: paths.srcPaths,
237-
exclude: [/[/\\\\]node_modules[/\\\\]/],
236+
include: paths.appSrc,
238237
},
239238
{
240239
// "oneOf" will traverse all following loaders until one will
@@ -255,8 +254,7 @@ module.exports = {
255254
// The preset includes JSX, Flow, and some ESnext features.
256255
{
257256
test: /\.(js|jsx|mjs)$/,
258-
include: paths.srcPaths,
259-
exclude: [/[/\\\\]node_modules[/\\\\]/],
257+
include: paths.appSrc,
260258
use: [
261259
// This loader parallelizes code compilation, it is optional but
262260
// improves compile time on larger projects
@@ -266,8 +264,8 @@ module.exports = {
266264
options: {
267265
// @remove-on-eject-begin
268266
babelrc: false,
269-
// @remove-on-eject-end
270267
presets: [require.resolve('babel-preset-react-app')],
268+
// @remove-on-eject-end
271269
plugins: [
272270
[
273271
require.resolve('babel-plugin-named-asset-import'),

packages/react-scripts/fixtures/kitchensink/.babelrc

-3
This file was deleted.

packages/react-scripts/fixtures/monorepos/packages/comp1/index.js

-21
This file was deleted.

packages/react-scripts/fixtures/monorepos/packages/comp1/index.test.js

-8
This file was deleted.

packages/react-scripts/fixtures/monorepos/packages/comp1/package.json

-10
This file was deleted.

packages/react-scripts/fixtures/monorepos/packages/comp2/index.js

-11
This file was deleted.

packages/react-scripts/fixtures/monorepos/packages/comp2/index.test.js

-8
This file was deleted.

packages/react-scripts/fixtures/monorepos/packages/comp2/package.json

-13
This file was deleted.

packages/react-scripts/fixtures/monorepos/packages/cra-app1/.gitignore

-21
This file was deleted.

packages/react-scripts/fixtures/monorepos/packages/cra-app1/package.json

-32
This file was deleted.
Binary file not shown.

0 commit comments

Comments
 (0)