ng-packagr: bug: rollup inlines external dependency because import path was re-written
Type of Issue
- Bug Report
- Feature Request
Description
FESM bundles include inlined external dependencies.
How To Reproduce
Exmaple w/ ngx-translate:
The ng-package.json:
{
"$schema": "../../node_modules/ng-packagr/lib/ng-package.schema.json",
"lib": {
"entryFile": "public_api.ts",
"externals": {
"@ngx-translate/core": "ngx-translate-core"
}
}
}
The source code:
import { TranslateService } from '@ngx-translate/core';
export class MyLib {
// do stuff with TranslateService
}
In the .ng_build directory, the generated .js file ends up with the following import:
import { TranslateModule, TranslateLoader } from '@ngx-translate/core/index';
The import path from @ngx-translate/core in the source was re-written to @ngx-translate/core/index, thus the externals mapping does not match and rollup inlines the third-party dependency.
To confirm the cause, the following setting then produces a good FESM bundle!
{
"lib": {
"entryFile": "public_api.ts",
"externals": {
"@ngx-translate/core": "ngx-translate-core",
"@ngx-translate/core/index": "ngx-translate-core"
}
}
}
FESM Bundle:
import { TranslateLoader, TranslateModule } from '@ngx-translate/core/index';
Expected Behaviour
Externals dependencies shouldn’t be rewritten.
Usage of lib.externals in ng-package.json SHOULD BE the TypeScript import path from sources!
In above examples: @ngx-translate/core.
Version Information
ng-packagr: v1.0.0-pre.14
node: v8.1.1
@angular: v4.3.3
@ngx-translate/core: v7.1.0
rxjs: 5.4.2
zone.js: 0.8.16
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 31 (26 by maintainers)
Commits related to this issue
- fixed redux/index bug https://github.com/dherges/ng-packagr/issues/101 — committed to HarmoWatch/ngx-redux-core by kay-schecker 7 years ago
Sorry. I stopped one step short: