Set up Babel transpilation
This commit is contained in:
parent
f11b070a1d
commit
8e2a7de17c
18
gulpfile.js
18
gulpfile.js
|
@ -34,6 +34,21 @@ var bannerPlugin = new webpack.BannerPlugin({
|
||||||
raw: true
|
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
|
// create a single instance of the compiler to allow caching
|
||||||
var compiler = webpack({
|
var compiler = webpack({
|
||||||
entry: ENTRY,
|
entry: ENTRY,
|
||||||
|
@ -48,7 +63,7 @@ var compiler = webpack({
|
||||||
// We no not want to minimize our code.
|
// We no not want to minimize our code.
|
||||||
minimize: false
|
minimize: false
|
||||||
},
|
},
|
||||||
|
module: webpackConfigModule,
|
||||||
resolve: {
|
resolve: {
|
||||||
extensions: ['.js'],
|
extensions: ['.js'],
|
||||||
mainFields: [ 'main' ], // pick ES5 version of vanilla-picker
|
mainFields: [ 'main' ], // pick ES5 version of vanilla-picker
|
||||||
|
@ -65,6 +80,7 @@ var compilerMinimalist = webpack({
|
||||||
path: DIST,
|
path: DIST,
|
||||||
filename: NAME_MINIMALIST + '.js'
|
filename: NAME_MINIMALIST + '.js'
|
||||||
},
|
},
|
||||||
|
module: webpackConfigModule,
|
||||||
plugins: [
|
plugins: [
|
||||||
bannerPlugin,
|
bannerPlugin,
|
||||||
new webpack.IgnorePlugin(new RegExp('^brace$')),
|
new webpack.IgnorePlugin(new RegExp('^brace$')),
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -34,6 +34,9 @@
|
||||||
"vanilla-picker": "2.9.2"
|
"vanilla-picker": "2.9.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@babel/core": "7.5.5",
|
||||||
|
"@babel/preset-env": "7.5.5",
|
||||||
|
"babel-loader": "8.0.6",
|
||||||
"date-format": "2.1.0",
|
"date-format": "2.1.0",
|
||||||
"fancy-log": "1.3.3",
|
"fancy-log": "1.3.3",
|
||||||
"gulp": "4.0.2",
|
"gulp": "4.0.2",
|
||||||
|
|
|
@ -1125,9 +1125,9 @@ exports.getIndexForPosition = function(el, row, column) {
|
||||||
* @returns {Array<{path: String, line: Number, row: Number}>}
|
* @returns {Array<{path: String, line: Number, row: Number}>}
|
||||||
*/
|
*/
|
||||||
exports.getPositionForPath = function(text, paths) {
|
exports.getPositionForPath = function(text, paths) {
|
||||||
var me = this;
|
const me = this;
|
||||||
var result = [];
|
const result = [];
|
||||||
var jsmap;
|
let jsmap;
|
||||||
if (!paths || !paths.length) {
|
if (!paths || !paths.length) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1139,9 +1139,9 @@ exports.getPositionForPath = function(text, paths) {
|
||||||
}
|
}
|
||||||
|
|
||||||
paths.forEach(function (path) {
|
paths.forEach(function (path) {
|
||||||
var pathArr = me.parsePath(path);
|
const pathArr = me.parsePath(path);
|
||||||
var pointerName = exports.compileJSONPointer(pathArr);
|
const pointerName = exports.compileJSONPointer(pathArr);
|
||||||
var pointer = jsmap.pointers[pointerName];
|
const pointer = jsmap.pointers[pointerName];
|
||||||
if (pointer) {
|
if (pointer) {
|
||||||
result.push({
|
result.push({
|
||||||
path: path,
|
path: path,
|
||||||
|
@ -1152,7 +1152,6 @@ exports.getPositionForPath = function(text, paths) {
|
||||||
});
|
});
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1163,12 +1162,10 @@ exports.getPositionForPath = function(text, paths) {
|
||||||
*/
|
*/
|
||||||
exports.compileJSONPointer = function (path) {
|
exports.compileJSONPointer = function (path) {
|
||||||
return path
|
return path
|
||||||
.map(function (p) {
|
.map(p => ('/' + String(p)
|
||||||
return ('/' + String(p)
|
|
||||||
.replace(/~/g, '~0')
|
.replace(/~/g, '~0')
|
||||||
.replace(/\//g, '~1')
|
.replace(/\//g, '~1')
|
||||||
);
|
))
|
||||||
})
|
|
||||||
.join('');
|
.join('');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue