Set up Babel transpilation

This commit is contained in:
jos 2019-08-28 11:54:14 +02:00
parent f11b070a1d
commit 8e2a7de17c
4 changed files with 1094 additions and 17 deletions

View File

@ -34,6 +34,21 @@ var bannerPlugin = new webpack.BannerPlugin({
raw: true
});
var webpackConfigModule = {
rules: [
{
test: /\.m?js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
}
]
};
// create a single instance of the compiler to allow caching
var compiler = webpack({
entry: ENTRY,
@ -48,7 +63,7 @@ var compiler = webpack({
// We no not want to minimize our code.
minimize: false
},
module: webpackConfigModule,
resolve: {
extensions: ['.js'],
mainFields: [ 'main' ], // pick ES5 version of vanilla-picker
@ -65,6 +80,7 @@ var compilerMinimalist = webpack({
path: DIST,
filename: NAME_MINIMALIST + '.js'
},
module: webpackConfigModule,
plugins: [
bannerPlugin,
new webpack.IgnorePlugin(new RegExp('^brace$')),

1067
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -34,6 +34,9 @@
"vanilla-picker": "2.9.2"
},
"devDependencies": {
"@babel/core": "7.5.5",
"@babel/preset-env": "7.5.5",
"babel-loader": "8.0.6",
"date-format": "2.1.0",
"fancy-log": "1.3.3",
"gulp": "4.0.2",

View File

@ -1125,9 +1125,9 @@ exports.getIndexForPosition = function(el, row, column) {
* @returns {Array<{path: String, line: Number, row: Number}>}
*/
exports.getPositionForPath = function(text, paths) {
var me = this;
var result = [];
var jsmap;
const me = this;
const result = [];
let jsmap;
if (!paths || !paths.length) {
return result;
}
@ -1139,9 +1139,9 @@ exports.getPositionForPath = function(text, paths) {
}
paths.forEach(function (path) {
var pathArr = me.parsePath(path);
var pointerName = exports.compileJSONPointer(pathArr);
var pointer = jsmap.pointers[pointerName];
const pathArr = me.parsePath(path);
const pointerName = exports.compileJSONPointer(pathArr);
const pointer = jsmap.pointers[pointerName];
if (pointer) {
result.push({
path: path,
@ -1152,7 +1152,6 @@ exports.getPositionForPath = function(text, paths) {
});
return result;
}
/**
@ -1163,12 +1162,10 @@ exports.getPositionForPath = function(text, paths) {
*/
exports.compileJSONPointer = function (path) {
return path
.map(function (p) {
return ('/' + String(p)
.replace(/~/g, '~0')
.replace(/\//g, '~1')
);
})
.map(p => ('/' + String(p)
.replace(/~/g, '~0')
.replace(/\//g, '~1')
))
.join('');
};