forked from facebook/react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
77 lines (66 loc) · 1.65 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/**
* Copyright 2013-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
'use strict';
var gulp = require('gulp');
var babel = require('gulp-babel');
var flatten = require('gulp-flatten');
var del = require('del');
var babelPluginModules = require('fbjs-scripts/babel-6/rewrite-modules');
var paths = {
react: {
src: [
'src/**/*.js',
'!src/**/__benchmarks__/**/*.js',
'!src/**/__tests__/**/*.js',
'!src/**/__mocks__/**/*.js',
'!src/shared/vendor/**/*.js',
],
lib: 'build/modules',
},
};
var fbjsModuleMap = require('fbjs/module-map');
var moduleMap = {};
for (var key in fbjsModuleMap) {
moduleMap[key] = fbjsModuleMap[key];
}
var whiteListNames = [
'deepDiffer',
'deepFreezeAndThrowOnMutationInDev',
'flattenStyle',
'InitializeJavaScriptAppEngine',
'InteractionManager',
'JSTimersExecution',
'merge',
'Platform',
'RCTEventEmitter',
'RCTLog',
'TextInputState',
'UIManager',
'View',
];
whiteListNames.forEach(function(name) {
moduleMap[name] = name;
});
moduleMap['object-assign'] = 'object-assign';
var babelOpts = {
plugins: [
[babelPluginModules, { map: moduleMap }],
],
};
gulp.task('react:clean', function() {
return del([paths.react.lib]);
});
gulp.task('react:modules', function() {
return gulp
.src(paths.react.src)
.pipe(babel(babelOpts))
.pipe(flatten())
.pipe(gulp.dest(paths.react.lib));
});
gulp.task('default', ['react:modules']);