Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

globals/external not working as expected #1746

Closed
caub opened this issue Nov 20, 2017 · 2 comments
Closed

globals/external not working as expected #1746

caub opened this issue Nov 20, 2017 · 2 comments

Comments

@caub
Copy link

caub commented Nov 20, 2017

In this repo: https://github.com/caub/Leaflet.Terminator/blob/npm/rollup.config.js

  name: 'leaflet.terminator',
  external: ['leaflet'],
  globals: {
    'leaflet': 'L'
  },

output generated: (format :'umd')

(function (global, factory) {
	typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('leaflet')) :
	typeof define === 'function' && define.amd ? define(['leaflet'], factory) :
	(global.leaflet = global.leaflet || {}, global.leaflet.terminator = factory(global.L));
}(this, (function (L) { 'use strict';

L = L && L.hasOwnProperty('default') ? L['default'] : L;
// ........

I expect that L is used in the output, but global.leaflet is still there, so I made this hacky plugin, in the hope rollup has a better way

As you can see, only the UMD header has this issue

I've read the docs, and issues on external/globals, yet I can't figure this

rollup: "^0.51.7"

adrianheine added a commit to adrianheine/rollup that referenced this issue Nov 20, 2017
adrianheine added a commit to adrianheine/rollup that referenced this issue Nov 20, 2017
adrianheine added a commit to adrianheine/rollup that referenced this issue Nov 24, 2017
@caub
Copy link
Author

caub commented Nov 24, 2017

Hmm it'd work if I set name: 'L.terminator', since name is put in https://github.com/rollup/rollup/blob/master/src/finalisers/umd.js#L16, it's a bit magic, but ok

@lukastaegert
Copy link
Member

Hi @caub, did you try @adrianheine 's PR by installing rollup via

npm install adrianheine/rollup#master

? Does it work for you? If so I would put this into the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants