How to use the buildExternalHelpers function from babel-core

Find comprehensive JavaScript babel-core.buildExternalHelpers code examples handpicked from public code repositorys.

208
209
210
211
212
213
214
215
216
217
  });
}


function buildCdnAngular(dirname) {
  var s = babelCore.buildExternalHelpers(angularBabelHelpers, 'global');

  return makeTask('build-cdn-angular: ' + dirname, function() {
    return gulp.src('./build-targets/cdn-angular.js')
      .pipe(plugins.browserify({
fork icon446
star icon0
watch icon2

+ 3 other calls in file

62
63
64
65
66
67
68
69
70
71
    return new RawModule(buildBabelHelpers(whitelist), getModuleIdentifier(dependency));
}

function buildBabelHelpers(whitelist) {
    if (whitelist.length) {
        return babelCore.buildExternalHelpers(whitelist);
    }

    return babelCore.buildExternalHelpers();
}
fork icon2
star icon3
watch icon1

+ 3 other calls in file

5
6
7
8
9
10
11
12
13
14
var babelPluginGlobals = require('babel-plugin-globals');
var Concat = require('concat-with-sourcemaps');

function addUsedHelpers(concat, results) {
  var usedHelpers = getUsedExternalHelpers(results);
  concat.add(null, babel.buildExternalHelpers(usedHelpers, 'var'));
}

function compileToGlobals(files, options) {
  options = normalizeOptions(options);
fork icon1
star icon4
watch icon3

54
55
56
57
58
59
60
61
62
63

  contents[destFullPath] = out.code;
  sourcemaps[destFullPath] = out.map;
});

var babelHelpers = babel.buildExternalHelpers(usedHelpers, 'var') + '\nexport default babelHelpers;';
var babelHelpersFile  = path.join(transpiledDir, 'babel-helpers.js');
fs.writeFileSync(babelHelpersFile, babelHelpers);

var entryFile  = path.join(transpiledDir, 'index.js');
fork icon1
star icon2
watch icon2

6
7
8
9
10
11
12
13
14
15

var globalsPluginObj = {transformer: babelPluginGlobals, position: 'after'};

function addUsedHelpers(concat, results) {
  var usedHelpers = getUsedExternalHelpers(results);
  concat.add('helpers.js', babel.buildExternalHelpers(usedHelpers));
}

function compileToGlobals(files, options) {
  dependencies = {};
fork icon1
star icon0
watch icon2

76
77
78
79
80
81
82
83
84
85
 */

function buildExternalHelpers(list, type) {
        var ex;
        try {
                return babel.buildExternalHelpers(list, type); 
        } catch (ex) {
                if (type === 'export') return buildExports(list);
        }
}
fork icon0
star icon11
watch icon4

43
44
45
46
47
48
49
50
51
52
if (lastFile) {
    var out = lastFile.clone({contents: false});
    out.path = path.join(lastFile.base, fileName);

    var usedHelpers = ''
        + babel.buildExternalHelpers(helpers, 'var')
        + '\nmodule.exports = babelHelpers;';

    out.contents = new Buffer(usedHelpers);
    this.push(out);
fork icon0
star icon7
watch icon2

147
148
149
150
151
152
153
154
155
156
  });
}


function buildCdnReact(dirname) {
  var s = babelCore.buildExternalHelpers(babelHelpersList, 'global');

  return makeTask('build-cdn-react: ' + dirname, function() {
    return gulp.src('./build-targets/cdn-react.js')
      .pipe(plugins.browserify({
fork icon446
star icon0
watch icon2

55
56
57
58
59
60
61
62
63
 * @param {!Array<!Array<string>>} usedHelpers
 * @param {function} cb
 */
function onFileThroughEnd(usedHelpers, cb) {
  var helpers = [].concat.apply([], usedHelpers);
  var content = babel.buildExternalHelpers(helpers);
  fs.writeFileSync('third_party/babel/custom-babel-helpers.js', content +'\n');
  cb();
}
fork icon0
star icon0
watch icon9