diff --git a/build.js b/build.js index dc1a6b3d2..f596a26b5 100644 --- a/build.js +++ b/build.js @@ -14,15 +14,15 @@ function buildAll() { return _currBuild = Promise.resolve() - .then(() => buildCSS()) - .then(() => buildData()) - .then(() => buildSrc()) - .then(() => _currBuild = null) - .catch((err) => { - console.error(err); - _currBuild = null; - process.exit(1); - }); + .then(() => buildCSS()) + .then(() => buildData()) + .then(() => buildSrc()) + .then(() => _currBuild = null) + .catch((err) => { + console.error(err); + _currBuild = null; + process.exit(1); + }); } module.exports = buildAll; diff --git a/build_css.js b/build_css.js index b68254373..02b8e4b5b 100644 --- a/build_css.js +++ b/build_css.js @@ -18,19 +18,19 @@ function buildCSS() { return _currBuild = Promise.resolve() - .then(() => doGlob('css/**/*.css')) - .then((files) => doConcat(files, 'dist/iD.css')) - .then(() => { - console.timeEnd(END); - console.log(''); - _currBuild = null; - }) - .catch((err) => { - console.error(err); - console.log(''); - _currBuild = null; - process.exit(1); - }); + .then(() => doGlob('css/**/*.css')) + .then((files) => doConcat(files, 'dist/iD.css')) + .then(() => { + console.timeEnd(END); + console.log(''); + _currBuild = null; + }) + .catch((err) => { + console.error(err); + console.log(''); + _currBuild = null; + process.exit(1); + }); } diff --git a/build_src.js b/build_src.js index e8a959fb9..e5b3aa0f4 100644 --- a/build_src.js +++ b/build_src.js @@ -1,10 +1,9 @@ /* eslint-disable no-console */ -const buble = require('@rollup/plugin-buble'); const colors = require('colors/safe'); -const commonjs = require('rollup-plugin-commonjs'); +const commonjs = require('@rollup/plugin-commonjs'); const includePaths = require('rollup-plugin-includepaths'); -const json = require('rollup-plugin-json'); -const nodeResolve = require('rollup-plugin-node-resolve'); +const json = require('@rollup/plugin-json'); +const nodeResolve = require('@rollup/plugin-node-resolve'); const rollup = require('rollup'); const shell = require('shelljs'); // const visualizer = require('rollup-plugin-visualizer'); @@ -24,18 +23,18 @@ function buildSrc() { return _currBuild = Promise.resolve() - .then(() => buildBundle()) - .then(() => { - console.timeEnd(END); - console.log(''); - _currBuild = null; - }) - .catch((err) => { - console.error(err); - console.log(''); - _currBuild = null; - process.exit(1); - }); + .then(() => buildBundle()) + .then(() => { + console.timeEnd(END); + console.log(''); + _currBuild = null; + }) + .catch((err) => { + console.error(err); + console.log(''); + _currBuild = null; + process.exit(1); + }); } @@ -66,8 +65,7 @@ function buildBundle() { dedupe: ['object-inspect'] }), commonjs(), - json({ indent: '' }), - buble(), + json({ indent: '' }) // viz causes src build to take about 3x longer; skip // visualizer({ // filename: 'docs/statistics.html', diff --git a/dist/index.html b/dist/index.html index 6061e59e8..530e57539 100644 --- a/dist/index.html +++ b/dist/index.html @@ -21,11 +21,8 @@ newScript.onerror = checkScript; var isIE11 = !!(navigator.userAgent.match(/Trident/) && !navigator.userAgent.match(/MSIE/)); - if (isIE11) { - newScript.src = 'iD.min.js'; - } else { - newScript.src = 'iD.min.js'; - } + // currently all minified files are legacy ES5 because of uglifyJS + newScript.src = isIE11 ? 'iD.min.js' : 'id.min.js'; document.getElementsByTagName('head')[0].appendChild(newScript); diff --git a/index.html b/index.html index bb6c0d02d..873f09931 100644 --- a/index.html +++ b/index.html @@ -21,11 +21,7 @@ newScript.onerror = checkScript; var isIE11 = !!(navigator.userAgent.match(/Trident/) && !navigator.userAgent.match(/MSIE/)); - if (isIE11) { - newScript.src = 'dist/iD.js'; - } else { - newScript.src = 'dist/iD.js'; - } + newScript.src = isIE11 ? 'dist/iD.legacy.js' : 'dist/iD.js'; document.getElementsByTagName('head')[0].appendChild(newScript); diff --git a/package.json b/package.json index 74b247872..ed464a700 100644 --- a/package.json +++ b/package.json @@ -12,11 +12,12 @@ "scripts": { "all": "npm-run-all -s clean build dist", "build": "node --max-old-space-size=4096 build.js", + "build:legacy": "rollup --config rollup.config.legacy.js", "clean": "shx rm -f dist/*.js dist/*.map dist/*.css dist/img/*.svg", - "dist": "npm-run-all -p dist:**", + "dist": "npm-run-all -p build:legacy dist:**", "dist:mapillary": "shx mkdir -p dist/mapillary-js && shx cp -R node_modules/mapillary-js/dist/* dist/mapillary-js/", "dist:pannellum": "shx mkdir -p dist/pannellum-streetside && shx cp -R node_modules/pannellum/build/* dist/pannellum-streetside/", - "dist:min": "uglifyjs dist/iD.js --compress --mangle --output dist/iD.min.js", + "dist:min": "uglifyjs dist/iD.legacy.js --compress --mangle --output dist/iD.min.js", "dist:svg:id": "svg-sprite --symbol --symbol-dest . --shape-id-generator \"iD-%s\" --symbol-sprite dist/img/iD-sprite.svg \"svg/iD-sprite/**/*.svg\"", "dist:svg:community": "svg-sprite --symbol --symbol-dest . --shape-id-generator \"community-%s\" --symbol-sprite dist/img/community-sprite.svg node_modules/osm-community-index/dist/img/*.svg", "dist:svg:fa": "svg-sprite --symbol --symbol-dest . --symbol-sprite dist/img/fa-sprite.svg svg/fontawesome/*.svg", @@ -28,7 +29,7 @@ "imagery": "node data/update_imagery", "lint": "eslint *.js test/spec modules", "start": "node --max-old-space-size=4096 server.js", - "test": "npm-run-all -s lint build test:**", + "test": "npm-run-all -s lint build:legacy test:**", "test:phantom": "phantomjs --web-security=no node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js test/phantom.html spec", "test:iD": "phantomjs --web-security=no node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js test/index.html spec", "translations": "node data/update_locales" @@ -65,6 +66,9 @@ "@ideditor/temaki": "~3.12.0", "@mapbox/maki": "^6.0.0", "@rollup/plugin-buble": "^0.21.0", + "@rollup/plugin-commonjs": "^11.0.1", + "@rollup/plugin-json": "^4.0.1", + "@rollup/plugin-node-resolve": "^7.0.0", "chai": "^4.1.0", "cldr-core": "36.0.0", "cldr-localenames-full": "36.0.0", @@ -90,11 +94,8 @@ "osm-community-index": "2.0.0", "phantomjs-prebuilt": "~2.1.11", "request": "^2.88.0", - "rollup": "~1.27.2", - "rollup-plugin-commonjs": "^10.1.0", + "rollup": "~1.29.1", "rollup-plugin-includepaths": "~0.2.3", - "rollup-plugin-json": "~4.0.0", - "rollup-plugin-node-resolve": "~5.2.0", "rollup-plugin-visualizer": "~3.3.1", "shelljs": "^0.8.0", "shx": "^0.3.0", diff --git a/rollup.config.legacy.js b/rollup.config.legacy.js new file mode 100644 index 000000000..e4edbed7d --- /dev/null +++ b/rollup.config.legacy.js @@ -0,0 +1,43 @@ +/* eslint-disable no-console */ +import buble from '@rollup/plugin-buble'; +import commonjs from '@rollup/plugin-commonjs'; +import includePaths from 'rollup-plugin-includepaths'; +import json from '@rollup/plugin-json'; +import nodeResolve from '@rollup/plugin-node-resolve'; + +export default { + input: './modules/id.js', + onwarn: onWarn, + output: { + file: 'dist/iD.legacy.js', + format: 'iife', + sourcemap: false, + strict: false + }, + plugins: [ + includePaths({ + paths: ['node_modules/d3/node_modules'], // npm2 or windows + include: { + 'martinez-polygon-clipping': 'node_modules/martinez-polygon-clipping/dist/martinez.umd.js' + } + }), + nodeResolve({ + mainFields: ['module', 'main'], + browser: false, + dedupe: ['object-inspect'] + }), + commonjs(), + json({ indent: '' }), + buble() + ] +}; + +function onWarn(warning, warn) { + // skip certain warnings + if (warning.code === 'CIRCULAR_DEPENDENCY') return; + if (warning.code === 'EVAL') return; + + // Use default for everything else + console.log(warning.code); + warn(warning); +} diff --git a/test/index.html b/test/index.html index 0dfbd4958..7ea279990 100644 --- a/test/index.html +++ b/test/index.html @@ -2,169 +2,168 @@ - - Mocha Tests - - - + + Mocha Tests + + + -
+
- - - - - + + + + + - + - - + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - - - + + + + + + - - - - - - + + + + - - - - + - + + - - + + - - + + + + + + + + + - - - - - - - - - + + + + - - - - + + + + - - - - + + + + + + + + - - - - - - - - + + + + + + + + + + + - - - - - - - - - - - + + + + + + + - - - - - - - + + + - - - + + + + + + - - - - - - + + + + + + + + + + - - - - - - - - - - - - + diff --git a/test/phantom.html b/test/phantom.html index 162d87283..21149e5bc 100644 --- a/test/phantom.html +++ b/test/phantom.html @@ -2,38 +2,38 @@ - - Mocha Tests - - - + + Mocha Tests + + + -
+
- - - - - + + + + + - + - - - + + + - - + + - +