2018-10-01 23:35:30 +00:00
|
|
|
/**
|
|
|
|
* This source code was adapted from:
|
2018-10-04 18:17:18 +00:00
|
|
|
* https://github.com/facebook/create-react-app/blob/v2.0.4/packages/babel-preset-react-app/webpack-overrides.js
|
2018-10-01 23:35:30 +00:00
|
|
|
*
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
*
|
|
|
|
* The MIT license for this code may be found on GitHub:
|
2018-10-04 18:17:18 +00:00
|
|
|
* https://github.com/facebook/create-react-app/blob/v2.0.4/packages/babel-preset-react-app/LICENSE
|
2018-10-01 23:35:30 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
const crypto = require('crypto');
|
|
|
|
const macroCheck = new RegExp('[./]macro');
|
|
|
|
|
|
|
|
module.exports = function () {
|
|
|
|
return {
|
|
|
|
config(config, {source}) {
|
|
|
|
// don't cache babel macros
|
|
|
|
// https://github.com/babel/babel/issues/8497
|
|
|
|
if (macroCheck.test(source)) {
|
|
|
|
return Object.assign({}, config.options, {
|
|
|
|
caller: Object.assign({}, config.options.caller, {
|
|
|
|
macroInvalidationToken: crypto.randomBytes(32).toString('hex')
|
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return config.options;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|