diff --git a/packages/react-dev-utils/ModuleScopePlugin.js b/packages/react-dev-utils/ModuleScopePlugin.js index 24263e21e77..bec33107909 100644 --- a/packages/react-dev-utils/ModuleScopePlugin.js +++ b/packages/react-dev-utils/ModuleScopePlugin.js @@ -44,18 +44,11 @@ class ModuleScopePlugin { path.dirname(request.context.issuer), request.__innerRequest_request ); - const requestRelativeToRoot = path.relative( - request.descriptionFileRoot, - requestFullPath - ); - if ( - requestRelativeToRoot === 'package.json' || - requestRelativeToRoot === 'package' - ) { + const requestRelative = path.relative(appSrc, requestFullPath); + if (/^(..[/|\\])+package(.json)?$/.test(requestRelative)) { return callback(); } // Find path from src to the requested file - const requestRelative = path.relative(appSrc, requestFullPath); // Error if in a parent directory of src/ if ( requestRelative.startsWith('../') || requestRelative.startsWith('..\\') diff --git a/packages/react-scripts/template/src/App.js b/packages/react-scripts/template/src/App.js index 9dc2e237928..d7d52a7f38a 100644 --- a/packages/react-scripts/template/src/App.js +++ b/packages/react-scripts/template/src/App.js @@ -1,7 +1,6 @@ import React, { Component } from 'react'; import logo from './logo.svg'; import './App.css'; -import { version, name } from '../../package.json'; class App extends Component { render() { @@ -10,7 +9,6 @@ class App extends Component {
logo

Welcome to React

-

{`${name} v${version}`}

To get started, edit src/App.js and save to reload.