Skip to content

Commit

Permalink
Merge pull request #890 from OpenGeoscience/dual-builds
Browse files Browse the repository at this point in the history
Build two bundles: full and lean
  • Loading branch information
zachmullen authored Aug 10, 2018
2 parents 2da62e4 + f9259dc commit 88bd6ca
Show file tree
Hide file tree
Showing 17 changed files with 197 additions and 249 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ deploy:
file:
- dist/built/geo.js
- dist/built/geo.min.js
- dist/built/geo.ext.js
- dist/built/geo.ext.min.js
- dist/built/geo.lean.js
- dist/built/geo.lean.min.js
skip-cleanup: true
on:
tags: true
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log

## Unreleased

### Changes

- Changed build process: optional dependencies are now included in the bundle by default (#890)


## Version 0.17.0

### Features
Expand Down
9 changes: 5 additions & 4 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,11 @@ is needed. ::
npm install
npm run build

Compiled javascript libraries will be named ``geo.min.js`` and ``geo.ext.min.js`` in ``dist/built``.
The first file contains geojs and vgl bundled together with a number of dependent libraries.
The second file contains d3. The bundled libraries are minified, but source maps are provided
The compiled javascript libraries will be named ``geo.min.js`` and ``geo.lean.min.js`` in ``dist/built``.
The first file contains geojs including all optional dependencies. The second file is a version of
geojs without any of the third party dependencies such as d3 and Hammer; if you want to use the lean
bundle but need any of these dependencies, you must include them first in your page and expose them in
global scope under their standard names. The bundled libraries are minified, but source maps are provided.

.. _quick-start-guide:

Expand All @@ -76,7 +78,6 @@ and creating a basic full map using the `osmLayer` class.
.. code-block:: html

<head>
<script charset="UTF-8" src="/built/geo.ext.min.js"></script>
<script src="/built/geo.min.js"></script>

<style>
Expand Down
17 changes: 5 additions & 12 deletions docs/users.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,12 @@ User's guide
Dependencies
------------

GeoJS depends on several Javascript libraries that must be loaded
prior to use as well as a few recommended libraries for optional
features. As a convenience, we provide a bundle containing all
required and optional dependencies in a single minified file.
This bundle is built as ``dist/built/geo.ext.min.js``. If you
are just building a simple page out of GeoJS like in the
:ref:`quick start guide <quick-start-guide>`, this will probably
work well; however, when using GeoJS as part of an application,
you may need to customize the loading order or versions of the
bundled applications. In this case, you may need to include the
sources manually or bundle them yourself.

See the package.json file for a list of required and optional dependencies used by GeoJS.
All libraries listed as optional dependencies are built into the main ``geo.min.js`` bundle,
but are not present in the ``geo.lean.min.js`` bundle. If you want to use a subset of the
optional dependencies, you can use the lean bundle and import any required dependency
libraries into your page before the lean bundle, making sure that the library is exposed
under its standard name in global scope.

.. note::

Expand Down
63 changes: 0 additions & 63 deletions external.config.js

This file was deleted.

15 changes: 12 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,12 @@
"url-loader": "^1.0.1",
"webpack": "^3.12.0",
"webpack-cli": "^2.1.3",
"webpack-merge": "^4.1.4",
"webpack-serve": "^1.0.2",
"xmlbuilder": "^10.0.0"
},
"scripts": {
"build": "webpack --config webpack.config.js && webpack --config external.config.js",
"build": "webpack --config webpack.config.js && webpack --config webpack-lean.config.js",
"build-examples": "node examples/build.js && webpack --config webpack-examples.config.js",
"build-website-examples": "node examples/build-website.js && webpack --config webpack-website-examples.config.js",
"build-tutorials": "node tutorials/build.js && webpack --config webpack-tutorials.config.js",
Expand All @@ -121,7 +122,7 @@
"website": "cd website && npx hexo server",
"setup-website": "cd website && npm install",
"build-website": "npm run build && cp -a dist/built/. website/source/built && npm run build-website-examples && npm run build-website-tutorials && npm run docs && cd dist && find data \\( -name tiles -o -name base-images -o -name '*-hash-stamp' -o -name '*.tgz' \\) -prune -o \\( -print0 \\) | cpio -pmdL0 ../website/source && cp -ar apidocs/. ../website/source/apidocs && cd ../website && npm install && rm -f db.json && npx hexo generate",
"prepublishOnly": "webpack --config webpack.config.js && webpack --config external.config.js && cp dist/built/*.js ."
"prepublishOnly": "webpack --config webpack.config.js && webpack --config webpack-lean.config.js && cp dist/built/*.js ."
},
"keywords": [
"map",
Expand Down
5 changes: 0 additions & 5 deletions tutorials/basic/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ block mainTutorial
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="../../built/geo.ext.min.js"></script>
<script type="text/javascript" src="../../built/geo.min.js"></script>
</head>
<body>
Expand All @@ -18,10 +17,6 @@ block mainTutorial
</html>

:markdown-it
The second script, ``geo.ext.min.js``, is optional. It adds support
for svg elements and touch interaction. It needs to be added before
``geo.min.js``.

Some CSS will make our map fill the page:

+codeblock('css', 2).
Expand Down
1 change: 0 additions & 1 deletion tutorials/common/tutorials.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ var processBlockInfo = {
/* We could also load from the CDN:
* https://cdnjs.cloudflare.com/ajax/libs/geojs/0.12.2/geo.min.js
* or the non-minified versions to make debug easier. */
' <script type="text/javascript" src="../../built/geo.ext.min.js"></script>\n' +
' <script type="text/javascript" src="../../built/geo.min.js"></script>\n' +
'</head>\n' +
'<body>\n' +
Expand Down
4 changes: 1 addition & 3 deletions tutorials/editor3/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@ block mainTutorial
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="../../built/geo.ext.min.js"></script>
<script type="text/javascript" src="../../built/geo.min.js"></script>
<!-- Use a specific version of GeoJS by requesting it from a CDN.
For instance, remove the local references, above, and
uncomment the following:
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/geojs/0.15.1/geo.ext.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/geojs/0.15.1/geo.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/geojs/0.18.0/geo.min.js"></script>
-->
</head>
<body>
Expand Down
1 change: 0 additions & 1 deletion tutorials/video_transport/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ block mainTutorial
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="../../built/geo.ext.min.js"></script>
<script type="text/javascript" src="../../built/geo.min.js"></script>
</head>
<body>
Expand Down
3 changes: 0 additions & 3 deletions webpack-examples.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const StringReplacePlugin = require('string-replace-webpack-plugin');
var path = require('path');

var base = require('./webpack.config');
var external = require('./external.config');

var rules = base.module.rules.concat([{
test: /\.pug$/,
Expand Down Expand Up @@ -39,8 +38,6 @@ var rules = base.module.rules.concat([{
})]
}]);

rules = rules.concat(external.module.rules);

var plugins = base.plugins;
plugins.push(new StringReplacePlugin());

Expand Down
23 changes: 23 additions & 0 deletions webpack-lean.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// The lean build does not include any of the third-party runtime dependencies, rather
// it assumes they are in the global namespace at runtime.
var config = require('./webpack.base.config');
var merge = require('webpack-merge');

module.exports = merge(config, {
entry: {
'geo.lean': './index.js',
'geo.lean.min': './index.js'
},
externals: {
d3: 'd3',
hammerjs: {
root: 'Hammer',
commonjs: 'hammerjs',
commonjs2: 'hammerjs',
amd: 'hammerjs',
// Since GeoJS's libraryTarget is "umd", defining this (undocumented) external library type
// will allow Webpack to create a better error message if a "hammerjs" import fails
umd: 'hammerjs'
}
}
});
3 changes: 0 additions & 3 deletions webpack-tutorials.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const StringReplacePlugin = require('string-replace-webpack-plugin');
var path = require('path');

var base = require('./webpack.config');
var external = require('./external.config');

var rules = base.module.rules.concat([{
test: /\.pug$/,
Expand Down Expand Up @@ -33,8 +32,6 @@ var rules = base.module.rules.concat([{
})
}]);

rules = rules.concat(external.module.rules);

var plugins = base.plugins;
plugins.push(new StringReplacePlugin());

Expand Down
Loading

0 comments on commit 88bd6ca

Please sign in to comment.