How to use babel-core.transformFileAsync:
135 136 137 138 139 140 141 142 143 144 145
}) }) } function compileJsAndReplace(filePath){ babel.transformFileAsync(filePath, { babelrc: false, presets: [ ['env', { 'modules': 'umd',
How to use babel-core.Pipeline:
How to use babel-core.types:
58 59 60 61 62 63 64 65 66 67
``` 此时,我们为插件创建一个文件,内容为导出一个默认的函数: ```js // moriscript.js module.exports = function(babel) { var t = babel.types; return { visitor: { } };
395
47
2
See more examples
How to use babel-core.transformFile:
2 3 4 5 6 7 8 9 10 11 12
const babel = require('babel-core'); module.exports = (filePath, callback) => { // Transform the file. // Check process.env.NODE_ENV to see if we should create sourcemaps. babel.transformFile( filePath, { sourceMaps: process.env.NODE_ENV === 'development' ? 'inline' : false, comments: false,
How to use babel-core.buildExternalHelpers:
GitHub: mzohaibqc/mui
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({
446
0
2
See more examples
How to use babel-core.transformFileSync:
GitHub: wetools/wept
11 12 13 14 15 16 17 18 19 20
if (os.platform() === 'win32') moduleName = moduleName.replace(/\\/gm, '/'); let content = `define("${moduleName}", `; content += `function(require, module, exports, window,document,frames,self,location,navigator,localStorage,history,Caches,screen,alert,confirm,prompt,fetch,XMLHttpRequest,WebSocket,webkit,WeixinJSCore,Reporter,print,URL,DOMParser,upload,preview,build,showDecryptedInfo,syncMessage,checkProxy,showSystemInfo,openVendor,openToolsLog,showRequestInfo,help,showDebugInfoTable,closeDebug,showDebugInfo,__global,WeixinJSBridge){\n`; if (projectConfig.setting.es6 && fs.statSync(sourceFile).size / 1024 < 500) { content += babel.transformFileSync(sourceFile, {presets: ['babel-preset-env', 'babel-preset-stage-0'].map(require.resolve)}).code; } else { content += fs.readFileSync(path.resolve(sourceFile), {encoding: 'utf8'}); } content += '\n});';
446
0
121
See more examples
How to use babel-core.OptionManager:
GitHub: Pacharoth/node-smis
97 98 99 100 101 102 103 104 105 106 107 108 109 110
} function compile(filename) { var result = void 0; var opts = new _babelCore.OptionManager().init((0, _extend2.default)({ sourceRoot: _path2.default.dirname(filename) }, (0, _cloneDeep2.default)(transformOpts), { filename: filename })); var cacheKey = (0, _stringify2.default)(opts) + ":" + babel.version; var env = process.env.BABEL_ENV || process.env.NODE_ENV;
How to use babel-core.transformFromAst:
GitHub: airuikun/front-core
18 19 20 21 22 23 24 25 26 27
dependencies.push(node.source.value); }, }); const id = ID++; const {code} = transformFromAst(ast, null, { presets: ['env'], }); const customCode = loader(filename, code)
87
0
63
See more examples
How to use babel-core.util:
GitHub: Pacharoth/node-smis
133 134 135 136 137 138 139 140 141 142 143 144
function shouldIgnore(filename) { if (!ignore && !only) { return getRelativePath(filename).split(_path2.default.sep).indexOf("node_modules") >= 0; } else { return _babelCore.util.shouldIgnore(filename, ignore || [], only); } } function loader(m, filename) {
How to use babel-core.transform:
GitHub: Sage/streamlinejs
27 28 29 30 31 32 33 34 35 36
vars += "var " + decl[2] + ";"; if (decl[1] === "function") cmd = decl[2] + "=function " + decl[2] + decl[3]; else cmd = decl[2] + decl[3]; } var babelOptions = util.babelOptions(options); var source = vars + babel.transform("(function(_) {" + cmd + "})(__callback);", babelOptions).code; context.__filename = filename; // cannot assign context.__ directly in callback - need to investigate why context.__private = context.__private || {};
59
958
40
See more examples