You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Run ng g library FirstLibrary -- This will create a library with an alias of "FirstLibrary" and package name of "first-library"
Run ng g library SecondLibrary
Go to second-library.service.ts.
Add import { FirstLibraryService } from 'FirstLibrary';
Add firstLibraryService: FirstLibraryService as an argument to the constructor of the SecondLibraryService for dependency injection
Run ng build FirstLibrary
Run ng build SecondLibrary
Go to any of the built second-library files (e.g. "dist/second-library/fesm2015/second-library.js") and notice something like the following two lines at the top of the file:
The second line is the bad import that was added during the build process and uses the package name of the imported library rather than the library's alias. It will cause an obvious error when imported into the main application, i.e. Module not found: 'first-library'
The log given by the failure
There isn't really a useful log to provide here, but this is the build log for SecondLibrary, which just seems to show a standard build process:
ng build SecondLibrary
Building Angular Package
Building entry point 'second-library'
Rendering Stylesheets
Rendering Templates
Compiling TypeScript sources through ngc
Bundling to FESM2015
Bundling to FESM5
Bundling to UMD
Minifying UMD bundle
Copying declaration files
Writing package metadata
Removing scripts section in package.json as it's considered a potential security vulnerability.
Built second-library
Built Angular Package!
- from: C:\...\App\projects\second-library
- to: C:\...\App\dist\second-library
Desired functionality
Import and injection without a bad duplicate import. Preferably in a way that still allows for a different library alias than the package name.
Mention any other details that might be useful
Sometimes in addition to this problem, during the build process of the second library I will get something like:
No name was provided for external module 'FirstLibrary' in output.globals – guessing 'firstLibrary'
No name was provided for external module 'first-library' in output.globals – guessing 'i1'
But this doesn't happen in the minimal reproduction above.
The text was updated successfully, but these errors were encountered:
Hello, the root cause has been fixed with this PR #11599.. As library names should be the same as the aliases in the tsconfig, Thus in your case it should be first-library
"first-library": ["dist/first-library"],
Regarding the warning that you are getting No name was provided for external module..., that is expected and you need to configure the UMD modules IDs in ng-package.json.
Bug Report or Feature Request (mark with an
x
)Command (mark with an
x
)Versions
Repro steps
The second line is the bad import that was added during the build process and uses the package name of the imported library rather than the library's alias. It will cause an obvious error when imported into the main application, i.e. Module not found: 'first-library'
The log given by the failure
There isn't really a useful log to provide here, but this is the build log for SecondLibrary, which just seems to show a standard build process:
Desired functionality
Import and injection without a bad duplicate import. Preferably in a way that still allows for a different library alias than the package name.
Mention any other details that might be useful
Sometimes in addition to this problem, during the build process of the second library I will get something like:
But this doesn't happen in the minimal reproduction above.
The text was updated successfully, but these errors were encountered: