UNPKG

920 BJavaScriptView Raw
1/**
2 * Copyright (c) 2013-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
8'use strict';
9
10const babel = require('@babel/core');
11const createCacheKeyFunction = require('./createCacheKeyFunction');
12const path = require('path');
13
14module.exports = {
15 process(src, filename) {
16 const options = {
17 presets: [
18 require('babel-preset-fbjs'),
19 ],
20 filename: filename,
21 retainLines: true,
22 };
23 return babel.transform(src, options).code;
24 },
25
26 // Generate a cache key that is based on the contents of this file and the
27 // fbjs preset package.json (used as a proxy for determining if the preset has
28 // changed configuration at all).
29 getCacheKey: createCacheKeyFunction([
30 __filename,
31 path.join(path.dirname(require.resolve('babel-preset-fbjs')), 'package.json')
32 ]),
33};