Skip to content

Commit fdc916a

Browse files
authored
Cache identifier follow up (facebook#5055)
* Tweak environment handling * Add documentation for getCacheIdentifier
1 parent 0cfe758 commit fdc916a

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

packages/react-dev-utils/README.md

+12-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
This package includes some utilities used by [Create React App](https://github.com/facebook/create-react-app).<br>
44
Please refer to its documentation:
55

6-
* [Getting Started](https://github.com/facebook/create-react-app/blob/master/README.md#getting-started) – How to create a new app.
7-
* [User Guide](https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md) – How to develop apps bootstrapped with Create React App.
6+
- [Getting Started](https://github.com/facebook/create-react-app/blob/master/README.md#getting-started) – How to create a new app.
7+
- [User Guide](https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md) – How to develop apps bootstrapped with Create React App.
88

99
## Usage in Create React App Projects
1010

@@ -361,3 +361,13 @@ module: {
361361
];
362362
}
363363
```
364+
365+
#### `getCacheIdentifier(environment: string, packages: string[]): string`
366+
367+
Returns a cache identifier (string) consisting of the specified environment and related package versions, e.g.,
368+
369+
```js
370+
var getCacheIdentifier = require('react-dev-utils/getCacheIdentifier');
371+
372+
getCacheIdentifier('prod', ['react-dev-utils', 'chalk']); // # => 'prod:react-dev-utils@5.0.0:chalk@2.4.1'
373+
```

packages/react-dev-utils/getCacheIdentifier.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
'use strict';
99

1010
module.exports = function getCacheIdentifier(environment, packages) {
11-
let cacheIdentifier = `${environment}`;
11+
let cacheIdentifier = environment == null ? '' : environment.toString();
1212
for (const packageName of packages) {
1313
cacheIdentifier += `:${packageName}@`;
1414
try {

0 commit comments

Comments
 (0)