-
Notifications
You must be signed in to change notification settings - Fork 12k
Angular 6 app with angular library: ng build
works but ng build --prod
throws "ERROR in ./src/app/app.component.ngfactory.js"
#11392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
After adding the
Now the Please see #11394 . I'm using this library in an external Angular 6 application and even though this build works as expected. It won't work on an external app. |
I have tried this and I cannot replicate any issue. Steps I did,
Output; Alans-iMac:Common alan$ ng build common-lib
Building Angular Package
Building entry point '@canyaio/common-lib'
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 @canyaio/common-lib
Built Angular Package!
- from: /Users/alan/git/Common/projects/common-lib
- to: /Users/alan/git/Common/dist/common-lib
Alans-iMac:Common alan$ ng build --prod
Date: 2018-06-29T15:38:58.467Z
Hash: a6b418e2c27ccdc9ac10
Time: 41160ms
chunk {scripts} scripts.a8d156b92ea2ded28ebf.js (scripts) 13.2 kB [rendered]
chunk {0} runtime.a66f828dca56eeb90e02.js (runtime) 1.05 kB [entry] [rendered]
chunk {1} styles.9e3ca50e8b8e482de370.css (styles) 75 kB [initial] [rendered]
chunk {2} polyfills.2f4a59095805af02bd79.js (polyfills) 59.6 kB [initial] [rendered]
chunk {3} main.20bdf776bfb60813d771.js (main) 635 kB [initial] [rendered] |
Can you check if this has the same effect
|
@alan-agius4 thanks. This build is working as expected now. Would this library work for child modules inside an external Angular 6 app? I'm having trouble with an Angular 6.0.7 app that uses the packaged library. This app has multiple modules However, when I use the same library in an app with just the app.module.ts, it works 🤔 Am I missing something in order to use the library inside child modules? |
There shouldn’t be any difference using this with multiple modules.
Since the issue is now resolved. Please close the issue. Thanks
…On Fri, 29 Jun 2018 at 18:12, Gus ***@***.***> wrote:
@alan-agius4 <https://github.com/alan-agius4> thanks.
This build is working as expected now.
Would this library work for child modules inside an external Angular 6 app?
I'm having trouble with an Angular 6.0.7 app that uses the packaged
library. This app has multiple modules
However, when I use the same library in an app with just the
app.module.ts, it works 🤔
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#11392 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AQv-WriJ6EWnuiTtp3NQbAVnBO6EVTxyks5uBlIFgaJpZM4U6i5F>
.
|
Just for future reference, I made it work by Seems like a cache issue or something |
Incase someone else lands here, I had the same issue but my problem was I prefixed the path with an
As you can see, the generated factory classes are looking for my-library, not @my-library. I just removed the |
After hours messing about with this I found this article stating that the local library package needs to be installed as well as being aliased in The author mentions that the local install can cause problems with |
I had the the same problem. I fixed it by using ng-packagr v3.0.3 instead of v2.4.5 when building the npm-package. |
I fixed this issue by adding the @libname path in the tsconfig.json , under "path" key |
Thanks @daniel-nagy
|
@vimalans thanks... the solution worked for me as well with the similar error...Angular 7 |
Also see this post #10643 (comment) |
Any solution for that issue please? |
These is another way to making build , patha like http://demo.com/professionals/admin/ |
@hari1928 thats almost the same as dev build. The expectation is it to work on Prod/AOT build |
To All, i think this issue is replicable even in a sample project created using CLI Steps | All using Ng CLI WORKS FINENow rename the library entries with alias names & have the paths for aliases resolved in the tsConfig. Now, 'ng build' will work fine but 'ng build --prod' fails. Happy to know if there is something missing/incorrect in the above steps. |
I was able to resolve my issue bu going into *.metadata.json file of that library and making sure "importAs" value is set to the new alias. I'm not sure where is this pulled from? Name tags in package.json is updated correctly. |
Still getting this error despite trying every proposed solution |
@andrewantar ... Can you please share the error, from what i experienced...one of the above should fix the issues... |
I had the same issue with Angular 7. "ng build" was fine but "ng build --prod" failed on 2 files saying it couldn't find the imported @module, even though that same @module was imported on several other files just fine. It turned out removing unused interfaces pulled from the @module fixed the issue. It seems a mix of used and unused interfaces causes the import to fail (with a bad message about the whole file not being found) -- It didn't complain if all imported items were unused, precompiler probably just removed the entire reference. Also, this was a named @module that just exported Interfaces. Other "normal" unused references from other modules were ignored. |
I resolve this error by using the followed command, after building the library: |
help I have a problem problem mark me this error when I put the command Date: 2019-06-26T19:47:29.429Z ERROR in scripts.000eefc49a6f20ab379c.js from Terser |
please help help |
I have same error please someone can help us ??? |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug Report or Feature Request (mark with an
x
)Area
Versions
node v8.10.0
npm 6.1.0
macOS High Sierra
"@angular/core": "^6.0.3",
"@angular/cli": "~6.0.8",
Repro steps
I created an angular library
ng generate library common-lib --prefix=canyalib
Added these components and services to the library module
Exported them in the
public_api.ts
Used the library components successfully in the project app
The
CommonLibModule
is imported in the app.module.tsI run
ng serve
andng build
without errors. But when I runng serve --prod
orng build --prod
. The build fails after the92% ... UglifyTask
:The log given by the failure
Desired functionality
This error won't let me run the app with library modules in a production environment.
Mention any other details that might be useful
If I import the packaged library in an external Angular 6 application, the same happens:
ng serve
orng build
lets the app run without problems.ng serve --prod
orng build --prod
fails.The text was updated successfully, but these errors were encountered: