rollup / rollup-plugin-commonjs

This module has moved and is now available at @rollup/plugin-commonjs / https://github.com/rollup/plugins/blob/master/packages/commonjs
MIT License
502 stars 126 forks source link

global is undefined #277

Closed stkevintan closed 6 years ago

stkevintan commented 6 years ago

when I import lunr and trigger the lunr.utils.warn function , the 'warn' will be an error in browser environment. because global is not defined.

lunr.utils.warn = (function (global) {
  /* eslint-disable no-console */
  return function (message) {
    if (global.console && console.warn) {
      console.warn(message);
    }
  }
  /* eslint-enable no-console */
})(this);
stkevintan commented 6 years ago

oh, I know in strict mode , this will be replaced by undefined. wtf....

DanielRuf commented 6 years ago

oh, I know in strict mode , this will be replaced by undefined. wtf....

Right. And here we need something like

if(global === undefined && window !== undefined) global = window

Why was this closed?

johnlim commented 6 years ago

Was there a resolution for this?

stkevintan commented 6 years ago

@johnlim I give up to pack lunr into my bundle resources. just use the old way: script html tag

johnlim commented 6 years ago

@stkevintan Did you consider using webpack instead?

lukastaegert commented 6 years ago

There was a PR in rollup but there were some issues with it so it was stalled. If someone were to pick it up again, this would be great.