Skip to content

Commit 5172040

Browse files
committed
feat: remove typescript flag and NODE_PATH support
1 parent 2473a73 commit 5172040

File tree

7 files changed

+8
-89
lines changed

7 files changed

+8
-89
lines changed

docusaurus/docs/advanced-configuration.md

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ You can adjust various development and production settings by setting environmen
2222
| REACT_EDITOR | ✅ Used | 🚫 Ignored | When an app crashes in development, you will see an error overlay with clickable stack trace. When you click on it, Create React App will try to determine the editor you are using based on currently running processes, and open the relevant source file. You can [send a pull request to detect your editor of choice](https://github.com/facebook/create-react-app/issues/2636). Setting this environment variable overrides the automatic detection. If you do it, make sure your systems [PATH](<https://en.wikipedia.org/wiki/PATH_(variable)>) environment variable points to your editor’s bin folder. You can also set it to `none` to disable it completely. |
2323
| CHOKIDAR_USEPOLLING | ✅ Used | 🚫 Ignored | When set to `true`, the watcher runs in polling mode, as necessary inside a VM. Use this option if `npm start` isn't detecting changes. |
2424
| GENERATE_SOURCEMAP | 🚫 Ignored | ✅ Used | When set to `false`, source maps are not generated for a production build. This solves out of memory (OOM) issues on some smaller machines. |
25-
| NODE_PATH | ✅ Used | ✅ Used | Same as [`NODE_PATH` in Node.js](https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders), but only relative folders are allowed. Can be handy for emulating a monorepo setup by setting `NODE_PATH=src`. |
2625
| INLINE_RUNTIME_CHUNK | 🚫 Ignored | ✅ Used | By default, Create React App will embed the runtime script into `index.html` during the production build. When set to `false`, the script will not be embedded and will be imported as usual. This is normally required when dealing with CSP. |
2726
| IMAGE_INLINE_SIZE_LIMIT | 🚫 Ignored | ✅ Used | By default, images smaller than 10,000 bytes are encoded as a data URI in base64 and inlined in the CSS or JS build artifact. Set this to control the size limit in bytes. Setting it to 0 will disable the inlining of images. |
2827
| EXTEND_ESLINT | ✅ Used | ✅ Used | When set to `true`, user provided ESLint configs will be used by `eslint-loader`. Note that any rules set to `"error"` will stop the application from building. |

packages/create-react-app/createReactApp.js

+3-45
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,6 @@ const program = new commander.Command(packageJson.name)
7474
)
7575
.option('--use-npm')
7676
.option('--use-pnp')
77-
// TODO: Remove this in next major release.
78-
.option(
79-
'--typescript',
80-
'(this option will be removed in favour of templates in the next major release of create-react-app)'
81-
)
8277
.allowUnknownOption()
8378
.on('--help', () => {
8479
console.log(` Only ${chalk.green('<project-directory>')} is required.`);
@@ -114,7 +109,7 @@ const program = new commander.Command(packageJson.name)
114109
console.log();
115110
console.log(` A custom ${chalk.cyan('--template')} can be one of:`);
116111
console.log(
117-
` - a custom fork published on npm: ${chalk.green(
112+
` - a custom template published on npm: ${chalk.green(
118113
'cra-template-typescript'
119114
)}`
120115
);
@@ -190,19 +185,10 @@ createApp(
190185
program.scriptsVersion,
191186
program.template,
192187
program.useNpm,
193-
program.usePnp,
194-
program.typescript
188+
program.usePnp
195189
);
196190

197-
function createApp(
198-
name,
199-
verbose,
200-
version,
201-
template,
202-
useNpm,
203-
usePnp,
204-
useTypeScript
205-
) {
191+
function createApp(name, verbose, version, template, useNpm, usePnp) {
206192
const unsupportedNodeVersion = !semver.satisfies(process.version, '>=10');
207193
if (unsupportedNodeVersion) {
208194
console.log(
@@ -275,23 +261,6 @@ function createApp(
275261
}
276262
}
277263

278-
if (useTypeScript) {
279-
console.log(
280-
chalk.yellow(
281-
'The --typescript option has been deprecated and will be removed in a future release.'
282-
)
283-
);
284-
console.log(
285-
chalk.yellow(
286-
`In future, please use ${chalk.cyan('--template typescript')}.`
287-
)
288-
);
289-
console.log();
290-
if (!template) {
291-
template = 'typescript';
292-
}
293-
}
294-
295264
if (useYarn) {
296265
let yarnUsesDefaultRegistry = true;
297266
try {
@@ -449,17 +418,6 @@ function run(
449418
console.log('');
450419
}
451420

452-
// TODO: Remove with next major release.
453-
if (!supportsTemplates && (template || '').includes('typescript')) {
454-
allDependencies.push(
455-
'@types/node',
456-
'@types/react',
457-
'@types/react-dom',
458-
'@types/jest',
459-
'typescript'
460-
);
461-
}
462-
463421
console.log(
464422
`Installing ${chalk.cyan('react')}, ${chalk.cyan(
465423
'react-dom'

packages/react-scripts/config/modules.js

+2-9
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,8 @@ const resolve = require('resolve');
2222
function getAdditionalModulePaths(options = {}) {
2323
const baseUrl = options.baseUrl;
2424

25-
// We need to explicitly check for null and undefined (and not a falsy value) because
26-
// TypeScript treats an empty string as `.`.
27-
if (baseUrl == null) {
28-
// If there's no baseUrl set we respect NODE_PATH
29-
// Note that NODE_PATH is deprecated and will be removed
30-
// in the next major release of create-react-app.
31-
32-
const nodePath = process.env.NODE_PATH || '';
33-
return nodePath.split(path.delimiter).filter(Boolean);
25+
if (!baseUrl) {
26+
return '';
3427
}
3528

3629
const baseUrlResolved = path.resolve(paths.appPath, baseUrl);

packages/react-scripts/scripts/build.js

-12
Original file line numberDiff line numberDiff line change
@@ -146,18 +146,6 @@ checkBrowsers(paths.appPath, isInteractive)
146146

147147
// Create the production build and print the deployment instructions.
148148
function build(previousFileSizes) {
149-
// We used to support resolving modules according to `NODE_PATH`.
150-
// This now has been deprecated in favor of jsconfig/tsconfig.json
151-
// This lets you use absolute paths in imports inside large monorepos:
152-
if (process.env.NODE_PATH) {
153-
console.log(
154-
chalk.yellow(
155-
'Setting NODE_PATH to resolve modules absolutely has been deprecated in favor of setting baseUrl in jsconfig.json (or tsconfig.json if you are using TypeScript) and will be removed in a future major release of create-react-app.'
156-
)
157-
);
158-
console.log();
159-
}
160-
161149
console.log('Creating an optimized production build...');
162150

163151
const compiler = webpack(config);

packages/react-scripts/scripts/init.js

+2-8
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,7 @@ module.exports = function(
110110
require.resolve(`${templateName}/package.json`, { paths: [appPath] })
111111
);
112112

113-
let templateJsonPath;
114-
if (templateName) {
115-
templateJsonPath = path.join(templatePath, 'template.json');
116-
} else {
117-
// TODO: Remove support for this in v4.
118-
templateJsonPath = path.join(appPath, '.template.dependencies.json');
119-
}
113+
const templateJsonPath = path.join(templatePath, 'template.json');
120114

121115
let templateJson = {};
122116
if (fs.existsSync(templateJsonPath)) {
@@ -125,7 +119,7 @@ module.exports = function(
125119

126120
const templatePackage = templateJson.package || {};
127121

128-
// TODO: Deprecate support for root-level `dependencies` and `scripts` in v4.
122+
// TODO: Deprecate support for root-level `dependencies` and `scripts` in v5.
129123
// These should now be set under the `package` key.
130124
if (templateJson.dependencies || templateJson.scripts) {
131125
console.log();

packages/react-scripts/scripts/start.js

-12
Original file line numberDiff line numberDiff line change
@@ -142,18 +142,6 @@ checkBrowsers(paths.appPath, isInteractive)
142142
clearConsole();
143143
}
144144

145-
// We used to support resolving modules according to `NODE_PATH`.
146-
// This now has been deprecated in favor of jsconfig/tsconfig.json
147-
// This lets you use absolute paths in imports inside large monorepos:
148-
if (process.env.NODE_PATH) {
149-
console.log(
150-
chalk.yellow(
151-
'Setting NODE_PATH to resolve modules absolutely has been deprecated in favor of setting baseUrl in jsconfig.json (or tsconfig.json if you are using TypeScript) and will be removed in a future major release of create-react-app.'
152-
)
153-
);
154-
console.log();
155-
}
156-
157145
console.log(chalk.cyan('Starting the development server...\n'));
158146
openBrowser(urls.localUrlForBrowser);
159147
});

packages/react-scripts/scripts/utils/verifyTypeScriptSetup.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ function verifyTypeScriptSetup() {
106106
allowSyntheticDefaultImports: { suggested: true },
107107
strict: { suggested: true },
108108
forceConsistentCasingInFileNames: { suggested: true },
109-
// TODO: Enable for v4.0 (#6936)
110-
// noFallthroughCasesInSwitch: { suggested: true },
109+
noFallthroughCasesInSwitch: { suggested: true },
111110

112111
// These values are required and cannot be changed by the user
113112
// Keep this in sync with the webpack config

0 commit comments

Comments
 (0)