Skip to content
  • Sponsor facebook/create-react-app

  • Notifications You must be signed in to change notification settings
  • Fork 27k
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit be60e23

Browse files
committedJun 22, 2017
Use regex to check relative path to package.json
1 parent 18ee2fc commit be60e23

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed
 

‎packages/react-dev-utils/ModuleScopePlugin.js

+2-9
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,11 @@ class ModuleScopePlugin {
4444
path.dirname(request.context.issuer),
4545
request.__innerRequest_request
4646
);
47-
const requestRelativeToRoot = path.relative(
48-
request.descriptionFileRoot,
49-
requestFullPath
50-
);
51-
if (
52-
requestRelativeToRoot === 'package.json' ||
53-
requestRelativeToRoot === 'package'
54-
) {
47+
const requestRelative = path.relative(appSrc, requestFullPath);
48+
if (/^(..[/|\\])+package(.json)?$/.test(requestRelative)) {
5549
return callback();
5650
}
5751
// Find path from src to the requested file
58-
const requestRelative = path.relative(appSrc, requestFullPath);
5952
// Error if in a parent directory of src/
6053
if (
6154
requestRelative.startsWith('../') || requestRelative.startsWith('..\\')

‎packages/react-scripts/template/src/App.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { Component } from 'react';
22
import logo from './logo.svg';
33
import './App.css';
4-
import { version, name } from '../../package.json';
54

65
class App extends Component {
76
render() {
@@ -10,7 +9,6 @@ class App extends Component {
109
<div className="App-header">
1110
<img src={logo} className="App-logo" alt="logo" />
1211
<h2>Welcome to React</h2>
13-
<p>{`${name} v${version}`}</p>
1412
</div>
1513
<p className="App-intro">
1614
To get started, edit <code>src/App.js</code> and save to reload.

0 commit comments

Comments
 (0)
Please sign in to comment.