export 'default' (imported as 'core_1') was not found in '@angular/core'
See original GitHub issueType of Issue
[x] Bug Report
[ ] Feature Request
Versions
ng-packagr: v1.5.0-rc.1
node: v6.11.0
@angular: v4.4.6
rxjs: 5.5.0
zone.js: 0.8.18
Description
When packaging my library i get the following warning:
'default' is not exported by 'node_modules\redux\es\index.js'
'default' is imported from external module 'rxjs/add/operator/let' but never used
'default' is imported from external module 'rxjs/add/operator/distinctUntilChanged' but n
'default' is imported from external module 'rxjs/add/operator/map' but never used
'default' is imported from external module 'rxjs/add/operator/filter' but never used
'default' is imported from external module 'rxjs/add/operator/switchMap' but never used
and when using my library in an application, i get the following warnings:
"export 'default' (imported as 'core_1') was not found in '@angular/core'
Here’s my setup: ng-package.json
{
"$schema": "./node_modules/ng-packagr/ng-package.schema.json",
"src": "lib",
"dest": "dist/lib",
"workingDirectory": ".ng_build",
"lib": {
"entryFile": "public_api.ts",
"externals": {
"oidc-client": "./node_modules/oidc-client/dist/oidc-client.min.js",
"rxjs/add/operator/let": "Rx.Observable.prototype"
}
}
}
public_api.ts_
export * from './my-lib/my-lib.module'
tsconfig:
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/src",
"baseUrl": "src",
"paths": {
"my-lib": [
"dist/lib"
]
},
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}
I haven’t been able to reproduce the issue in an example app and I cannot make any sense of this but I hope you might. Thanks
Issue Analytics
- State:
- Created 6 years ago
- Reactions:5
- Comments:28 (8 by maintainers)
Top Results From Across the Web
export 'default' (imported as 'core_1') was not found in ...
EUREKA. Fixed by playing with the tsconfig in both the library, and the angular project : tsconfig.lib.json. { "extends": "../.
Read more >ERROR - export 'default' (imported as 'core') was not found in ...
I will try to get a simple repo going to reproduce. The library is just a single angular component generated from CLI. We...
Read more >Export 'Default' (Imported As 'Core_1') Was Not Found In ...
These functions are exposed via the global ng namespace variable automatically when you import from @angular/core and run your application in development ...
Read more >NG0301: Export not found! - Angular
For example, if the export not found is ngForm , we need to import FormsModule and declare it in the list of imports...
Read more >export 'render' (imported as 'render') was not found - You.com
The reason this is happening is because in Vue 2, Vue provides a default export export default vue , which allows BootstrapVue to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think it’s due to some third party libraries not respecting the Angular Library Format, so the imports you use from the lib, screws with the angular compiler (or webpack).
Here a solution I’ve found to debug, find out which lib breaks the transpilation, and fix the problem.
Suppose I have my-lib project that compiles with ng-packagr into dist/lib folder
After compilation in
dist/lib/my-lib.js
there is a problem with imports (core is not imported correctly):So one of the imports from TimeAgoPipe library is breaking the compilation
So the solution in this case is to add the entire import path into externals in ng-package.json (if you have other imports from this lib add them too):
After which everything compiles fine:
The most confusing part of this bug is not knowing where the error comes from, because the ng-packagr packages the lib just fine, without warnings or spitting out an error.
For me this happened because I didn’t have my
compilerOptions.module
set intsconfig.json
, which resulted incommonjs
being used as default (for targetses3
ores5
).Setting it to
es6
fixed it for me.Relevant part: