3

I forked an angular lib, added a new subfolder in projects/keycloak-angular/src/lib/core which has a .js and .d.ts file that exports a namespace. It is imported into two existing files to expand functionality.

When running npm run build I get the following error:

Building Angular Package
Building entry point 'keycloak-angular'
Rendering Stylesheets
Rendering Templates
Compiling TypeScript sources through ngc
Bundling to FESM2015

BUILD ERROR
Could not resolve '../keycloak-authz/keycloak-authz' from dist/keycloak-angular/esm2015/lib/core/services/keycloak.service.js
Error: Could not resolve '../keycloak-authz/keycloak-authz' from dist/keycloak-angular/esm2015/lib/core/services/keycloak.service.js
    at error (/Users/cen/git/petrol-keycloak-angular/node_modules/rollup/dist/rollup.js:199:15)
    at /Users/cen/git/petrol-keycloak-angular/node_modules/rollup/dist/rollup.js:20784:25

The error is exactly what it says: it cannot resolve the import because the newly added files are not copied to dist folder. Vscode "intellisense" resolves the imports just fine in the src folder.

I checked tsconfig, angular config and ng-package config to try and figure out if the existing files are specified somehow for inclusion but I can't find anything. I also found this issue which sounds very similar to mine and might be connected.

Why are my additions left out from the build/package phase?

cen
  • 2,873
  • 3
  • 31
  • 56
  • 1
    Did you find a solution to this issue? I am facing the same – Shijil Narayanan Nov 13 '18 at 13:22
  • 3
    @ShijilNarayan no I did not. For some reason it does not like the .js and .d.ts combo. I had to rewrite the .js file into regular typescript class. – cen Nov 13 '18 at 14:10
  • same trouble... using ng-packagr assets doesn't helped us because the assets copying is done WAAAAAAAY after the FESM2015 bundling. Not sure why the assets are not copied earlier. – glihm Sep 29 '21 at 04:28

0 Answers0