-
Notifications
You must be signed in to change notification settings - Fork 295
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
bug: rollup inlines external dependency because import path was re-written #101
Comments
Cause explained in angular/angular#16084 Issue tracked by angular/tsickle#376 |
In Angular, there is one place where they set to tsc-wrapped sets it to false: compiler-cli sets it to true: |
See also angular/angular#16152 (back-dating to April...Oo) |
Is it why I get the Is there any work around? |
@avatsaev Possibly yes. Possibly no. Angular CLI's error messaging can be quite verbosive w/o concrete indication of the cause. The above error message often raises when an import cannot be properly resolved. |
Could you please help me out, I've been pulling my hair for 2 days, every time I install my custom built package from an archive or npm, I get this error when I build the host angular app with angular cli:
this is my ng-package.json:
My external dependency is And when I package the lib without
|
Did you try the workaround as described above? {
"lib": {
"entryFile": "public_api.ts",
"externals": {
"@ngx-translate/core": "ngx-translate-core",
"@ngx-translate/core/index": "ngx-translate-core"
}
}
} |
isn't it what I did?
|
Did you add both? If still not working, you could try to check the global token "codemirror" - which one do they use? Seems like they write "CodeMirror" ... is it case sensitive? see #119 If then still not working, you could try to upgrade to When you find the solution, please let us know so we can keep this as documentation on how to configure external libraries. |
So I did add both as you suggested (with 1.2.0):
and got this error:
Thing is, it works without any problems when I run the project with ng serve |
I have the same problem with Mousetrap |
Same problems with @swimlane/ngx-datatable, which is unfortunate because soooo close to having converted my entire manual build process over to jsut ng-packagr + asset bundling |
Same problem with angular-calendar |
Hi all, @avatsaev @ferreirarod @ronnyek @Ks89, I wanted took a look at the ngx-codemirror error. I think it should be representative for what most of you are experiencing. This is what I got:
This is a build success for the library. What exactly is the build error? Can you provide repros? |
It builds no problem, but try to use the resulting pkg in a host angular cli app, then compile the app in prod mode, you’ll get an error |
Sorry. I stopped one step short:
|
Modified //import {CodeMirrorModule} from 'ngx-codemirror';
import { fromTextArea } from 'codemirror/index'; It builds. Then, I modified import { Directive, ElementRef, EventEmitter, Input, NgModule, Output } from '@angular/core';
import { CommonModule } from '@angular/common';
import { fromTextArea } from 'codemirror';
var CodeMirrorDirective = /** @class */ (function () { and import {CodeMirrorModule} from 'ngx-codemirror'; And
I see two possibilities:
|
very true, and there is a lot of these confusing build system err msgs. |
I'm running into a similar situation with a library I'm trying to create with ng-packagr. The library builds fine, but when I try to npm link from a host angular-cli app, I get a similar error. The library is simple and has no peerDependencies besides Using angular 4.4.4, cli 1.4.4, ng-packagr 1.2.1, though I tried a bunch of different combinations to no avail. |
@dherges The library produced by ng-packagr looks structurally similar to
(which seems to be related to the issues above) but that didn't work either. |
You're right, my issue actually looks more like #117. I did encounter the appended |
though not much ng-packagr can do about it, it's causing a lot of confusion and thus it's high prio |
As of the release of angular 4.4.5, this should no longer be an issue due to this fix |
Seems to be working with 4.4.5 on ngx-codemirror |
Is this issue solved by angular/angular#19579 ? I think it is. If yes, this issue can be closed. |
Should the dependency on |
I confirm that now it's working also with Mousetrap. Well done and thank u. |
Let's bump the dependency. |
Closing this issue as it should be solved by the change in Should the same issue re-occur, please verify that you are using the latest version of tsc-wrapped. If then the issue still re-occurs, please let know in this thread! |
This issue has been automatically locked due to inactivity. |
Type of Issue
Description
FESM bundles include inlined external dependencies.
How To Reproduce
Exmaple w/ ngx-translate:
The
ng-package.json
:The source code:
In the
.ng_build
directory, the generated.js
file ends up with the following import:The import path from
@ngx-translate/core
in the source was re-written to@ngx-translate/core/index
, thus theexternals
mapping does not match and rollup inlines the third-party dependency.To confirm the cause, the following setting then produces a good FESM bundle!
FESM Bundle:
Expected Behaviour
Externals dependencies shouldn't be rewritten.
Usage of
lib.externals
inng-package.json
SHOULD BE the TypeScript import path from sources!In above examples:
@ngx-translate/core
.Version Information
The text was updated successfully, but these errors were encountered: