Skip to content

Instantly share code, notes, and snippets.

@w8r
Created January 10, 2018 10:20
Show Gist options
  • Save w8r/95078f2d4ed8808d2765d2659008c929 to your computer and use it in GitHub Desktop.
Save w8r/95078f2d4ed8808d2765d2659008c929 to your computer and use it in GitHub Desktop.

Revisions

  1. @tschaub tschaub revised this gist Nov 12, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions package.json
    Original file line number Diff line number Diff line change
    @@ -6,12 +6,12 @@
    "build": "rollup --config rollup.config.js"
    },
    "devDependencies": {
    "rollup": "0.51.3",
    "rollup": "^0.51.3",
    "rollup-plugin-closure-compiler-js": "^1.0.5",
    "rollup-plugin-commonjs": "^8.2.6",
    "rollup-plugin-node-resolve": "^3.0.0"
    },
    "dependencies": {
    "ol": "4.0.0"
    "ol": "^4.1.0"
    }
    }
  2. @tschaub tschaub revised this gist Nov 10, 2017. 2 changed files with 8 additions and 8 deletions.
    10 changes: 5 additions & 5 deletions package.json
    Original file line number Diff line number Diff line change
    @@ -6,12 +6,12 @@
    "build": "rollup --config rollup.config.js"
    },
    "devDependencies": {
    "rollup": "^0.38.0",
    "rollup-plugin-closure-compiler-js": "^1.0.3",
    "rollup-plugin-commonjs": "^6.0.1",
    "rollup-plugin-node-resolve": "^2.0.0"
    "rollup": "0.51.3",
    "rollup-plugin-closure-compiler-js": "^1.0.5",
    "rollup-plugin-commonjs": "^8.2.6",
    "rollup-plugin-node-resolve": "^3.0.0"
    },
    "dependencies": {
    "ol": "3.21.0-beta.14"
    "ol": "4.0.0"
    }
    }
    6 changes: 3 additions & 3 deletions rollup.config.js
    Original file line number Diff line number Diff line change
    @@ -3,9 +3,9 @@ import common from 'rollup-plugin-commonjs';
    import node from 'rollup-plugin-node-resolve';

    module.exports = {
    entry: 'main.js',
    targets: [
    {dest: 'bundle.js', format: 'es'}
    input: 'main.js',
    output: [
    {file: 'bundle.js', format: 'es'}
    ],
    plugins: [
    node(),
  3. @tschaub tschaub revised this gist Jan 3, 2017. 3 changed files with 3 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion _readme_.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    This example demonstrates how the [`ol@beta` package](https://www.npmjs.com/package/ol) can be used with Rollup and the Closure Compiler in advanced mode.

    Note that the Compiler creates a while to run.
    Note that the Compiler takes a while to run.

    Clone the project.

    1 change: 1 addition & 0 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>Using OpenLayers with Rollup and the Closure Compiler</title>
    <link rel="stylesheet" href="https://openlayers.org/en/latest/css/ol.css" type="text/css">
    <style>
    2 changes: 1 addition & 1 deletion package.json
    Original file line number Diff line number Diff line change
    @@ -12,6 +12,6 @@
    "rollup-plugin-node-resolve": "^2.0.0"
    },
    "dependencies": {
    "ol": "3.21.0-beta.13"
    "ol": "3.21.0-beta.14"
    }
    }
  4. @tschaub tschaub revised this gist Jan 2, 2017. 3 changed files with 4 additions and 3 deletions.
    2 changes: 1 addition & 1 deletion _readme_.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    This example demonstrates how the [`ol@beta` package](https://www.npmjs.com/package/ol) can be used with Rollup and the Closure Compiler in advanced mode.

    Note that the Compiler creates a lot of noise. This needs to be fixed.
    Note that the Compiler creates a while to run.

    Clone the project.

    2 changes: 1 addition & 1 deletion package.json
    Original file line number Diff line number Diff line change
    @@ -12,6 +12,6 @@
    "rollup-plugin-node-resolve": "^2.0.0"
    },
    "dependencies": {
    "ol": "3.21.0-beta.11"
    "ol": "3.21.0-beta.13"
    }
    }
    3 changes: 2 additions & 1 deletion rollup.config.js
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,8 @@ module.exports = {
    node(),
    common(),
    closure({
    compilationLevel: 'ADVANCED'
    compilationLevel: 'ADVANCED',
    warningLevel: 'QUIET'
    })
    ]
    };
  5. @tschaub tschaub revised this gist Dec 28, 2016. 2 changed files with 3 additions and 3 deletions.
    4 changes: 2 additions & 2 deletions _readme_.md
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    # OpenLayers, Rollup, and Closure Compiler

    This example demonstrates how the [`ol` package](https://www.npmjs.com/package/ol) can be used with Rollup and the Closure Compiler in advanced mode.
    This example demonstrates how the [`ol@beta` package](https://www.npmjs.com/package/ol) can be used with Rollup and the Closure Compiler in advanced mode.

    Note that the Compiler creates a lot of noise.
    Note that the Compiler creates a lot of noise. This needs to be fixed.

    Clone the project.

    2 changes: 1 addition & 1 deletion index.html
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    <!DOCTYPE html>
    <html>
    <head>
    <title>Using OpenLayers with Rollup</title>
    <title>Using OpenLayers with Rollup and the Closure Compiler</title>
    <link rel="stylesheet" href="https://openlayers.org/en/latest/css/ol.css" type="text/css">
    <style>
    html, body {
  6. @tschaub tschaub revised this gist Dec 28, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion _readme_.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # OpenLayers, Rollup, and Closure Compiler

    This example demonstrates how the `ol` package can be used with Rollup and the Closure Compiler in advanced mode.
    This example demonstrates how the [`ol` package](https://www.npmjs.com/package/ol) can be used with Rollup and the Closure Compiler in advanced mode.

    Note that the Compiler creates a lot of noise.

  7. @tschaub tschaub revised this gist Dec 28, 2016. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions rollup.config.js
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    const closure = require('rollup-plugin-closure-compiler-js');
    const common = require('rollup-plugin-commonjs');
    const node = require('rollup-plugin-node-resolve');
    import closure from 'rollup-plugin-closure-compiler-js';
    import common from 'rollup-plugin-commonjs';
    import node from 'rollup-plugin-node-resolve';

    module.exports = {
    entry: 'main.js',
  8. @tschaub tschaub revised this gist Dec 28, 2016. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion rollup.config.js
    Original file line number Diff line number Diff line change
    @@ -10,6 +10,8 @@ module.exports = {
    plugins: [
    node(),
    common(),
    closure()
    closure({
    compilationLevel: 'ADVANCED'
    })
    ]
    };
  9. @tschaub tschaub revised this gist Dec 28, 2016. 2 changed files with 7 additions and 28 deletions.
    2 changes: 1 addition & 1 deletion package.json
    Original file line number Diff line number Diff line change
    @@ -6,8 +6,8 @@
    "build": "rollup --config rollup.config.js"
    },
    "devDependencies": {
    "google-closure-compiler-js": "^20161201.0.0",
    "rollup": "^0.38.0",
    "rollup-plugin-closure-compiler-js": "^1.0.3",
    "rollup-plugin-commonjs": "^6.0.1",
    "rollup-plugin-node-resolve": "^2.0.0"
    },
    33 changes: 6 additions & 27 deletions rollup.config.js
    Original file line number Diff line number Diff line change
    @@ -1,36 +1,15 @@
    const compile = require('google-closure-compiler-js').compile;
    const logger = require('google-closure-compiler-js/logger');
    const nodeResolve = require('rollup-plugin-node-resolve');
    const commonJs = require('rollup-plugin-commonjs');
    const closure = require('rollup-plugin-closure-compiler-js');
    const common = require('rollup-plugin-commonjs');
    const node = require('rollup-plugin-node-resolve');

    module.exports = {
    entry: 'main.js',
    targets: [
    {dest: 'bundle.js', format: 'es'}
    ],
    plugins: [
    nodeResolve(),
    commonJs(),
    {
    name: 'closure-compiler-js',
    transformBundle: function(code) {
    const flags = {
    createSourceMap: true,
    jsCode: [{
    src: code
    }],
    compilationLevel: 'ADVANCED'
    };
    const output = compile(flags);
    logger(flags, output);
    if (output.errors.length) {
    throw new Error(`Compilation Errors (${output.errors.length})`);
    }
    return {
    code: output.compiledCode,
    map: output.sourceMap
    };
    }
    }
    node(),
    common(),
    closure()
    ]
    };
  10. @tschaub tschaub revised this gist Dec 28, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion _readme_.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # OpenLayers + Rollup
    # OpenLayers, Rollup, and Closure Compiler

    This example demonstrates how the `ol` package can be used with Rollup and the Closure Compiler in advanced mode.

  11. @tschaub tschaub revised this gist Dec 28, 2016. 2 changed files with 24 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions .gitignore
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    /node_modules/
    bundle.js
    22 changes: 22 additions & 0 deletions _readme_.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    # OpenLayers + Rollup

    This example demonstrates how the `ol` package can be used with Rollup and the Closure Compiler in advanced mode.

    Note that the Compiler creates a lot of noise.

    Clone the project.

    git clone [email protected]:32a5692bedac5254da24fa3b12072f35.git ol-rollup-closure

    Install the project dependencies.

    cd ol-rollup-closure
    npm install

    Create a bundle for the browser.

    npm run build

    Open `index.html` to see the result.

    open index.html
  12. @tschaub tschaub created this gist Dec 28, 2016.
    23 changes: 23 additions & 0 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    <!DOCTYPE html>
    <html>
    <head>
    <title>Using OpenLayers with Rollup</title>
    <link rel="stylesheet" href="https://openlayers.org/en/latest/css/ol.css" type="text/css">
    <style>
    html, body {
    margin: 0;
    height: 100%;
    }
    #map {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 100%;
    }
    </style>
    </head>
    <body>
    <div id="map"></div>
    <script src="./bundle.js"></script>
    </body>
    </html>
    19 changes: 19 additions & 0 deletions main.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    import Map from 'ol/map';
    import View from 'ol/view';
    import TileLayer from 'ol/layer/tile';
    import XYZ from 'ol/source/xyz';

    new Map({
    target: 'map',
    layers: [
    new TileLayer({
    source: new XYZ({
    url: 'https://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png'
    })
    })
    ],
    view: new View({
    center: [0, 0],
    zoom: 2
    })
    });
    17 changes: 17 additions & 0 deletions package.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    {
    "name": "ol-rollup-closure",
    "version": "1.0.0",
    "description": "Example using OpenLayers with Rollup and Closure Compiler",
    "scripts": {
    "build": "rollup --config rollup.config.js"
    },
    "devDependencies": {
    "google-closure-compiler-js": "^20161201.0.0",
    "rollup": "^0.38.0",
    "rollup-plugin-commonjs": "^6.0.1",
    "rollup-plugin-node-resolve": "^2.0.0"
    },
    "dependencies": {
    "ol": "3.21.0-beta.11"
    }
    }
    36 changes: 36 additions & 0 deletions rollup.config.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    const compile = require('google-closure-compiler-js').compile;
    const logger = require('google-closure-compiler-js/logger');
    const nodeResolve = require('rollup-plugin-node-resolve');
    const commonJs = require('rollup-plugin-commonjs');

    module.exports = {
    entry: 'main.js',
    targets: [
    {dest: 'bundle.js', format: 'es'}
    ],
    plugins: [
    nodeResolve(),
    commonJs(),
    {
    name: 'closure-compiler-js',
    transformBundle: function(code) {
    const flags = {
    createSourceMap: true,
    jsCode: [{
    src: code
    }],
    compilationLevel: 'ADVANCED'
    };
    const output = compile(flags);
    logger(flags, output);
    if (output.errors.length) {
    throw new Error(`Compilation Errors (${output.errors.length})`);
    }
    return {
    code: output.compiledCode,
    map: output.sourceMap
    };
    }
    }
    ]
    };