webpack and angular-cli support
See original GitHub issueBreeze wraps its definition in a function and sees “this” as its global variables. For my understanding, this does not work in combination with angular-cli. angular-cli uses uses webpack and it looks like “this” is an empty object instead of the global namespace when using webpack. The result is, that breeze is unable to find any depending library like OData (datajs).
My (very) dirty fix: breeze.debug.js ` (function (global, definition) { var def = function(){ return definition(global); };
// CommonJS
if (typeof exports === "object" && typeof module === "object") {
**global = window;**
module.exports = def();
// RequireJS
} else if (typeof define === "function" && define["amd"]) {
define(def);
// <script>
} else {
breeze = def();
}
})(this, function (global) { … `
I found some other workarrounds in combination with webpack, e.g. this: http://stackoverflow.com/questions/41119357/how-to-configure-webpack-to-support-global-window-for-breeze-clientdatajs
The problem with angular-cli is, that it does not and will not expose the webpack configuration, so this is no solution.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:7 (6 by maintainers)
Top GitHub Comments
@marcelgood, I also had the same issue when using Angular CLI with BreezeJS & datajs.
in
__requireLibCore
function, it’s checking the availability of the necessary libraries by usingglobal.window
but somehow in Angular CLI project,global
is just an empty object at that point and it throwsUnable to initialize OData. Needed to support remote OData services
error.I just created a demo project that solves the issue by tweaking
breeze.base.debug.js
itself, which is of course not the proper way of fixing it: https://github.com/forCrowd/Labs-AngularCLI-BreezeJSAlso I had to modify
package.json
to refer tobreeze.base.debug.js
instead ofbreeze.debug.js
.“Readme” also contains how to see the error but let me know if you encounter any issue.
Update: Created a separate issue and updated the demo app Issue: https://github.com/Breeze/breeze.js/issues/221 Demo app: https://github.com/forCrowd/Labs-AngularCLI-BreezeJS
@coni2k thanks! This solution worked for me. It’s not the best to have to live patch a library like this, but it’s better to do this than to modify breeze-client directly.
@marcelgood I believe this rollup PR if completed would fix this problem and you should be able to update to the latest rollup and solve this problem properly.
https://github.com/rollup/rollup/pull/2274
Edit: I had some issues with Q even with this change and had to set it later. If someone runs into the same issue, try adding the following to your initialization: