-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Switch back to babel-loader * Preserve existing caller options. Use Object.assign instead of object spread. * Updated filename in package.json * Update comment about cache identifier * Update macro check to use a regex * Move macro check regex out of function
- Loading branch information
Showing
8 changed files
with
45 additions
and
54 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* Copyright (c) 2015-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
'use strict'; | ||
|
||
const crypto = require('crypto'); | ||
|
||
const macroCheck = new RegExp('[./]macro'); | ||
|
||
module.exports = function() { | ||
return { | ||
// This function transforms the Babel configuration on a per-file basis | ||
config(config, { source }) { | ||
// Babel Macros are notoriously hard to cache, so they shouldn't be | ||
// https://github.com/babel/babel/issues/8497 | ||
// We naively detect macros using their package suffix and add a random token | ||
// to the caller, a valid option accepted by Babel, to compose a one-time | ||
// cacheIdentifier for the file. We cannot tune the loader options on a per | ||
// file basis. | ||
if (macroCheck.test(source)) { | ||
return Object.assign({}, config.options, { | ||
caller: Object.assign({}, config.options.caller, { | ||
craInvalidationToken: crypto.randomBytes(32).toString('hex'), | ||
}), | ||
}); | ||
} | ||
return config.options; | ||
}, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39c73ce
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Timer @iansu this is causing an error after ejecting:
Cannot find module 'babel-preset-react-app/webpack-overrides'
39c73ce
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I think I know what the issue is. I'll fix it tomorrow.
39c73ce
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why didn't our E2E catch it?
39c73ce
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good question. I don't know why. I've submitted a fix (and tested it manually) here: #5160
39c73ce
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brunolemos I'm unable to reproduce this error. If you encounter this again please file a new issue and we'll investigate.