I’m trying extends all components from ionic for use customized tags - I wish use “my-button” instead of “ion-button”, but keep all features that ionic components already has.
Another thing I want is customize some styles. I want use our design patterns.
But, I’m having some problems build with --prod flag.
Actually, I have the class “MyChip” extending “Chip”:
My problem happen when I export this directive in my module. In dev mode, everything works fine, but when I build with “–prod” flag, simply doesn’t run on mobile, with the message:
Uncaught TypeError: Object prototype may only be an Object or null: undefined
at setPrototypeOf (<anonymous>)
at r (main.js:34)
at main.js:34
at Object.<anonymous> (main.js:34)
at e (main.js:1)
at Object.<anonymous> (main.js:21)
at e (main.js:1)
at Object.<anonymous> (main.js:21)
at e (main.js:1)
at Object.<anonymous> (main.js:21)
If I remove inheritance, app works correctly on device with --prod.
Can anybody help me? What’s the correct way to do that? I just want customize tags and attributes, and too some css (styles).
These. ngc with webpack throws this error if the imports are a little off. So any import of MyChip is suspect. The combination of inheritance and lazy loading might make webpack more annoyed too. The basic idea is that if your component is in ‘component/component’ and you only import it from ‘component’ then it works in most situations, but not in when building for production. And more might be going on because of lazy loading, I don’t know. Anyway, I have to step away, so I might be useless to you. But here’s a sample thread about what might be the issue. The fix might be as simple as changing the order of your imports or exactly how they work, or it might involve digging into Ionic, I don’t know yet. Good luck.
I think this is a bad road to start down. There’s no guarantee that implementation details of Ionic components won’t change from version to version, and you are tying your code very tightly to them.
I have the same issue. It happens when you run a build with --optimizejs parameter, ex:
ionic cordova run android --optimizejs
This is a peace of my main.js bundle.
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b); //<--- ERROR: Uncaught TypeError: Object prototype may only be an Object or null: undefined
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var forms_1 = __webpack_require__(19);
var core_1 = __webpack_require__(0);
var ionic_angular_1 = __webpack_require__(2);
exports.MY_MODULE_VALUE_ACCESSOR = {
provide: forms_1.NG_VALUE_ACCESSOR,
useExisting: core_1.forwardRef(function () { return MyComponent; }),
multi: true
};
The ‘b’ parameter is undefined when the function extendStatics(d, b); is called, the ‘d’ parameter is MyComponent . I created MyComponent from another ionic component. Although I have come up with this problem, I still have not found the solution.
@rafaelquines I know I’m 2 years too late but did you ultimately find a solution to your problem of extending ionic components? I would like to do the same (though in Ionic 4) and am running into problems similar to the ones you described ITT