From f2d570bfa6b134f630b490a51ebcad376e75dd87 Mon Sep 17 00:00:00 2001 From: Antonio Manuel Rebollar Marquez Date: Thu, 22 Jun 2023 08:23:34 +0200 Subject: [PATCH] Tarea: #274793 Fichero mutated de Mapea y se elimina Babel.js --- mapea-js/package.json | 4 - mapea-js/webpack-config/mutate-loader.js | 172 +++++++++--------- .../webpack.development.config.js | 17 +- .../webpack.production-core.config.js | 17 +- .../webpack.production-plugins.config.js | 17 +- 5 files changed, 89 insertions(+), 138 deletions(-) diff --git a/mapea-js/package.json b/mapea-js/package.json index 21158d0cf..d9aac2c38 100644 --- a/mapea-js/package.json +++ b/mapea-js/package.json @@ -18,10 +18,6 @@ "url": "https://github.com/sigcorporativo-ja/Mapea4/issues" }, "devDependencies": { - "@babel/core": "^7.6.4", - "@babel/plugin-proposal-export-default-from": "^7.0.0-beta.51", - "@babel/preset-env": "^7.4.4", - "babel-loader": "^8.0.0-beta.4", "chromedriver": "^2.46.0", "copy-webpack-plugin": "^6.1.0", "cross-env": "^5.2.0", diff --git a/mapea-js/webpack-config/mutate-loader.js b/mapea-js/webpack-config/mutate-loader.js index a9ee4e657..048167c73 100644 --- a/mapea-js/webpack-config/mutate-loader.js +++ b/mapea-js/webpack-config/mutate-loader.js @@ -10,36 +10,41 @@ const CONF_ENV = { dev: [{ path: 'ol/format/GML3', - original: `GML3.prototype.getCoords_ = function (point, opt_srsName, opt_hasZ) { - var axisOrientation = 'enu'; - if (opt_srsName) { - axisOrientation = getProjection(opt_srsName).getAxisOrientation(); - } - var coords = ((axisOrientation.substr(0, 2) === 'en') ? - point[0] + ' ' + point[1] : - point[1] + ' ' + point[0]); - if (opt_hasZ) { - // For newly created points, Z can be undefined. - var z = point[2] || 0; - coords += ' ' + z; - } - return coords; - };`, - mutated: `GML3.prototype.getCoords_ = function (point, opt_srsName, opt_hasZ) { + original: `getCoords_(point, srsName, hasZ) { + let axisOrientation = 'enu'; + if (srsName) { + axisOrientation = getProjection(srsName).getAxisOrientation(); + } + let coords = + axisOrientation.substr(0, 2) === 'en' + ? point[0] + ' ' + point[1] + : point[1] + ' ' + point[0]; + if (hasZ) { + // For newly created points, Z can be undefined. + const z = point[2] || 0; + coords += ' ' + z; + } + + return coords; + }`, + mutated: `getCoords_(point, opt_srsName, opt_hasZ) { return point[0] + ' ' + point[1]; };`, }, { path: 'ol/layer/Layer', original: `export function inView(layerState, viewState) { - if (!layerState.visible) { - return false; - } - var resolution = viewState.resolution; - if (resolution < layerState.minResolution || resolution >= layerState.maxResolution) { - return false; - } - var zoom = viewState.zoom; - return zoom > layerState.minZoom && zoom <= layerState.maxZoom; + if (!layerState.visible) { + return false; + } + const resolution = viewState.resolution; + if ( + resolution < layerState.minResolution || + resolution >= layerState.maxResolution + ) { + return false; + } + const zoom = viewState.zoom; + return zoom > layerState.minZoom && zoom <= layerState.maxZoom; }`, mutated: `export function inView(layerState, viewState) { if (!layerState.visible) { @@ -55,33 +60,32 @@ const CONF_ENV = { }, { path: 'ol/format/GML3', - original: `GML3.prototype.writePos_ = function (node, value, objectStack) { - var context = objectStack[objectStack.length - 1]; - var hasZ = context['hasZ']; - var srsDimension = hasZ ? '3' : '2'; - node.setAttribute('srsDimension', srsDimension); - var srsName = context['srsName']; - var axisOrientation = 'enu'; - if (srsName) { - axisOrientation = getProjection(srsName).getAxisOrientation(); - } - var point = value.getCoordinates(); - var coords; - // only 2d for simple features profile - if (axisOrientation.substr(0, 2) === 'en') { - coords = (point[0] + ' ' + point[1]); - } - else { - coords = (point[1] + ' ' + point[0]); - } - if (hasZ) { - // For newly created points, Z can be undefined. - var z = point[2] || 0; - coords += ' ' + z; - } - writeStringTextNode(node, coords); - };`, - mutated: `GML3.prototype.writePos_ = function (node, value, objectStack) { + original: `writePos_(node, value, objectStack) { + const context = objectStack[objectStack.length - 1]; + const hasZ = context['hasZ']; + const srsDimension = hasZ ? '3' : '2'; + node.setAttribute('srsDimension', srsDimension); + const srsName = context['srsName']; + let axisOrientation = 'enu'; + if (srsName) { + axisOrientation = getProjection(srsName).getAxisOrientation(); + } + const point = value.getCoordinates(); + let coords; + // only 2d for simple features profile + if (axisOrientation.substr(0, 2) === 'en') { + coords = point[0] + ' ' + point[1]; + } else { + coords = point[1] + ' ' + point[0]; + } + if (hasZ) { + // For newly created points, Z can be undefined. + const z = point[2] || 0; + coords += ' ' + z; + } + writeStringTextNode(node, coords); + }`, + mutated: `writePos_(node, value, objectStack) { var point = value.getCoordinates(); var coords = point[0] + " " + point[1]; writeStringTextNode(node, coords); @@ -90,24 +94,24 @@ const CONF_ENV = { ], prod: [{ path: 'ol/format/GML3', - original: `GML3.prototype.getCoords_ = function (point, opt_srsName, opt_hasZ) { - var axisOrientation = 'enu'; - - if (opt_srsName) { - axisOrientation = getProjection(opt_srsName).getAxisOrientation(); + original: `getCoords_(point, srsName, hasZ) { + let axisOrientation = 'enu'; + if (srsName) { + axisOrientation = getProjection(srsName).getAxisOrientation(); } - - var coords = axisOrientation.substr(0, 2) === 'en' ? point[0] + ' ' + point[1] : point[1] + ' ' + point[0]; - - if (opt_hasZ) { + let coords = + axisOrientation.substr(0, 2) === 'en' + ? point[0] + ' ' + point[1] + : point[1] + ' ' + point[0]; + if (hasZ) { // For newly created points, Z can be undefined. - var z = point[2] || 0; + const z = point[2] || 0; coords += ' ' + z; } return coords; - };`, - mutated: `GML3.prototype.getCoords_ = function (point, opt_srsName, opt_hasZ) { + }`, + mutated: `getCoords_(point, opt_srsName, opt_hasZ) { return point[0] + ' ' + point[1]; };`, }, { @@ -116,14 +120,14 @@ const CONF_ENV = { if (!layerState.visible) { return false; } - - var resolution = viewState.resolution; - - if (resolution < layerState.minResolution || resolution >= layerState.maxResolution) { + const resolution = viewState.resolution; + if ( + resolution < layerState.minResolution || + resolution >= layerState.maxResolution + ) { return false; } - - var zoom = viewState.zoom; + const zoom = viewState.zoom; return zoom > layerState.minZoom && zoom <= layerState.maxZoom; }`, mutated: `export function inView(layerState, viewState) { @@ -140,36 +144,32 @@ const CONF_ENV = { }, { path: 'ol/format/GML3', - original: `GML3.prototype.writePos_ = function (node, value, objectStack) { - var context = objectStack[objectStack.length - 1]; - var hasZ = context['hasZ']; - var srsDimension = hasZ ? '3' : '2'; + original: `writePos_(node, value, objectStack) { + const context = objectStack[objectStack.length - 1]; + const hasZ = context['hasZ']; + const srsDimension = hasZ ? '3' : '2'; node.setAttribute('srsDimension', srsDimension); - var srsName = context['srsName']; - var axisOrientation = 'enu'; - + const srsName = context['srsName']; + let axisOrientation = 'enu'; if (srsName) { axisOrientation = getProjection(srsName).getAxisOrientation(); } - - var point = value.getCoordinates(); - var coords; // only 2d for simple features profile - + const point = value.getCoordinates(); + let coords; + // only 2d for simple features profile if (axisOrientation.substr(0, 2) === 'en') { coords = point[0] + ' ' + point[1]; } else { coords = point[1] + ' ' + point[0]; } - if (hasZ) { // For newly created points, Z can be undefined. - var z = point[2] || 0; + const z = point[2] || 0; coords += ' ' + z; } - writeStringTextNode(node, coords); - };`, - mutated: `GML3.prototype.writePos_ = function (node, value, objectStack) { + }`, + mutated: `writePos_(node, value, objectStack) { var point = value.getCoordinates(); var coords = point[0] + " " + point[1]; writeStringTextNode(node, coords); diff --git a/mapea-js/webpack-config/webpack.development.config.js b/mapea-js/webpack-config/webpack.development.config.js index 85b9850f4..1830bfa46 100644 --- a/mapea-js/webpack-config/webpack.development.config.js +++ b/mapea-js/webpack-config/webpack.development.config.js @@ -68,22 +68,7 @@ module.exports = { }, { test: /\.js$/, - exclude: /(node_modules|bower_components)/, - use: { - loader: 'babel-loader', - options: { - presets: [ - [ - '@babel/preset-env', - { - targets: { - esmodules: true, - }, - }, - ], - ], - }, - }, + exclude: /(node_modules|bower_components)/ }, { test: /\.js$/, diff --git a/mapea-js/webpack-config/webpack.production-core.config.js b/mapea-js/webpack-config/webpack.production-core.config.js index 98c8cffea..f63509dd7 100644 --- a/mapea-js/webpack-config/webpack.production-core.config.js +++ b/mapea-js/webpack-config/webpack.production-core.config.js @@ -46,22 +46,7 @@ module.exports = { include: /node_modules\/ol\/*/, }, { test: /\.js$/, - exclude: /(node_modules\/(?!ol)|bower_components)/, - use: { - loader: 'babel-loader', - options: { - presets: [ - [ - '@babel/preset-env', - { - targets: { - esmodules: true, - }, - }, - ], - ], - }, - }, + exclude: /(node_modules\/(?!ol)|bower_components)/ }, { test: /\.js$/, diff --git a/mapea-js/webpack-config/webpack.production-plugins.config.js b/mapea-js/webpack-config/webpack.production-plugins.config.js index 7e1e5e266..c799cf7f6 100644 --- a/mapea-js/webpack-config/webpack.production-plugins.config.js +++ b/mapea-js/webpack-config/webpack.production-plugins.config.js @@ -23,22 +23,7 @@ module.exports = { module: { rules: [{ test: /\.js$/, - exclude: /(node_modules\/(?!ol)|bower_components)/, - use: { - loader: 'babel-loader', - options: { - presets: [ - [ - '@babel/preset-env', - { - targets: { - esmodules: true, - }, - }, - ], - ], - }, - }, + exclude: /(node_modules\/(?!ol)|bower_components)/ }, { test: /\.js$/,