Unverified Commit fdc916a5 authored by Joe Haddad's avatar Joe Haddad Committed by GitHub
Browse files

Cache identifier follow up (#5055)

* Tweak environment handling

* Add documentation for getCacheIdentifier
parent 0cfe758f
Showing with 13 additions and 3 deletions
+13 -3
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
This package includes some utilities used by [Create React App](https://github.com/facebook/create-react-app).<br> This package includes some utilities used by [Create React App](https://github.com/facebook/create-react-app).<br>
Please refer to its documentation: Please refer to its documentation:
* [Getting Started](https://github.com/facebook/create-react-app/blob/master/README.md#getting-started) – How to create a new app. - [Getting Started](https://github.com/facebook/create-react-app/blob/master/README.md#getting-started) – How to create a new app.
* [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. - [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.
## Usage in Create React App Projects ## Usage in Create React App Projects
...@@ -361,3 +361,13 @@ module: { ...@@ -361,3 +361,13 @@ module: {
]; ];
} }
``` ```
#### `getCacheIdentifier(environment: string, packages: string[]): string`
Returns a cache identifier (string) consisting of the specified environment and related package versions, e.g.,
```js
var getCacheIdentifier = require('react-dev-utils/getCacheIdentifier');
getCacheIdentifier('prod', ['react-dev-utils', 'chalk']); // # => 'prod:react-dev-utils@5.0.0:chalk@2.4.1'
```
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
'use strict'; 'use strict';
module.exports = function getCacheIdentifier(environment, packages) { module.exports = function getCacheIdentifier(environment, packages) {
let cacheIdentifier = `${environment}`; let cacheIdentifier = environment == null ? '' : environment.toString();
for (const packageName of packages) { for (const packageName of packages) {
cacheIdentifier += `:${packageName}@`; cacheIdentifier += `:${packageName}@`;
try { try {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment