Skip to content

Commit

Permalink
add pkg.module (Leaflet#6021)
Browse files Browse the repository at this point in the history
* add pkg.module version

* get tests to pass

* export noConflict
  • Loading branch information
Rich-Harris authored and mourner committed Feb 1, 2018
1 parent d3175e8 commit d188cc5
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 20 deletions.
35 changes: 27 additions & 8 deletions build/rollup-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
import rollupGitVersion from 'rollup-plugin-git-version'
import json from 'rollup-plugin-json'
import gitRev from 'git-rev-sync'
import pkg from '../package.json'

let version = require('../package.json').version;
let {version} = pkg;
let release;

// Skip the git branch+rev in the banner when doing a release build
Expand All @@ -23,15 +24,33 @@ const banner = `/* @preserve
*/
`;

const outro = `var oldL = window.L;
exports.noConflict = function() {
window.L = oldL;
return this;
}
// Always export us to window global (see #2364)
window.L = exports;`;

export default {
input: 'src/Leaflet.js',
output: {
file: 'dist/leaflet-src.js',
format: 'umd',
name: 'L',
banner: banner,
sourcemap: true
},
output: [
{
file: pkg.main,
format: 'umd',
name: 'L',
banner: banner,
outro: outro,
sourcemap: true
},
{
file: pkg.module,
format: 'es',
banner: banner,
sourcemap: true
}
],
legacy: true, // Needed to create files loadable by IE8
plugins: [
release ? json() : rollupGitVersion()
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"uglify-js": "~3.0.26"
},
"main": "dist/leaflet-src.js",
"module": "dist/leaflet-src.esm.js",
"style": "dist/leaflet.css",
"files": [
"dist",
Expand Down
12 changes: 11 additions & 1 deletion spec/karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
var json = require('rollup-plugin-json');

const outro = `var oldL = window.L;
exports.noConflict = function() {
window.L = oldL;
return this;
}
// Always export us to window global (see #2364)
window.L = exports;`;

// Karma configuration
module.exports = function (config) {

Expand Down Expand Up @@ -50,7 +59,8 @@ module.exports = function (config) {
json()
],
format: 'umd',
name: 'L'
name: 'L',
outro: outro
},

// test results reporter to use
Expand Down
11 changes: 0 additions & 11 deletions src/Leaflet.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,5 @@ export * from './layer/index';
// map
export * from './map/index';

// misc

var oldL = window.L;
export function noConflict() {
window.L = oldL;
return this;
}

// Always export us to window global (see #2364)
window.L = exports;

import {freeze} from './core/Util';
Object.freeze = freeze;

0 comments on commit d188cc5

Please sign in to comment.