question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

export 'default' (imported as 'core_1') was not found in '@angular/core'

See original GitHub issue

Type 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:closed
  • Created 6 years ago
  • Reactions:5
  • Comments:28 (8 by maintainers)

github_iconTop GitHub Comments

10reactions
avatsaevcommented, Dec 5, 2017

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):

  • Fist step is to figure out which lib is breaking everything so just control+F and look where core is used:

So one of the imports from TimeAgoPipe library is breaking the compilation

  • Project wide search (ctrl+shif+f ‘time-ago-pipe’) I only import from time-ago-pipe lib once:

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.

3reactions
markus-wacommented, Oct 18, 2018

For me this happened because I didn’t have my compilerOptions.module set in tsconfig.json, which resulted in commonjs being used as default (for targets es3 or es5).

Setting it to es6 fixed it for me.

Relevant part:

{
  "compilerOptions": {
    "module": "es6"
  }
}
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found