Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit dc957e2

Browse files
authored
Merge branch 'master' into patch-webpack-mainFields
2 parents 3792a47 + a6417e3 commit dc957e2

File tree

4 files changed

+38
-27
lines changed

4 files changed

+38
-27
lines changed

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ See [React Workspaces Playground](https://github.com/react-workspaces/react-work
66

77
[![React Workspaces Playground Screenshots](https://i.imgur.com/7snWXD0.png)](https://github.com/react-workspaces/react-workspaces-playground)
88

9-
For more information on why this ways created, please read this for more info: [Support Lerna and/or Yarn Workspaces #1333](https://github.com/facebook/create-react-app/issues/1333)
9+
For more information on why this was created, please read this for more info: [Support Lerna and/or Yarn Workspaces #1333](https://github.com/facebook/create-react-app/issues/1333)
1010

1111
# Create React App [![Build Status](https://travis-ci.org/facebook/create-react-app.svg?branch=master)](https://travis-ci.org/facebook/create-react-app) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-green.svg)](https://github.com/facebook/create-react-app/pulls)
1212

‎packages/react-scripts/config/paths.js‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
const path = require('path');
1212
const fs = require('fs');
1313
const url = require('url');
14+
const findUp = require('find-up');
1415

1516
// Make sure any symlinks in the project folder are resolved:
1617
// https://github.com/facebook/create-react-app/issues/637
@@ -122,7 +123,9 @@ module.exports = {
122123
};
123124

124125
const ownPackageJson = require('../package.json');
125-
const reactScriptsPath = resolveApp(`node_modules/${ownPackageJson.name}`);
126+
const reactScriptsPath = findUp.sync(`node_modules/${ownPackageJson.name}`, {
127+
cwd: resolveApp('.'),
128+
});
126129
const reactScriptsLinked =
127130
fs.existsSync(reactScriptsPath) &&
128131
fs.lstatSync(reactScriptsPath).isSymbolicLink();

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

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,26 @@ module.exports = function(webpackEnv) {
6262
const isEnvDevelopment = webpackEnv === 'development';
6363
const isEnvProduction = webpackEnv === 'production';
6464

65-
const workspacesMainFields = [workspacesConfig.packageEntry, 'browser', 'module', 'main'];
65+
const workspacesMainFields = [
66+
workspacesConfig.packageEntry,
67+
'browser',
68+
'module',
69+
'main',
70+
];
6671
const mainFields =
6772
isEnvDevelopment && workspacesConfig.development
6873
? workspacesMainFields
6974
: isEnvProduction && workspacesConfig.production
7075
? workspacesMainFields
7176
: undefined;
7277

78+
const includePaths =
79+
isEnvDevelopment && workspacesConfig.development
80+
? [paths.appSrc, ...workspacesConfig.paths]
81+
: isEnvProduction && workspacesConfig.production
82+
? [paths.appSrc, ...workspacesConfig.paths]
83+
: paths.appSrc;
84+
7385
// Webpack uses `publicPath` to determine where the app is being served from.
7486
// It requires a trailing slash, or the file assets will get an incorrect path.
7587
// In development, we always serve from the root. This makes config easier.
@@ -342,11 +354,13 @@ module.exports = function(webpackEnv) {
342354
loader: require.resolve('eslint-loader'),
343355
},
344356
],
345-
include: isEnvDevelopment && workspacesConfig.development
346-
? [paths.appSrc, workspacesConfig.paths]
347-
: isEnvProduction && workspacesConfig.production
348-
? [paths.appSrc, workspacesConfig.paths]
349-
: paths.appSrc,
357+
include: includePaths,
358+
// Don't lint typescript files outside the main package because it has problems with some syntax rules, e.g. abstract
359+
exclude: useTypeScript
360+
? file =>
361+
/\.tsx?/.test(path.extname(file)) &&
362+
!file.startsWith(paths.appSrc)
363+
: undefined,
350364
},
351365
{
352366
// "oneOf" will traverse all following loaders until one will
@@ -368,12 +382,7 @@ module.exports = function(webpackEnv) {
368382
// The preset includes JSX, Flow, TypeScript, and some ESnext features.
369383
{
370384
test: /\.(js|mjs|jsx|ts|tsx)$/,
371-
include:
372-
isEnvDevelopment && workspacesConfig.development
373-
? [paths.appSrc, workspacesConfig.paths]
374-
: isEnvProduction && workspacesConfig.production
375-
? [paths.appSrc, workspacesConfig.paths]
376-
: paths.appSrc,
385+
include: includePaths,
377386
loader: require.resolve('babel-loader'),
378387
options: {
379388
customize: require.resolve(
@@ -656,6 +665,10 @@ module.exports = function(webpackEnv) {
656665
typescript: resolve.sync('typescript', {
657666
basedir: paths.appNodeModules,
658667
}),
668+
compilerOptions: {
669+
skipLibCheck: true,
670+
suppressOutputPathCheck: true,
671+
},
659672
async: isEnvDevelopment,
660673
useTypescriptIncrementalApi: true,
661674
checkSyntacticErrors: true,
@@ -667,7 +680,7 @@ module.exports = function(webpackEnv) {
667680
'!**/src/setupProxy.*',
668681
'!**/src/setupTests.*',
669682
],
670-
watch: paths.appSrc,
683+
watch: includePaths,
671684
silent: true,
672685
// The formatter is invoked directly in WebpackDevServerUtils during development
673686
formatter: isEnvProduction ? typescriptFormatter : undefined,

‎packages/react-scripts/config/yarn-workspaces.js‎

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@ const getWorkspacesRootConfig = dir => {
2323

2424
const packageObj = loadPackageJson(packageJsonUp);
2525

26-
if (Reflect.has(packageObj, 'workspaces')) {
26+
if (
27+
packageObj.workspaces &&
28+
(
29+
Array.isArray(packageObj.workspaces) ||
30+
Reflect.has(packageObj.workspaces, 'packages')
31+
)
32+
) {
2733
const workspacesRootConfig = {
2834
root: path.dirname(packageJsonUp),
2935
workspaces: packageObj.workspaces
@@ -161,17 +167,6 @@ const getDeps = pkg => {
161167

162168
const depsTable = {};
163169

164-
const filterDeps = deps =>
165-
Reflect.ownKeys(deps).filter(dep => Reflect.has(depsTable, dep));
166-
167-
const filterDepsTable = () => {
168-
Reflect.ownKeys(depsTable).forEach(depName => {
169-
const depsList = depsTable[depName].deps;
170-
const workspacesOnlyDeps = filterDeps(depsList);
171-
depsTable[depName].deps = workspacesOnlyDeps;
172-
});
173-
};
174-
175170
const buildDepsTable = srcPaths => {
176171
srcPaths.forEach(path => {
177172
const pkg = getPkg(path);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /