Saturday 28 December 2019

How to import ionic-angular BaseInput to work with both, JIT and AOT compilation?

I'm working with a pretty standard Ionic v3 project setup and trying to extend BaseInput for a custom component. Since it's not exposed through ionic-angular, I'm trying to import it either through as non-UMD,

import { BaseInput } from 'ionic-angular/util/base-input';

or as UMD,

import { BaseInput } from 'ionic-angular/umd/util/base-input';

The former (non-UMD) case works with the JIT compiler, e.g. when running the app through ionic serve. However, when trying to do a prod build (ionic cordova build <platform> --prod), it fails with seemingly unrelated typescript errors ("Cannot determine the module for class [...] in [...]").

Going with the UMD import poth, prod builds (with the AOT compiler) go through without errors, but trying to run the app fails with an error message:

Error: Cannot find module "."
  at webpackMissingModule (webpack:///node_modules/ionic-angular/umd/util/base-input.js:13:24 <- test-config/karma-integration-test-shim.js:180279:69)
  at webpack:///node_modules/ionic-angular/umd/util/base-input.js:13:24 <- test-config/karma-integration-test-shim.js:180279:147
  at Object.<anonymous> (webpack:///node_modules/ionic-angular/umd/util/base-input.js:19:1 <- test-config/karma-integration-test-shim.js:180288:3)
  at __webpack_require__ (webpack:///webpack/bootstrap%20e1799a6a30ca82a9bd77:19 <- test-config/karma-integration-test-shim.js:20:30)
  at Object.<anonymous> (test-config/karma-integration-test-shim.js:180256:92)
[...]

How can I import BaseInput in a way that complies with both, the JIT and the AOT compiler?



from How to import ionic-angular BaseInput to work with both, JIT and AOT compilation?

No comments:

Post a Comment