manfredsteyer / ngx-build-plus

Extend the Angular CLI's default build behavior without ejecting, e. g. for Angular Elements
1.19k stars 136 forks source link

Uncaught TypeError: Cannot read property 'InjectionToken' of undefined/ Uncaught TypeError: Cannot read property 'ɵcrt' of undefined #103

Open suryaprakashgottimukkula opened 5 years ago

suryaprakashgottimukkula commented 5 years ago

I am trying the webpack externals and did the same way as you did in your samples example we are trying to load multiple angular elements on a mfe (micro front end) angular project and i am getting these errors . Can you please help me in resolving these ?

errors

main.js:1 Uncaught TypeError: Cannot read property 'InjectionToken' of undefined at Module.zUnb (main.js:1) at n (main.js:1) at Object.0 (main.js:1) at n (main.js:1) at main.js:1 at main.js:1 zUnb @ main.js:1 n @ main.js:1 0 @ main.js:1 n @ main.js:1 (anonymous) @ main.js:1 (anonymous) @ main.js:1

main.js:1 Uncaught TypeError: Cannot read property 'ɵcrt' of undefined at Module.zUnb (main.js:1) at r (main.js:1) at Object.0 (main.js:1) at r (main.js:1) at main.js:1 at main.js:1

ringodotnl commented 4 years ago

Solved it be adding the packages rxjs, angular etc. in index.html like:


  <!-- Polyfills for Browsers supporting Custom Elements. Needed b/c we downlevel to ES5. See: @webcomponents/custom-elements -->
  <script
    type="text/javascript"
    src="./corelibs/native-shim.js"
  ></script>

  <!-- Polyfills for Browsers not supporting Custom Elements. See: @webcomponents/custom-elements -->
  <script
    type="text/javascript"
    src="./corelibs/custom-elements.min.js"
  ></script>

  <!-- Rx -->
  <script
    type="text/javascript"
    src="./corelibs/rxjs.umd.min.js"
  ></script>

  <!-- Angular Packages -->
  <script
    type="text/javascript"
    src="./corelibs/core.umd.min.js"
  ></script>
  <script>
    ng.core.enableProdMode();
  </script>
  <script
    type="text/javascript"
    src="./corelibs/common.umd.min.js"
  ></script>
  <script
    type="text/javascript"
    src="./corelibs/platform-browser.umd.min.js"
  ></script>
  <script
    type="text/javascript"
    src="./corelibs/elements.umd.min.js"
  ></script>
  <script
    type="text/javascript"
    src="./corelibs/router.umd.min.js"
  ></script>