diff --git a/docusaurus/docs/advanced-configuration.md b/docusaurus/docs/advanced-configuration.md index fb71df0e231..958f9ac3168 100644 --- a/docusaurus/docs/advanced-configuration.md +++ b/docusaurus/docs/advanced-configuration.md @@ -22,7 +22,6 @@ You can adjust various development and production settings by setting environmen | 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]() environment variable points to your editor’s bin folder. You can also set it to `none` to disable it completely. | | 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. | | 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. | -| 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`. | | 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. | | 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. | | 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. | diff --git a/packages/create-react-app/createReactApp.js b/packages/create-react-app/createReactApp.js index cdb5105a78f..dc97cf2fda5 100755 --- a/packages/create-react-app/createReactApp.js +++ b/packages/create-react-app/createReactApp.js @@ -74,11 +74,6 @@ const program = new commander.Command(packageJson.name) ) .option('--use-npm') .option('--use-pnp') - // TODO: Remove this in next major release. - .option( - '--typescript', - '(this option will be removed in favour of templates in the next major release of create-react-app)' - ) .allowUnknownOption() .on('--help', () => { console.log(` Only ${chalk.green('')} is required.`); @@ -114,7 +109,7 @@ const program = new commander.Command(packageJson.name) console.log(); console.log(` A custom ${chalk.cyan('--template')} can be one of:`); console.log( - ` - a custom fork published on npm: ${chalk.green( + ` - a custom template published on npm: ${chalk.green( 'cra-template-typescript' )}` ); @@ -190,19 +185,10 @@ createApp( program.scriptsVersion, program.template, program.useNpm, - program.usePnp, - program.typescript + program.usePnp ); -function createApp( - name, - verbose, - version, - template, - useNpm, - usePnp, - useTypeScript -) { +function createApp(name, verbose, version, template, useNpm, usePnp) { const unsupportedNodeVersion = !semver.satisfies(process.version, '>=10'); if (unsupportedNodeVersion) { console.log( @@ -284,23 +270,6 @@ function createApp( } } - if (useTypeScript) { - console.log( - chalk.yellow( - 'The --typescript option has been deprecated and will be removed in a future release.' - ) - ); - console.log( - chalk.yellow( - `In future, please use ${chalk.cyan('--template typescript')}.` - ) - ); - console.log(); - if (!template) { - template = 'typescript'; - } - } - if (useYarn) { let yarnUsesDefaultRegistry = true; try { @@ -457,17 +426,6 @@ function run( console.log(''); } - // TODO: Remove with next major release. - if (!supportsTemplates && (template || '').includes('typescript')) { - allDependencies.push( - '@types/node', - '@types/react', - '@types/react-dom', - '@types/jest', - 'typescript' - ); - } - console.log( `Installing ${chalk.cyan('react')}, ${chalk.cyan( 'react-dom' diff --git a/packages/react-scripts/config/modules.js b/packages/react-scripts/config/modules.js index 38c95b91e44..22820993a25 100644 --- a/packages/react-scripts/config/modules.js +++ b/packages/react-scripts/config/modules.js @@ -22,15 +22,8 @@ const resolve = require('resolve'); function getAdditionalModulePaths(options = {}) { const baseUrl = options.baseUrl; - // We need to explicitly check for null and undefined (and not a falsy value) because - // TypeScript treats an empty string as `.`. - if (baseUrl == null) { - // If there's no baseUrl set we respect NODE_PATH - // Note that NODE_PATH is deprecated and will be removed - // in the next major release of create-react-app. - - const nodePath = process.env.NODE_PATH || ''; - return nodePath.split(path.delimiter).filter(Boolean); + if (!baseUrl) { + return ''; } const baseUrlResolved = path.resolve(paths.appPath, baseUrl); diff --git a/packages/react-scripts/scripts/build.js b/packages/react-scripts/scripts/build.js index b51df86101b..de2ff505eb3 100644 --- a/packages/react-scripts/scripts/build.js +++ b/packages/react-scripts/scripts/build.js @@ -150,18 +150,6 @@ checkBrowsers(paths.appPath, isInteractive) // Create the production build and print the deployment instructions. function build(previousFileSizes) { - // We used to support resolving modules according to `NODE_PATH`. - // This now has been deprecated in favor of jsconfig/tsconfig.json - // This lets you use absolute paths in imports inside large monorepos: - if (process.env.NODE_PATH) { - console.log( - chalk.yellow( - '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.' - ) - ); - console.log(); - } - console.log('Creating an optimized production build...'); const compiler = webpack(config); diff --git a/packages/react-scripts/scripts/init.js b/packages/react-scripts/scripts/init.js index d064e5db195..8e1bb3fca80 100644 --- a/packages/react-scripts/scripts/init.js +++ b/packages/react-scripts/scripts/init.js @@ -110,13 +110,7 @@ module.exports = function ( require.resolve(`${templateName}/package.json`, { paths: [appPath] }) ); - let templateJsonPath; - if (templateName) { - templateJsonPath = path.join(templatePath, 'template.json'); - } else { - // TODO: Remove support for this in v4. - templateJsonPath = path.join(appPath, '.template.dependencies.json'); - } + const templateJsonPath = path.join(templatePath, 'template.json'); let templateJson = {}; if (fs.existsSync(templateJsonPath)) { @@ -125,7 +119,7 @@ module.exports = function ( const templatePackage = templateJson.package || {}; - // TODO: Deprecate support for root-level `dependencies` and `scripts` in v4. + // TODO: Deprecate support for root-level `dependencies` and `scripts` in v5. // These should now be set under the `package` key. if (templateJson.dependencies || templateJson.scripts) { console.log(); diff --git a/packages/react-scripts/scripts/start.js b/packages/react-scripts/scripts/start.js index 3f77a58f98f..daa98423f1a 100644 --- a/packages/react-scripts/scripts/start.js +++ b/packages/react-scripts/scripts/start.js @@ -142,18 +142,6 @@ checkBrowsers(paths.appPath, isInteractive) clearConsole(); } - // We used to support resolving modules according to `NODE_PATH`. - // This now has been deprecated in favor of jsconfig/tsconfig.json - // This lets you use absolute paths in imports inside large monorepos: - if (process.env.NODE_PATH) { - console.log( - chalk.yellow( - '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.' - ) - ); - console.log(); - } - console.log(chalk.cyan('Starting the development server...\n')); openBrowser(urls.localUrlForBrowser); }); diff --git a/packages/react-scripts/scripts/utils/verifyTypeScriptSetup.js b/packages/react-scripts/scripts/utils/verifyTypeScriptSetup.js index ebd93d7b667..09c3e1c01b0 100644 --- a/packages/react-scripts/scripts/utils/verifyTypeScriptSetup.js +++ b/packages/react-scripts/scripts/utils/verifyTypeScriptSetup.js @@ -106,8 +106,7 @@ function verifyTypeScriptSetup() { allowSyntheticDefaultImports: { suggested: true }, strict: { suggested: true }, forceConsistentCasingInFileNames: { suggested: true }, - // TODO: Enable for v4.0 (#6936) - // noFallthroughCasesInSwitch: { suggested: true }, + noFallthroughCasesInSwitch: { suggested: true }, // These values are required and cannot be changed by the user // Keep this in sync with the webpack config diff --git a/tasks/e2e-installs.sh b/tasks/e2e-installs.sh index 79988df9e29..fa5207cebdd 100755 --- a/tasks/e2e-installs.sh +++ b/tasks/e2e-installs.sh @@ -147,11 +147,11 @@ grep '"version": "1.0.17"' node_modules/react-scripts/package.json checkDependencies # ****************************************************************************** -# Test --typescript flag +# Test typescript setup # ****************************************************************************** cd "$temp_app_path" -npx create-react-app test-app-typescript --typescript +npx create-react-app test-app-typescript --template typescript cd test-app-typescript # Check corresponding template is installed. diff --git a/test/fixtures/node_path/.disable-pnp b/test/fixtures/jsconfig/.disable-pnp similarity index 100% rename from test/fixtures/node_path/.disable-pnp rename to test/fixtures/jsconfig/.disable-pnp diff --git a/test/fixtures/node_path/index.test.js b/test/fixtures/jsconfig/index.test.js similarity index 100% rename from test/fixtures/node_path/index.test.js rename to test/fixtures/jsconfig/index.test.js diff --git a/test/fixtures/jsconfig/jsconfig.json b/test/fixtures/jsconfig/jsconfig.json new file mode 100644 index 00000000000..ec2332eb49c --- /dev/null +++ b/test/fixtures/jsconfig/jsconfig.json @@ -0,0 +1,5 @@ +{ + "compilerOptions": { + "baseUrl": "src" + } +} diff --git a/test/fixtures/node_path/package.json b/test/fixtures/jsconfig/package.json similarity index 100% rename from test/fixtures/node_path/package.json rename to test/fixtures/jsconfig/package.json diff --git a/test/fixtures/node_path/src/App.js b/test/fixtures/jsconfig/src/App.js similarity index 100% rename from test/fixtures/node_path/src/App.js rename to test/fixtures/jsconfig/src/App.js diff --git a/test/fixtures/node_path/src/App.test.js b/test/fixtures/jsconfig/src/App.test.js similarity index 88% rename from test/fixtures/node_path/src/App.test.js rename to test/fixtures/jsconfig/src/App.test.js index bacc39efcfe..f70db9efc01 100644 --- a/test/fixtures/node_path/src/App.test.js +++ b/test/fixtures/jsconfig/src/App.test.js @@ -9,7 +9,7 @@ import React from 'react'; import ReactDOM from 'react-dom'; import App from './App'; -test('loads modules absolutely with NODE_PATH', () => { +test('loads modules absolutely with baseUrl', () => { const div = document.createElement('div'); return new Promise(resolve => { ReactDOM.render(, div); diff --git a/test/fixtures/node_path/src/absoluteLoad.js b/test/fixtures/jsconfig/src/absoluteLoad.js similarity index 100% rename from test/fixtures/node_path/src/absoluteLoad.js rename to test/fixtures/jsconfig/src/absoluteLoad.js diff --git a/test/fixtures/node_path/src/index.js b/test/fixtures/jsconfig/src/index.js similarity index 100% rename from test/fixtures/node_path/src/index.js rename to test/fixtures/jsconfig/src/index.js diff --git a/test/fixtures/node_path/.env b/test/fixtures/node_path/.env deleted file mode 100644 index f5fe60280fd..00000000000 --- a/test/fixtures/node_path/.env +++ /dev/null @@ -1 +0,0 @@ -NODE_PATH=src