|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 1 | /**
|
|---|
| 2 | * Copyright (c) 2015-present, Facebook, Inc.
|
|---|
| 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 | 'use strict';
|
|---|
| 8 |
|
|---|
| 9 | const crypto = require('crypto');
|
|---|
| 10 |
|
|---|
| 11 | const macroCheck = new RegExp('[./]macro');
|
|---|
| 12 |
|
|---|
| 13 | module.exports = function () {
|
|---|
| 14 | return {
|
|---|
| 15 | // This function transforms the Babel configuration on a per-file basis
|
|---|
| 16 | config(config, { source }) {
|
|---|
| 17 | // Babel Macros are notoriously hard to cache, so they shouldn't be
|
|---|
| 18 | // https://github.com/babel/babel/issues/8497
|
|---|
| 19 | // We naively detect macros using their package suffix and add a random token
|
|---|
| 20 | // to the caller, a valid option accepted by Babel, to compose a one-time
|
|---|
| 21 | // cacheIdentifier for the file. We cannot tune the loader options on a per
|
|---|
| 22 | // file basis.
|
|---|
| 23 | if (macroCheck.test(source)) {
|
|---|
| 24 | return Object.assign({}, config.options, {
|
|---|
| 25 | caller: Object.assign({}, config.options.caller, {
|
|---|
| 26 | craInvalidationToken: crypto.randomBytes(32).toString('hex'),
|
|---|
| 27 | }),
|
|---|
| 28 | });
|
|---|
| 29 | }
|
|---|
| 30 | return config.options;
|
|---|
| 31 | },
|
|---|
| 32 | };
|
|---|
| 33 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.