ng-packagr / ng-packagr

Compile and package Angular libraries in Angular Package Format (APF)
MIT License
1.84k stars 298 forks source link

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

Closed floydspace closed 6 years ago

floydspace commented 6 years ago

Type of Issue

[ ] Bug Report
[ ] Feature Request
[*] I'm stuck

Description

What could be the reson of the issue:

WARNING in ./node_modules/@scope/common/@scope/common.es5.js
72496:41-45 "export 'default' (imported as 'core') was not found in '@angular/core'
    at HarmonyImportSpecifierDependency._getErrors (C:\Projects\SCOPE\scope_concrete\node_modules\webpack\lib\dependencies\HarmonyImportSpecifierDependency.js:65:15)
    at HarmonyImportSpecifierDependency.getWarnings (C:\Projects\SCOPE\scope_concrete\node_modules\webpack\lib\dependencies\HarmonyImportSpecifierDependency.js:39:15)
    at Compilation.reportDependencyErrorsAndWarnings (C:\Projects\SCOPE\scope_concrete\node_modules\webpack\lib\Compilation.js:703:24)
    at Compilation.finish (C:\Projects\SCOPE\scope_concrete\node_modules\webpack\lib\Compilation.js:561:9)
    at applyPluginsParallel.err (C:\Projects\SCOPE\scope_concrete\node_modules\webpack\lib\Compiler.js:506:17)
    at C:\Projects\SCOPE\scope_concrete\node_modules\tapable\lib\Tapable.js:289:11
    at _addModuleChain (C:\Projects\SCOPE\scope_concrete\node_modules\webpack\lib\Compilation.js:507:11)
    at processModuleDependencies.err (C:\Projects\SCOPE\scope_concrete\node_modules\webpack\lib\Compilation.js:477:14)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)
 @ ./node_modules/@scope/common/@scope/common.es5.js
 @ ./src/app/app.component.ts
 @ ./src/app/app.module.ts
 @ ./src/main.ts
 @ multi ./src/main.ts

How To Reproduce

I'm not sure how. All was done as in ng-packaged repo. Please let me know what provide else.

Version Information

ng-packagr: v1.5.1
node: v8.6.0

Here is my package.json:

{
  "name": "scope-concrete",
  "version": "0.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "ng": "ng",
    "link:common": "cd common && npm ln && cd .. && npm ln @scope/common",
    "start": "npm run link:common && ng serve",
    "start:dev": "npm run start -- --env=dev",
    "start:local": "npm run start -- --env=local",
    "add:common": "rimraf node_modules/@scope && yarn add file:./dist/common",
    "build": "npm run package && yarn add:common && ng build --prod --aot=false",
    "build:dev": "npm run build -- --env=dev",
    "test": "ng test",
    "pree2e": "webdriver-manager update --standalone false --gecko false",
    "e2e": "protractor",
    "package": "ng-packagr"
  },
  "private": true,
  "dependencies": {
    "@agm/core": "~1.0.0-beta.1",
    "@angular/animations": "^4.4.6",
    "@angular/cdk": "2.0.0-beta.11",
    "@angular/common": "^4.4.6",
    "@angular/compiler": "^4.4.6",
    "@angular/core": "^4.4.6",
    "@angular/flex-layout": "2.0.0-beta.9",
    "@angular/forms": "^4.4.6",
    "@angular/http": "^4.4.6",
    "@angular/material": "2.0.0-beta.11",
    "@angular/platform-browser": "^4.4.6",
    "@angular/platform-browser-dynamic": "^4.4.6",
    "@angular/platform-server": "^4.4.6",
    "@angular/router": "^4.4.6",
    "@floydspace/ngx-validation": "^1.0.3",
    "@ngrx/store": "^4.0.3",
    "@ngrx/store-devtools": "^4.0.0",
    "@types/lodash": "^4.14.77",
    "angular2-text-mask": "^8.0.3",
    "angulartics2": "~3.0.0",
    "bootstrap": "^4.0.0-alpha.6",
    "core-js": "^2.5.0",
    "font-awesome": "^4.7.0",
    "hammerjs": "^2.0.8",
    "lodash": "^4.17.4",
    "md2": "0.0.28",
    "moment": "^2.18.1",
    "mydatepicker": "^2.0.27",
    "ng2-page-scroll": "^4.0.0-beta.11",
    "ngrx-store-localstorage": "^0.2.2",
    "ngx-clipboard": "^8.1.1",
    "ngx-sharebuttons": "^3.0.0",
    "primeng": "^4.1.3",
    "rxjs": "^5.4.2",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.7.2"
  },
  "devDependencies": {
    "@angular/cli": "^1.5.0",
    "@angular/compiler-cli": "^4.4.6",
    "@types/google.analytics": "0.0.35",
    "@types/jasmine": "2.5.38",
    "@types/node": "^6.0.42",
    "codelyzer": "~2.0.0-beta.1",
    "jasmine-core": "2.5.2",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "1.2.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-remap-istanbul": "^0.2.1",
    "ng-packagr": "^1.5.1",
    "protractor": "~4.0.13",
    "rimraf": "^2.6.2",
    "ts-node": "1.2.1",
    "tslint": "^4.3.0",
    "typescript": "~2.3.3",
    "webpack": "^3.8.1"
  }
}
floydspace commented 6 years ago

The issue was in the angular2-text-mask lib. Not sure why. Perhaps because of it has angular 2 dependencies. Will have to fork it. Anyway, thank you for the great tool.

sshraki commented 6 years ago

where this tool i have same problem

floydspace commented 6 years ago

@sshraki I mean ng-packagr is a great tool. To resolve the issue you should add all your external dependencies to lib.externals in ng-package.json. Check each of them in your package.json one by one to determine which one causes the issue. hope it helps.

Pat-Lovelace commented 6 years ago

As @F1oyd said and following the solution suggested by @avatsaev in the issue https://github.com/dherges/ng-packagr/issues/210 , I was able to build without errors adding angular2-text-mask

to lib.externals in ng-package.json

{
    "$schema": "./node_modules/ng-packagr/ng-package.schema.json",
    "lib": {
        "entryFile": "public_api.ts",
        "externals": {
            "lodash": "./node_modules/lodash/index.js",
            "angular2-text-mask": "angular2-text-mask"
        }
    }
}
github-actions[bot] commented 4 years ago

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

This action has been performed automatically by a bot.