diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 605e5429f1..42574ea3e4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -103,8 +103,8 @@ jobs: - name: Build the Package run: npm run build-package - - name: Generate the Legacy Build - run: "npm run build-legacy && npx eslint --rule 'import/no-duplicates: off' --fix build/index.js" + - name: Generate the Full Build + run: "npm run build-full" rendering: name: Rendering diff --git a/changelog/upgrade-notes.md b/changelog/upgrade-notes.md index 5bc0390ab9..7cd8d25bde 100644 --- a/changelog/upgrade-notes.md +++ b/changelog/upgrade-notes.md @@ -2,6 +2,10 @@ ### Next version +#### Notice to full build users + +If you have been using the full (or legacy) build of the library, note that the location of these scripts is changing for this and future releases. The previous locations were not stable, and although we do not recommend linking to the full build for production applications, there are many instances of this that were breaking due to changing URLs. See the [download page](https://openlayers.org/download/) for details on the new versioned URLs for the full build. + #### Deprecation of `ol/AssertionError` and error codes Future versions will no longer throw `ol/AssertionError` with an error `code`. Instead, they will throw `Error` with just the error message. diff --git a/config/rollup-full-build.js b/config/rollup-full-build.js new file mode 100644 index 0000000000..033343358a --- /dev/null +++ b/config/rollup-full-build.js @@ -0,0 +1,24 @@ +import commonjs from '@rollup/plugin-commonjs'; +import externalGlobals from 'rollup-plugin-external-globals'; +import resolve from '@rollup/plugin-node-resolve'; +import {terser} from 'rollup-plugin-terser'; + +export default { + input: 'build/index.js', + output: { + name: 'ol', + format: 'iife', + exports: 'default', + file: 'build/full/ol.js', + sourcemap: true, + }, + plugins: [ + resolve({moduleDirectories: ['build', 'node_modules']}), + commonjs(), + externalGlobals({ + geotiff: 'GeoTIFF', + 'ol-mapbox-style': 'olms', + }), + terser(), + ], +}; diff --git a/config/webpack-config-legacy-build.mjs b/config/webpack-config-legacy-build.mjs deleted file mode 100644 index 87e23f58a4..0000000000 --- a/config/webpack-config-legacy-build.mjs +++ /dev/null @@ -1,37 +0,0 @@ -import TerserPlugin from 'terser-webpack-plugin'; -import path from 'path'; - -export default { - entry: './build/index.js', - devtool: 'source-map', - mode: 'production', - target: ['browserslist'], - resolve: { - fallback: { - fs: false, - http: false, - https: false, - }, - alias: { - ol: path.resolve('./build/ol'), - }, - }, - optimization: { - minimizer: [ - new TerserPlugin({ - terserOptions: { - // Mangle private members convention with underscore suffix - mangle: {properties: {regex: /_$/}}, - }, - }), - ], - }, - output: { - path: path.resolve('./build/legacy'), - publicPath: 'auto', - filename: 'ol.js', - library: 'ol', - libraryTarget: 'umd', - libraryExport: 'default', - }, -}; diff --git a/package-lock.json b/package-lock.json index b957d5af7b..8944d8fc02 100644 --- a/package-lock.json +++ b/package-lock.json @@ -65,6 +65,7 @@ "proj4": "2.8.0", "puppeteer": "17.0.0", "rollup": "^2.42.3", + "rollup-plugin-external-globals": "^0.6.1", "rollup-plugin-terser": "^7.0.2", "semver": "^7.3.7", "serve-static": "^1.14.0", @@ -4383,9 +4384,9 @@ "dev": true }, "node_modules/es-module-lexer": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-0.9.0.tgz", - "integrity": "sha512-qU2eN/XHsrl3E4y7mK1wdWnyy5c8gXtCbfP6Xcsemm7fPUR1PIV1JhZfP7ojcN0Fzp69CfrS3u76h2tusvfKiQ==", + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-0.9.3.tgz", + "integrity": "sha512-1HQ2M2sPtxwnvOvT1ZClHyQDiggdNjURWpY2we6aMKCQiUVxTmVs2UYPLIrD84sS+kMdUwfBSylbJPwNnBrnHQ==", "dev": true }, "node_modules/es-to-primitive": { @@ -8771,6 +8772,34 @@ "fsevents": "~2.3.2" } }, + "node_modules/rollup-plugin-external-globals": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/rollup-plugin-external-globals/-/rollup-plugin-external-globals-0.6.1.tgz", + "integrity": "sha512-mlp3KNa5sE4Sp9UUR2rjBrxjG79OyZAh/QC18RHIjM+iYkbBwNXSo8DHRMZWtzJTrH8GxQ+SJvCTN3i14uMXIA==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^4.0.0", + "estree-walker": "^2.0.1", + "is-reference": "^1.2.1", + "magic-string": "^0.25.7" + }, + "peerDependencies": { + "rollup": "^2.25.0" + } + }, + "node_modules/rollup-plugin-external-globals/node_modules/@rollup/pluginutils": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-4.2.1.tgz", + "integrity": "sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==", + "dev": true, + "dependencies": { + "estree-walker": "^2.0.1", + "picomatch": "^2.2.2" + }, + "engines": { + "node": ">= 8.0.0" + } + }, "node_modules/rollup-plugin-terser": { "version": "7.0.2", "resolved": "https://registry.npmjs.org/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz", @@ -14157,9 +14186,9 @@ "dev": true }, "es-module-lexer": { - "version": "0.9.0", - "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-0.9.0.tgz", - "integrity": "sha512-qU2eN/XHsrl3E4y7mK1wdWnyy5c8gXtCbfP6Xcsemm7fPUR1PIV1JhZfP7ojcN0Fzp69CfrS3u76h2tusvfKiQ==", + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-0.9.3.tgz", + "integrity": "sha512-1HQ2M2sPtxwnvOvT1ZClHyQDiggdNjURWpY2we6aMKCQiUVxTmVs2UYPLIrD84sS+kMdUwfBSylbJPwNnBrnHQ==", "dev": true }, "es-to-primitive": { @@ -17463,6 +17492,30 @@ "fsevents": "~2.3.2" } }, + "rollup-plugin-external-globals": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/rollup-plugin-external-globals/-/rollup-plugin-external-globals-0.6.1.tgz", + "integrity": "sha512-mlp3KNa5sE4Sp9UUR2rjBrxjG79OyZAh/QC18RHIjM+iYkbBwNXSo8DHRMZWtzJTrH8GxQ+SJvCTN3i14uMXIA==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^4.0.0", + "estree-walker": "^2.0.1", + "is-reference": "^1.2.1", + "magic-string": "^0.25.7" + }, + "dependencies": { + "@rollup/pluginutils": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-4.2.1.tgz", + "integrity": "sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==", + "dev": true, + "requires": { + "estree-walker": "^2.0.1", + "picomatch": "^2.2.2" + } + } + } + }, "rollup-plugin-terser": { "version": "7.0.2", "resolved": "https://registry.npmjs.org/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz", diff --git a/package.json b/package.json index c128e36d8d..a0f64a44dd 100644 --- a/package.json +++ b/package.json @@ -20,9 +20,9 @@ "start": "npm run serve-examples", "serve-examples": "webpack serve --config examples/webpack/config.mjs --mode development", "build-examples": "shx rm -rf build/examples && webpack --config examples/webpack/config.mjs --mode production", - "build-package": "npm run transpile && npm run copy-css && npm run generate-types && node tasks/prepare-package.js", - "build-index": "shx rm -f build/index.js && npm run build-package && node tasks/generate-index.js", - "build-legacy": "shx rm -rf build/legacy && npm run build-index && webpack --config config/webpack-config-legacy-build.mjs && cleancss --source-map src/ol/ol.css -o build/legacy/ol.css", + "build-package": "npm run build-full && npm run copy-css && npm run generate-types && node tasks/prepare-package.js", + "build-index": "shx rm -f build/index.js && npm run transpile && node tasks/generate-index.js", + "build-full": "shx rm -rf build/full && npm run build-index && npx rollup --config config/rollup-full-build.js", "copy-css": "shx cp src/ol/ol.css build/ol/ol.css", "generate-types": "tsc --project config/tsconfig-build.json --declaration --declarationMap --emitDeclarationOnly --outdir build/ol", "transpile": "shx rm -rf build/ol && shx mkdir -p build/ol && shx cp -rf src/ol build && node tasks/serialize-workers.cjs", @@ -100,6 +100,7 @@ "proj4": "2.8.0", "puppeteer": "17.0.0", "rollup": "^2.42.3", + "rollup-plugin-external-globals": "^0.6.1", "rollup-plugin-terser": "^7.0.2", "semver": "^7.3.7", "serve-static": "^1.14.0", diff --git a/src/ol/layer/MapboxVector.js b/src/ol/layer/MapboxVector.js index 28bff1b240..5c1d26d4d0 100644 --- a/src/ol/layer/MapboxVector.js +++ b/src/ol/layer/MapboxVector.js @@ -130,6 +130,9 @@ class ErrorEvent extends BaseEvent { * On configuration or loading error, the layer will trigger an `'error'` event. Listeners * will receive an object with an `error` property that can be used to diagnose the problem. * + * **Note for users of the full build**: The `MapboxVectorLayer` requires the + * [ol-mapbox-style](https://github.com/openlayers/ol-mapbox-style) library to be loaded as well. + * * @param {Options} options Options. * @extends {VectorTileLayer} * @fires module:ol/events/Event~BaseEvent#event:error diff --git a/src/ol/source/GeoTIFF.js b/src/ol/source/GeoTIFF.js index 27843c5992..485d074e0e 100644 --- a/src/ol/source/GeoTIFF.js +++ b/src/ol/source/GeoTIFF.js @@ -365,6 +365,9 @@ function getMaxForDataType(array) { /** * @classdesc * A source for working with GeoTIFF data. + * **Note for users of the full build**: The `GeoTIFF` source requires the + * [geotiff.js](https://github.com/geotiffjs/geotiff.js) library to be loaded as well. + * * @api */ class GeoTIFFSource extends DataTile { diff --git a/tasks/build-website.sh b/tasks/build-website.sh index 3335d9d63d..11e025dc52 100755 --- a/tasks/build-website.sh +++ b/tasks/build-website.sh @@ -71,9 +71,9 @@ echo "Building API docs for ${version}" npm run apidoc mv build/apidoc ${build}/en/${version}/ -echo "Building the legacy build for ${version}" -npm run build-legacy -mv build/legacy ${build}/en/${version}/ +echo "Building the package ${version}" +npm run build-package +mv build/ol ${build}/en/${version}/ if [[ "${latest}" == "${version}" ]] ; then echo "Copying to en/latest" @@ -84,7 +84,7 @@ if [[ "${latest}" == "${version}" ]] ; then zip -r ${OLDPWD}/build/${version}-site.zip . -x "en/${version}/*" popd - pushd ${build}/en/${version}/legacy - zip -r ${OLDPWD}/build/${version}-legacy.zip . + pushd ${build}/en/${version}/ol + zip -r ${OLDPWD}/build/${version}-package.zip . popd fi diff --git a/tasks/prepare-package.js b/tasks/prepare-package.js index 47e109bda8..2024273f7c 100644 --- a/tasks/prepare-package.js +++ b/tasks/prepare-package.js @@ -37,6 +37,11 @@ async function main() { path.resolve(baseDir, '../LICENSE.md'), path.join(buildDir, 'LICENSE.md') ); + + await fse.copy( + path.resolve(baseDir, '../build/full/'), + path.join(buildDir, 'dist') + ); } /**