Merge pull request #14067 from openlayers/embrace-legacy

Include the full build in the ol package
This commit is contained in:
Tim Schaub
2022-08-30 09:44:41 -06:00
committed by GitHub
10 changed files with 109 additions and 53 deletions

View File

@@ -103,8 +103,8 @@ jobs:
- name: Build the Package - name: Build the Package
run: npm run build-package run: npm run build-package
- name: Generate the Legacy Build - name: Generate the Full Build
run: "npm run build-legacy && npx eslint --rule 'import/no-duplicates: off' --fix build/index.js" run: "npm run build-full"
rendering: rendering:
name: Rendering name: Rendering

View File

@@ -2,6 +2,10 @@
### Next version ### 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 #### 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. Future versions will no longer throw `ol/AssertionError` with an error `code`. Instead, they will throw `Error` with just the error message.

View File

@@ -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(),
],
};

View File

@@ -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',
},
};

65
package-lock.json generated
View File

@@ -65,6 +65,7 @@
"proj4": "2.8.0", "proj4": "2.8.0",
"puppeteer": "17.0.0", "puppeteer": "17.0.0",
"rollup": "^2.42.3", "rollup": "^2.42.3",
"rollup-plugin-external-globals": "^0.6.1",
"rollup-plugin-terser": "^7.0.2", "rollup-plugin-terser": "^7.0.2",
"semver": "^7.3.7", "semver": "^7.3.7",
"serve-static": "^1.14.0", "serve-static": "^1.14.0",
@@ -4383,9 +4384,9 @@
"dev": true "dev": true
}, },
"node_modules/es-module-lexer": { "node_modules/es-module-lexer": {
"version": "0.9.0", "version": "0.9.3",
"resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-0.9.0.tgz", "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-0.9.3.tgz",
"integrity": "sha512-qU2eN/XHsrl3E4y7mK1wdWnyy5c8gXtCbfP6Xcsemm7fPUR1PIV1JhZfP7ojcN0Fzp69CfrS3u76h2tusvfKiQ==", "integrity": "sha512-1HQ2M2sPtxwnvOvT1ZClHyQDiggdNjURWpY2we6aMKCQiUVxTmVs2UYPLIrD84sS+kMdUwfBSylbJPwNnBrnHQ==",
"dev": true "dev": true
}, },
"node_modules/es-to-primitive": { "node_modules/es-to-primitive": {
@@ -8771,6 +8772,34 @@
"fsevents": "~2.3.2" "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": { "node_modules/rollup-plugin-terser": {
"version": "7.0.2", "version": "7.0.2",
"resolved": "https://registry.npmjs.org/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz", "resolved": "https://registry.npmjs.org/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz",
@@ -14157,9 +14186,9 @@
"dev": true "dev": true
}, },
"es-module-lexer": { "es-module-lexer": {
"version": "0.9.0", "version": "0.9.3",
"resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-0.9.0.tgz", "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-0.9.3.tgz",
"integrity": "sha512-qU2eN/XHsrl3E4y7mK1wdWnyy5c8gXtCbfP6Xcsemm7fPUR1PIV1JhZfP7ojcN0Fzp69CfrS3u76h2tusvfKiQ==", "integrity": "sha512-1HQ2M2sPtxwnvOvT1ZClHyQDiggdNjURWpY2we6aMKCQiUVxTmVs2UYPLIrD84sS+kMdUwfBSylbJPwNnBrnHQ==",
"dev": true "dev": true
}, },
"es-to-primitive": { "es-to-primitive": {
@@ -17463,6 +17492,30 @@
"fsevents": "~2.3.2" "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": { "rollup-plugin-terser": {
"version": "7.0.2", "version": "7.0.2",
"resolved": "https://registry.npmjs.org/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz", "resolved": "https://registry.npmjs.org/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz",

View File

@@ -20,9 +20,9 @@
"start": "npm run serve-examples", "start": "npm run serve-examples",
"serve-examples": "webpack serve --config examples/webpack/config.mjs --mode development", "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-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-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 build-package && node tasks/generate-index.js", "build-index": "shx rm -f build/index.js && npm run transpile && 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-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", "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", "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", "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", "proj4": "2.8.0",
"puppeteer": "17.0.0", "puppeteer": "17.0.0",
"rollup": "^2.42.3", "rollup": "^2.42.3",
"rollup-plugin-external-globals": "^0.6.1",
"rollup-plugin-terser": "^7.0.2", "rollup-plugin-terser": "^7.0.2",
"semver": "^7.3.7", "semver": "^7.3.7",
"serve-static": "^1.14.0", "serve-static": "^1.14.0",

View File

@@ -130,6 +130,9 @@ class ErrorEvent extends BaseEvent {
* On configuration or loading error, the layer will trigger an `'error'` event. Listeners * 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. * 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. * @param {Options} options Options.
* @extends {VectorTileLayer} * @extends {VectorTileLayer}
* @fires module:ol/events/Event~BaseEvent#event:error * @fires module:ol/events/Event~BaseEvent#event:error

View File

@@ -365,6 +365,9 @@ function getMaxForDataType(array) {
/** /**
* @classdesc * @classdesc
* A source for working with GeoTIFF data. * 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 * @api
*/ */
class GeoTIFFSource extends DataTile { class GeoTIFFSource extends DataTile {

View File

@@ -71,9 +71,9 @@ echo "Building API docs for ${version}"
npm run apidoc npm run apidoc
mv build/apidoc ${build}/en/${version}/ mv build/apidoc ${build}/en/${version}/
echo "Building the legacy build for ${version}" echo "Building the package ${version}"
npm run build-legacy npm run build-package
mv build/legacy ${build}/en/${version}/ mv build/ol ${build}/en/${version}/
if [[ "${latest}" == "${version}" ]] ; then if [[ "${latest}" == "${version}" ]] ; then
echo "Copying to en/latest" echo "Copying to en/latest"
@@ -84,7 +84,7 @@ if [[ "${latest}" == "${version}" ]] ; then
zip -r ${OLDPWD}/build/${version}-site.zip . -x "en/${version}/*" zip -r ${OLDPWD}/build/${version}-site.zip . -x "en/${version}/*"
popd popd
pushd ${build}/en/${version}/legacy pushd ${build}/en/${version}/ol
zip -r ${OLDPWD}/build/${version}-legacy.zip . zip -r ${OLDPWD}/build/${version}-package.zip .
popd popd
fi fi

View File

@@ -37,6 +37,11 @@ async function main() {
path.resolve(baseDir, '../LICENSE.md'), path.resolve(baseDir, '../LICENSE.md'),
path.join(buildDir, 'LICENSE.md') path.join(buildDir, 'LICENSE.md')
); );
await fse.copy(
path.resolve(baseDir, '../build/full/'),
path.join(buildDir, 'dist')
);
} }
/** /**