Невозможно создать полимерный веб-компонент внутри ионного приложения. - PullRequest
1 голос
/ 07 марта 2019

Я пытаюсь использовать пользовательский компонент Polymer (v3) внутри приложения Ionic (также v3).

Компонент работает нормально, если я работаю с ionic cordova run android.

Но когда я пытаюсь запустить с флагом --prod, проект компилируется и открывается в моем телефоне, но он просто не показывает компонент.

Ошибка, отображаемая в инструментах Chrome Inspect, следующая:

Uncaught TypeError: Failed to construct 'HTMLElement': Please use the 'new' operator, this DOM object contructor cannot be called as a function.

Вот мой package.json:

{
  "name": "testApp",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "start": "ionic-app-scripts serve",
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "lint": "ionic-app-scripts lint"
  },
  "dependencies": {
    "@angular/animations": "4.1.3",
    "@angular/common": "4.1.3",
    "@angular/compiler": "4.1.3",
    "@angular/compiler-cli": "4.1.3",
    "@angular/core": "4.1.3",
    "@angular/forms": "4.1.3",
    "@angular/http": "4.1.3",
    "@angular/platform-browser": "4.1.3",
    "@angular/platform-browser-dynamic": "4.1.3",
    "@babel/core": "^7.3.4",
    "@ionic-native/core": "4.8.0",
    "@ionic-native/device": "4.8.0",
    "@ionic-native/screen-orientation": "4.8.0",
    "@ionic-native/splash-screen": "4.8.0",
    "@ionic-native/status-bar": "4.8.0",
    "@ionic/app-scripts": "2.0.2",
    "@ionic/storage": "2.0.1",
    "cordova-android": "7.0.0",
    "cordova-plugin-device": "^1.1.7",
    "cordova-plugin-ionic-keyboard": "^2.1.3",
    "cordova-plugin-ionic-webview": "^3.1.2",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-statusbar": "^2.4.2",
    "cordova-plugin-whitelist": "^1.3.3",
    "ionic-angular": "3.9.3",
    "ionicons": "3.0.0",
    "rxjs": "5.5.11",
    "sw-toolbox": "3.6.0",
    "tsc-wrapper": "^2.0.0",
    "my-polymer-component": "^1.3.0",
    "zone.js": "0.8.29"
  },
  "devDependencies": {
    "@ionic/app-scripts": "2.0.2",
    "tslint-ionic-rules": "0.0.21",
    "typescript": "2.6.2"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-plugin-whitelist": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-device": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-ionic-webview": {
        "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
      },
      "cordova-plugin-ionic-keyboard": {}
    },
    "platforms": [
      "android"
    ]
  }
}

Я пытался добавить веб-компоненты в мой index.html, но все еще не увенчался успехом.

1 Ответ

0 голосов
/ 12 марта 2019

Мне удалось заставить его работать, добавив polyfill custom-elements-es5-adapter.js из webcomponentsjs

...