Skip to content

Zerim/fix/yarn workspace monorepo 2.8.0 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 23 additions & 25 deletions packages/react-scripts/config/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,31 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
// @remove-on-eject-end
'use strict';
'use strict'

const path = require('path');
const fs = require('fs');
const url = require('url');
const path = require('path')
const fs = require('fs')
const url = require('url')

// Make sure any symlinks in the project folder are resolved:
// https://github.com/facebookincubator/create-react-app/issues/637
const appDirectory = fs.realpathSync(process.cwd());
const resolveApp = relativePath => path.resolve(appDirectory, relativePath);
const appDirectory = fs.realpathSync(process.cwd())
const resolveApp = relativePath => path.resolve(appDirectory, relativePath)

const envPublicUrl = process.env.PUBLIC_URL;
const envPublicUrl = process.env.PUBLIC_URL

function ensureSlash(path, needsSlash) {
const hasSlash = path.endsWith('/');
const hasSlash = path.endsWith('/')
if (hasSlash && !needsSlash) {
return path.substr(path, path.length - 1);
return path.substr(path, path.length - 1)
} else if (!hasSlash && needsSlash) {
return `${path}/`;
return `${path}/`
} else {
return path;
return path
}
}

const getPublicUrl = appPackageJson =>
envPublicUrl || require(appPackageJson).homepage;
const getPublicUrl = appPackageJson => envPublicUrl || require(appPackageJson).homepage

// We use `PUBLIC_URL` environment variable or "homepage" field to infer
// "public path" at which the app is served.
Expand All @@ -42,10 +41,9 @@ const getPublicUrl = appPackageJson =>
// We can't use a relative path in HTML because we don't want to load something
// like /todos/42/static/js/bundle.7289d.js. We have to know the root.
function getServedPath(appPackageJson) {
const publicUrl = getPublicUrl(appPackageJson);
const servedUrl =
envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : '/');
return ensureSlash(servedUrl, true);
const publicUrl = getPublicUrl(appPackageJson)
const servedUrl = envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : '/')
return ensureSlash(servedUrl, true)
}

// config after eject: we're in ./config/
Expand All @@ -63,10 +61,10 @@ module.exports = {
appTsConfig: resolveApp('tsconfig.json'),
publicUrl: getPublicUrl(resolveApp('package.json')),
servedPath: getServedPath(resolveApp('package.json')),
};
}

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

// config before eject: we're in ./node_modules/react-scripts/config/
module.exports = {
Expand All @@ -81,20 +79,20 @@ module.exports = {
yarnLockFile: resolveApp('yarn.lock'),
testsSetup: resolveApp('src/setupTests.ts'),
appNodeModules: resolveApp('node_modules'),
rootNodeModules: path.resolve(appDirectory, '..', '..', 'node_modules'),
appTsConfig: resolveApp('tsconfig.json'),
appTsTestConfig: resolveApp('tsconfig.test.json'),
publicUrl: getPublicUrl(resolveApp('package.json')),
servedPath: getServedPath(resolveApp('package.json')),
// These properties only exist before ejecting:
ownPath: resolveOwn('.'),
ownNodeModules: resolveOwn('node_modules'), // This is empty on npm 3
};
}

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

// config before publish: we're in ./packages/react-scripts/config/
if (
Expand All @@ -120,6 +118,6 @@ if (
// These properties only exist before ejecting:
ownPath: resolveOwn('.'),
ownNodeModules: resolveOwn('node_modules'),
};
}
}
// @remove-on-eject-end
42 changes: 22 additions & 20 deletions packages/react-scripts/config/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
// @remove-on-eject-end
'use strict';
'use strict'

const autoprefixer = require('autoprefixer');
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
const getClientEnvironment = require('./env');
const paths = require('./paths');
const autoprefixer = require('autoprefixer')
const path = require('path')
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin')
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin')
const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin')
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin')
const getClientEnvironment = require('./env')
const paths = require('./paths')

// Webpack uses `publicPath` to determine where the app is being served from.
// In development, we always serve from the root. This makes config easier.
const publicPath = '/';
const publicPath = '/'
// `publicUrl` is just like `publicPath`, but we will provide it to our app
// as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
// Omit trailing slash as %PUBLIC_PATH%/xyz looks better than %PUBLIC_PATH%xyz.
const publicUrl = '';
const publicUrl = ''
// Get environment variables to inject into our app.
const env = getClientEnvironment(publicUrl);
const env = getClientEnvironment(publicUrl)

// This is the development configuration.
// It is focused on developer experience and fast rebuilds.
Expand Down Expand Up @@ -110,9 +110,7 @@ module.exports = {
// It usually still works on npm 3 without this but it would be
// unfortunate to rely on, as react-scripts could be symlinked,
// and thus babel-runtime might not be resolvable from the source.
'babel-runtime': path.dirname(
require.resolve('babel-runtime/package.json')
),
'babel-runtime': path.dirname(require.resolve('babel-runtime/package.json')),
// @remove-on-eject-end
// Support React Native Web
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
Expand All @@ -126,6 +124,10 @@ module.exports = {
// Make sure your source files are compiled, as they will not be processed in any way.
new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]),
],
symlinks: false,
},
resolveLoader: {
symlinks: false,
},
module: {
strictExportPresence: true,
Expand All @@ -140,7 +142,7 @@ module.exports = {
test: /\.(ts|tsx)$/,
loader: require.resolve('tslint-loader'),
enforce: 'pre',
include: paths.appSrc,
include: [paths.appSrc, paths.rootNodeModules],
},
{
test: /\.js$/,
Expand All @@ -167,7 +169,7 @@ module.exports = {
// Compile .tsx?
{
test: /\.(ts|tsx)$/,
include: paths.appSrc,
include: [paths.appSrc, paths.rootNodeModules],
loader: require.resolve('ts-loader'),
},
// "postcss" loader applies autoprefixer to our CSS.
Expand Down Expand Up @@ -278,4 +280,4 @@ module.exports = {
performance: {
hints: false,
},
};
}
14 changes: 4 additions & 10 deletions packages/react-scripts/package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
{
"name": "react-scripts-ts",
"name": "@functionalfoundry/react-scripts-ts",
"version": "2.8.0",
"description": "Configuration and scripts for Create React App.",
"repository": "wmonk/create-react-app",
"repository": "functionalfoundry/create-react-app-typescript",
"license": "BSD-3-Clause",
"engines": {
"node": ">=6"
},
"bugs": {
"url": "https://github.com/wmonk/create-react-app/issues"
"url": "https://github.com/functionalfoundry/create-react-app-typescript/issues"
},
"files": [
"bin",
"config",
"scripts",
"template",
"utils"
],
"files": ["bin", "config", "scripts", "template", "utils"],
"bin": {
"react-scripts-ts": "./bin/react-scripts-ts.js"
},
Expand Down