systemjs / builder

SystemJS build tool
MIT License
465 stars 122 forks source link

Error: (SystemJS) global is not defined #780

Closed karlhaas closed 7 years ago

karlhaas commented 7 years ago

I'm using Version 0.15.35 and SystemJS version 0.19.42 and when bundling an AoT compiled version of the latest ng2-bootstrap release (1.4.0), global is not defined. I can solve the problem by editing the bundle manually as described in https://github.com/valor-software/ng2-bootstrap/issues/1723

I don't know if this is a bug of ngc, ng2-bootstrap or the builder.

guybedford commented 7 years ago

I don't think this is SystemJS - SystemJS just doesn't provide a global binding to browser ES modules, which is correct.

I think that project is assuming an ES module -> CJS or ES module -> Rollup -> CJS process, where the assumption of the final build step is to provide a global binding.

They should really be importing the global as a common dependency, where it is defined with a universal form such as const _global = typeof self !== 'undefined' ? self : global; export { _global as global }

karlhaas commented 7 years ago

@guybedford thx for your comment! do you know a possible workaround?

valorkin commented 7 years ago

not having a global object looks strange https://developer.mozilla.org/en-US/docs/Glossary/Global_object