Add Babel and core-js & regenerator polyfills (#367)

This commit is contained in:
Norbert Renner 2021-02-12 10:07:02 +01:00 committed by GitHub
parent 2b94300c61
commit 0ee37f557a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 1130 additions and 107 deletions

View file

@ -3,3 +3,5 @@ layers/collection/extract.js
gulpfile.js
dist/brouter-web.js
dist/turf.min.js
dist/core-js-bundle.min.js
dist/regenerator-runtime.js

View file

@ -1,9 +1,10 @@
{
"extends": ["plugin:compat/recommended"],
"env": {
"browser": true
"browser": true,
"es2021": true
},
"settings": {
"polyfills": ["URLSearchParams", "Symbol.iterator", "Promise", "fetch", "Math", "Number", "navigator"]
"polyfills": ["URL", "Promise", "navigator", "Uint8Array", "performance", "location.hostname"]
}
}

View file

@ -114,10 +114,6 @@ Copyright (c) 2018 Norbert Renner and [contributors](https://github.com/nrenner/
Copyright (c) 2016 Eduard <edward17>; [MIT License](https://github.com/Edward17/LayersCollection/blob/gh-pages/LICENSE.md)
- [Leaflet-providers](https://github.com/leaflet-extras/leaflet-providers)
Copyright (c) 2013 Leaflet Providers contributors All rights reserved.; [2-clause BSD License](https://github.com/leaflet-extras/leaflet-providers/blob/master/license.md)
- [Fetch polyfill](https://github.com/Github/fetch)
Copyright (c) 2014-2016 GitHub, Inc.; [MIT License](https://github.com/github/fetch/blob/master/LICENSE)
- [Promise Polyfill](https://github.com/taylorhakes/promise-polyfill)
Copyright (c) 2014 Taylor Hakes, Copyright (c) 2014 Forbes Lindesay; [MIT License](https://github.com/taylorhakes/promise-polyfill/blob/master/LICENSE)
- [Leaflet.FileLayer](https://github.com/makinacorpus/Leaflet.FileLayer)
Copyright (c) 2012 Makina Corpus; [MIT License](https://github.com/makinacorpus/Leaflet.FileLayer/blob/master/LICENSE)
- [togeojson](https://github.com/mapbox/togeojson)
@ -127,4 +123,10 @@ Copyright (c) 2018 Norbert Renner and [contributors](https://github.com/nrenner/
- [leaflet-distance-markers](https://github.com/adoroszlai/leaflet-distance-markers)
Copyright (c) 2014- Doroszlai Attila, 2016- Phil Whitehurst; [MIT License](https://github.com/adoroszlai/leaflet-distance-markers/blob/master/LICENSE.md)
- [Leaflet.hotline](https://github.com/iosphere/Leaflet.hotline)
Copyright (c) 2015, iosphere GmbH, Jonas Coch; [Leaflet.hotline](https://github.com/iosphere/Leaflet.hotline/blob/master/LICENSE)
Copyright (c) 2015, iosphere GmbH, Jonas Coch; [3-clause BSD License](https://github.com/iosphere/Leaflet.hotline/blob/master/LICENSE)
- [Babel](https://github.com/babel/babel)
Copyright (c) 2014-present Sebastian McKenzie and other contributors; [MIT License](https://github.com/babel/babel/blob/main/LICENSE)
- [core-js](https://github.com/zloirock/core-js)
Copyright (c) 2014-2021 Denis Pushkarev; [MIT License](https://github.com/zloirock/core-js/blob/master/LICENSE)
- [regenerator-runtime](https://github.com/facebook/regenerator/tree/master/packages/regenerator-runtime)
Copyright (c) 2014-present, Facebook, Inc.; [MIT License](https://github.com/facebook/regenerator/blob/master/packages/regenerator-runtime/LICENSE)

5
babel.config.json Normal file
View file

@ -0,0 +1,5 @@
{
"presets": [["@babel/preset-env", {}]],
"sourceType": "script",
"exclude": ["node_modules/**"]
}

View file

@ -27,6 +27,7 @@ var jsonConcat = require('gulp-json-concat');
var rename = require('gulp-rename');
var browserSync = require('browser-sync');
var merge = require('merge-stream');
var babel = require('gulp-babel');
const server = browserSync.create();
@ -35,7 +36,12 @@ var debug = false;
var paths = {
// see overrides in package.json
scriptsConfig: mainNpmFiles()
.filter((f) => RegExp('url-search-params/.*\\.js', 'i').test(f))
.filter(
(f) =>
RegExp('url-search-params/.*\\.js', 'i').test(f) ||
RegExp('core-js-bundle/.*\\.js', 'i').test(f) ||
RegExp('regenerator-runtime/.*\\.js', 'i').test(f)
)
.concat([
// large lib as extra file for faster parallel loading (*.min.js already excluded from bundle)
'node_modules/@turf/turf/turf.min.js',
@ -50,7 +56,9 @@ var paths = {
(f) =>
RegExp('.*\\.js', 'i').test(f) &&
!RegExp('.*\\.min\\.js', 'i').test(f) &&
!RegExp('url-search-params/.*\\.js', 'i').test(f)
!RegExp('url-search-params/.*\\.js', 'i').test(f) &&
!RegExp('core-js-bundle/.*\\.js', 'i').test(f) &&
!RegExp('regenerator-runtime/.*\\.js', 'i').test(f)
)
)
.concat([
@ -92,7 +100,19 @@ gulp.task('clean', function (cb) {
// libs that require loading before config.js
gulp.task('scripts_config', function () {
// just copy for now
return gulp.src(paths.scriptsConfig).pipe(gulp.dest(paths.dest));
return gulp
.src(paths.scriptsConfig)
.pipe(
rename(function (path) {
if (path.basename === 'minified') {
path.basename = 'core-js-bundle.min';
} else if (path.basename === 'runtime') {
path.basename = 'regenerator-runtime';
}
})
)
.pipe(replace('//# sourceMappingURL=minified.js.map', ''))
.pipe(gulp.dest(paths.dest));
});
gulp.task('scripts', function () {
@ -103,6 +123,7 @@ gulp.task('scripts', function () {
.src(paths.scripts, { base: '.' })
.pipe(sourcemaps.init())
.pipe(cached('scripts'))
.pipe(gulpif(!debug, babel()))
.pipe(gulpif(!debug, uglify()))
.pipe(remember('scripts'))
.pipe(concat(paths.destName + '.js'))

View file

@ -1106,6 +1106,8 @@
);
</script>
<script src="dist/core-js-bundle.min.js"></script>
<script src="dist/regenerator-runtime.js"></script>
<!-- <script src="dist/url-search-params.js"></script> -->
<script src="config.js"></script>
<script src="keys.js"></script>

View file

@ -46,6 +46,7 @@
"bootstrap-select": "1.13.6",
"bootstrap-slider": "^9.8.1",
"codemirror": "^5.35.0",
"core-js-bundle": "^3.8.3",
"datatables": "~1.10.18",
"font-awesome": "^4.7.0",
"geo-data-exchange": "alexcojocaru/geo-data-exchange#v1.1.0",
@ -73,19 +74,22 @@
"leaflet.stravasegments": "2.3.2",
"mapbbcode": "MapBBCode/mapbbcode#v1.2.0",
"osmtogeojson": "^3.0.0-beta.4",
"promise-polyfill": "^8.2.0",
"regenerator-runtime": "^0.13.7",
"togpx": "^0.5.4",
"topojson-client": "^3.1.0",
"url-search-params": "~0.5.0",
"whatwg-fetch": "^3.5.0"
"url-search-params": "~0.5.0"
},
"devDependencies": {
"@babel/cli": "^7.12.13",
"@babel/core": "^7.12.13",
"@babel/preset-env": "^7.12.13",
"autoprefixer": "^8.1.0",
"browser-sync": "^2.26.14",
"del": "^1.1.1",
"eslint": "^7.15.0",
"eslint-plugin-compat": "^3.3.0",
"eslint-plugin-compat": "^3.9.0",
"gulp": "^4.0.2",
"gulp-babel": "^8.0.0",
"gulp-bump": "^3.2.0",
"gulp-cached": "^1.0.4",
"gulp-clean-css": "^4.3.0",
@ -247,11 +251,6 @@
"dist/themes/default/*.png"
]
},
"promise-polyfill": {
"main": [
"dist/polyfill.js"
]
},
"Leaflet.vector-markers": {
"main": [
"dist/leaflet-vector-markers.js",
@ -272,6 +271,11 @@
"main": [
"togpx.js"
]
},
"core-js-bundle": {
"main": [
"minified.js"
]
}
}
}

1160
yarn.lock

File diff suppressed because it is too large Load diff