File tree Expand file tree Collapse file tree
packages/react-native-babel-preset/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /**
2+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3+ *
4+ * This source code is licensed under the MIT license found in the
5+ * LICENSE file in the root directory of this source tree.
6+ *
7+ * @format
8+ * @noflow
9+ */
10+
11+ 'use strict' ;
12+
13+ function getCacheKey ( packageContents ) {
14+ jest . resetModules ( ) ;
15+ jest . doMock ( 'node:fs' , ( ) => ( {
16+ readFileSync : filename =>
17+ filename . endsWith ( 'package.json' )
18+ ? Buffer . from ( packageContents )
19+ : Buffer . from ( filename ) ,
20+ } ) ) ;
21+
22+ return require ( '../index' ) . getCacheKey ( ) ;
23+ }
24+
25+ test ( 'cache key includes package metadata for main builds' , ( ) => {
26+ expect ( getCacheKey ( '{"dependency":"1.0.0"}' ) ) . not . toBe (
27+ getCacheKey ( '{"dependency":"2.0.0"}' ) ,
28+ ) ;
29+ } ) ;
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ module.exports.getCacheKey = () => {
3535 const { readFileSync} = require ( 'node:fs' ) ;
3636 const key = createHash ( 'md5' ) ;
3737 [
38+ readFileSync ( require . resolve ( '../package.json' ) ) ,
3839 readFileSync ( __filename ) ,
3940 readFileSync ( require . resolve ( './configs/main.js' ) ) ,
4041 readFileSync ( require . resolve ( './configs/hmr.js' ) ) ,
You can’t perform that action at this time.
0 commit comments