Update core 8.3.0
This commit is contained in:
parent
da7a7918f8
commit
cd7a898e66
6144 changed files with 132297 additions and 87747 deletions
web/core/scripts/js
54
web/core/scripts/js/babel-es6-build.js
Normal file
54
web/core/scripts/js/babel-es6-build.js
Normal file
|
@ -0,0 +1,54 @@
|
|||
/**
|
||||
* @file
|
||||
*
|
||||
* Compile *.es6.js files to ES5.
|
||||
*
|
||||
* @internal This file is part of the core javascript build process and is only
|
||||
* meant to be used in that context.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const babel = require('babel-core');
|
||||
const glob = require('glob');
|
||||
|
||||
// Logging human-readable timestamp.
|
||||
const log = function (message) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(`[${new Date().toTimeString().slice(0, 8)}] ${message}`);
|
||||
};
|
||||
|
||||
function addSourceMappingUrl(code, loc) {
|
||||
return code + '\n\n//# sourceMappingURL=' + path.basename(loc);
|
||||
}
|
||||
|
||||
const changedOrAdded = (filePath) => {
|
||||
babel.transformFile(filePath, {
|
||||
sourceMaps: true,
|
||||
comments: false
|
||||
}, function (err, result) {
|
||||
const fileName = filePath.slice(0, -7);
|
||||
// we've requested for a sourcemap to be written to disk
|
||||
let mapLoc = `${fileName}.js.map`;
|
||||
|
||||
fs.writeFile(mapLoc, JSON.stringify(result.map));
|
||||
fs.writeFile(`${fileName}.js`, addSourceMappingUrl(result.code, mapLoc));
|
||||
|
||||
log(`'${filePath}' is being processed.`);
|
||||
});
|
||||
};
|
||||
|
||||
const fileMatch = './**/*.es6.js';
|
||||
const globOptions = {
|
||||
ignore: 'node_modules/**'
|
||||
};
|
||||
const processFiles = (error, filePaths) => {
|
||||
if (error) {
|
||||
process.exitCode = 1;
|
||||
}
|
||||
filePaths.forEach(changedOrAdded);
|
||||
};
|
||||
glob(fileMatch, globOptions, processFiles);
|
||||
process.exitCode = 0;
|
Reference in a new issue