File tree Expand file tree Collapse file tree
test/watchCases/cache/inline-exports-value-change Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ export const FLAG = process . env . FLAG ;
2+ export const NUM = 5 ;
Original file line number Diff line number Diff line change 1+ import { FLAG , NUM } from "./env" ;
2+ import { REEXPORTED_NUM } from "./reexport" ;
3+ import "./trigger" ;
4+
5+ const fs = __non_webpack_require__ ( "fs" ) ;
6+ const path = __non_webpack_require__ ( "path" ) ;
7+
8+ it ( "should refresh the inlined constants a cached build baked into consumers" , ( ) => {
9+ const source = fs . readFileSync (
10+ path . join ( STATS_JSON . outputPath , "bundle.js" ) ,
11+ "utf8"
12+ ) ;
13+ const expectedFlag = WATCH_STEP === "0" ? "on" : "off" ;
14+ const expectedNum = WATCH_STEP === "2" ? 6 : 5 ;
15+ expect ( FLAG ) . toBe ( expectedFlag ) ;
16+ expect ( NUM ) . toBe ( expectedNum ) ;
17+ expect ( REEXPORTED_NUM ) . toBe ( expectedNum ) ;
18+ expect ( source ) . toContain (
19+ `(/* inlined export .FLAG */${ JSON . stringify ( expectedFlag ) } )`
20+ ) ;
21+ expect ( source ) . toContain ( `(/* inlined export .NUM */${ expectedNum } )` ) ;
22+ } ) ;
Original file line number Diff line number Diff line change 1+ export { NUM as REEXPORTED_NUM } from "./env" ;
Original file line number Diff line number Diff line change 1+ // Changed at every step so the watcher rebuilds while the consumer stays as it was
2+ module . exports = 0 ;
Original file line number Diff line number Diff line change 1+ // Changed at every step so the watcher rebuilds while the consumer stays as it was
2+ module . exports = 1 ;
Original file line number Diff line number Diff line change 1+ export const FLAG = process . env . FLAG ;
2+ export const NUM = 6 ;
Original file line number Diff line number Diff line change 1+ // Changed at every step so the watcher rebuilds while the consumer stays as it was
2+ module . exports = 2 ;
Original file line number Diff line number Diff line change 1+ "use strict" ;
2+
3+ const { DefinePlugin } = require ( "../../../../" ) ;
4+ const currentWatchStep = require ( "../../../helpers/currentWatchStep" ) ;
5+
6+ /** @type {import("../../../../").Configuration } */
7+ module . exports = {
8+ mode : "production" ,
9+ cache : {
10+ type : "filesystem"
11+ } ,
12+ optimization : {
13+ minimize : false ,
14+ inlineExports : true
15+ } ,
16+ plugins : [
17+ new DefinePlugin ( {
18+ "process.env.FLAG" : DefinePlugin . runtimeValue (
19+ ( ) =>
20+ JSON . stringify (
21+ Number ( currentWatchStep . step || 0 ) === 0 ? "on" : "off"
22+ ) ,
23+ { version : ( ) => String ( currentWatchStep . step || 0 ) }
24+ )
25+ } )
26+ ]
27+ } ;
You can’t perform that action at this time.
0 commit comments