1 | ;
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = _default;
|
7 |
|
8 | var _crypto = _interopRequireDefault(require("crypto"));
|
9 |
|
10 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11 |
|
12 | /**
|
13 | * ref:
|
14 | * https://github.com/facebook/create-react-app/blob/master/packages/babel-preset-react-app/webpack-overrides.js
|
15 | */
|
16 | const macroCheck = new RegExp('[./]macro');
|
17 |
|
18 | function _default() {
|
19 | return {
|
20 | // This function transforms the Babel configuration on a per-file basis
|
21 | config(config, {
|
22 | source
|
23 | }) {
|
24 | // Babel Macros are notoriously hard to cache, so they shouldn't be
|
25 | // https://github.com/babel/babel/issues/8497
|
26 | // We naively detect macros using their package suffix and add a random token
|
27 | // to the caller, a valid option accepted by Babel, to compose a one-time
|
28 | // cacheIdentifier for the file. We cannot tune the loader options on a per
|
29 | // file basis.
|
30 | if (macroCheck.test(source)) {
|
31 | return Object.assign({}, config.options, {
|
32 | caller: Object.assign({}, config.options.caller, {
|
33 | craInvalidationToken: _crypto.default.randomBytes(32).toString('hex')
|
34 | })
|
35 | });
|
36 | }
|
37 |
|
38 | return config.options;
|
39 | }
|
40 |
|
41 | };
|
42 | } |
\ | No newline at end of file |