Skip to content

Commit

Permalink
Fixing noConflict and merge rollup-config (#7855)
Browse files Browse the repository at this point in the history
* fixing noConflict and merge rollup-config

* Fix lint
  • Loading branch information
Falke-Design committed Jan 19, 2022
1 parent 4d63087 commit f3f27b0
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 48 deletions.
30 changes: 18 additions & 12 deletions build/rollup-config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Config file for running Rollup in "normal" mode (non-watch)
// Config file for running Rollup

import rollupGitVersion from 'rollup-plugin-git-version';
import json from '@rollup/plugin-json';
Expand All @@ -7,42 +7,48 @@ import pkg from '../package.json';
import {createBanner} from './banner';

const release = process.env.NODE_ENV === 'release';
const watch = process.argv.indexOf('-w') > -1 || process.argv.indexOf('--watch') > -1;
// Skip the git branch+rev in the banner when doing a release build
const version = release ? pkg.version : `${pkg.version}+${gitRev.branch()}.${gitRev.short()}`;
const banner = createBanner(version);

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

/** @type {import('rollup').RollupOptions} */
export default {
const config = {
input: 'src/Leaflet.js',
output: [
{
file: pkg.main,
format: 'umd',
name: 'L',
name: 'leaflet',
banner: banner,
outro: outro,
sourcemap: true,
freeze: false,
esModule: false
},
}
],
plugins: [
release ? json() : rollupGitVersion()
]
};

if (!watch) {
config.output.push(
{
file: 'dist/leaflet-src.esm.js',
format: 'es',
banner: banner,
sourcemap: true,
freeze: false
}
],
plugins: [
release ? json() : rollupGitVersion()
]
};
);
}
export default config;
27 changes: 0 additions & 27 deletions build/rollup-watch-config.js

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"lint": "eslint .",
"lintfix": "npm run lint -- --fix",
"rollup": "rollup -c build/rollup-config.js",
"watch": "rollup -w -c build/rollup-watch-config.js",
"watch": "rollup -w -c build/rollup-config.js",
"uglify": "uglifyjs dist/leaflet-src.js -c -m -o dist/leaflet.js --source-map filename=dist/leaflet.js.map --source-map content=dist/leaflet-src.js.map --source-map url=leaflet.js.map --comments",
"integrity": "node ./build/integrity.js",
"bundlemon": "bundlemon --subProject no-compression --defaultCompression none && bundlemon --subProject gzip-compression --defaultCompression gzip"
Expand Down
6 changes: 3 additions & 3 deletions spec/karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
var json = require('@rollup/plugin-json');

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

// Karma configuration
module.exports = function (config) {
Expand Down Expand Up @@ -63,7 +63,7 @@ module.exports = function (config) {
],
output: {
format: 'umd',
name: 'L',
name: 'leaflet',
outro: outro,
freeze: false,
},
Expand Down
7 changes: 2 additions & 5 deletions spec/suites/core/GeneralSpec.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
describe('General', function () {
it('noConflict', function () {
var leaflet = L;

after(function () {
L = leaflet;
});

expect(L.noConflict()).to.eql(leaflet);
expect(L).to.eql(undefined);
L = leaflet;
});

it('namespace extension', function () {
Expand Down

0 comments on commit f3f27b0

Please sign in to comment.