Skip to content
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

Circular dependencies generated via flatModuleOutFile #656

Closed
dherges opened this issue Mar 3, 2018 · 3 comments · Fixed by #2051
Closed

Circular dependencies generated via flatModuleOutFile #656

dherges opened this issue Mar 3, 2018 · 3 comments · Fixed by #2051
Labels

Comments

@dherges
Copy link
Contributor

dherges commented Mar 3, 2018

Type of Issue

[x] Bug Report
[ ] Feature Request

Description

In package.json:

{
  "name": "ngxs",
  "ngPackage": {
    "lib": {
      "entryFile": "src/index.ts"
    }
  }
}

The sources contain a file src/ngx.ts.

It’s a bug in ng-packagr and/or ngc. What basically happens is:

  • ngc generates a src/ngxs source file that re-exports symbols from src/index.
  • src/index imports from src/ngxs (the original source file)
  • During compilation (more precise in ng.createProgram()), src/ngxs is then resolved to the generated source file rather than the original source file. Since the generated file src/ngxs imports from src/index and src/index imports from src/ngxs there is a circular dependency.

Resulting error is:

BUILD ERROR
Maximum call stack size exceeded
RangeError: Maximum call stack size exceeded
    at MetadataBundler.exportAll (/Users/David/Projects/github/amcdnl/ngxs/node_modules/@angular/compiler-cli/src/metadata/bundler.js:71:52)
    at MetadataBundler.exportAll (/Users/David/Projects/github/amcdnl/ngxs/node_modules/@angular/compiler-cli/src/metadata/bundler.js:108:44)
    at MetadataBundler.exportAll (/Users/David/Projects/github/amcdnl/ngxs/node_modules/@angular/compiler-cli/src/metadata/bundler.js:108:44)
    at MetadataBundler.exportAll (/Users/David/Projects/github/amcdnl/ngxs/node_modules/@angular/compiler-cli/src/metadata/bundler.js:108:44)
    at MetadataBundler.exportAll (/Users/David/Projects/github/amcdnl/ngxs/node_modules/@angular/compiler-cli/src/metadata/bundler.js:108:44)
    at MetadataBundler.exportAll (/Users/David/Projects/github/amcdnl/ngxs/node_modules/@angular/compiler-cli/src/metadata/bundler.js:108:44)
    at MetadataBundler.exportAll (/Users/David/Projects/github/amcdnl/ngxs/node_modules/@angular/compiler-cli/src/metadata/bundler.js:108:44)
    at MetadataBundler.exportAll (/Users/David/Projects/github/amcdnl/ngxs/node_modules/@angular/compiler-cli/src/metadata/bundler.js:108:44)
    at MetadataBundler.exportAll (/Users/David/Projects/github/amcdnl/ngxs/node_modules/@angular/compiler-cli/src/metadata/bundler.js:108:44)
    at MetadataBundler.exportAll (/Users/David/Projects/github/amcdnl/ngxs/node_modules/@angular/compiler-cli/src/metadata/bundler.js:108:44)

How To Reproduce

https://github.com/amcdnl/ngxs

Expected Behaviour

Build success 😛

Version Information

$ node_modules/.bin/ng-packagr --version
ng-packagr:            2.1.0
@angular/compiler:     5.2.7
@angular/compiler-cli: 5.2.7
rollup:                0.55.5
tsickle:               0.27.2
typescript:            2.7.2
@dherges
Copy link
Contributor Author

dherges commented Mar 3, 2018

Austin says: "I expect that ng-packagr falls back to a file name that doesn't overlap existing source file"

David says: "I expect that ngc gives a better error message"

@ssameh
Copy link

ssameh commented Sep 20, 2018

I had this issue when the file name was sharing the same name of its folder, once I changed file name the issue was resolved, a snapshot to the error is include as you can see , the issue is occurring at path.js library

capture

alan-agius4 added a commit that referenced this issue Aug 20, 2021
With this change we enabled publishing of Ivy partially compiled libraries by default.

BREAKING CHANGE: Compilation of libraries using VIew Engine is no longer supported.

Closes #1087, closes #382, closes #285, closes #317, closes #355, closes #656, closes #917
@github-actions
Copy link

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.

@github-actions github-actions bot locked and limited conversation to collaborators Sep 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

2 participants