jvandemo / jvandemo/generator-angular2-library

'@uirouter/angular' gets renamed into '@uirouter/angular/index' in final bundle

Open
#207 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
740
Forks
116
PR merge metrics
No merged PRs in 30d

Description

While trying to bundle a module with it's own routes defined using `@uirouter/angular`, original import path for it is getting renamed into `@uirouter/angular/index` which causes warnings during build, and fails when trying to use it in a consumer application.
`$ npm run build` output:
```bash
[10:40:06] Using gulpfile ~/proj/amedia/gulpfile.js
[10:40:06] Starting 'clean:dist'...
[10:40:06] Starting 'clean:tmp'...
[10:40:06] Starting 'clean:build'...
[10:40:06] Starting 'compile'...
[10:40:06] Finished 'compile' after 777 μs
[10:40:06] Finished 'clean:tmp' after 7.95 ms
[10:40:06] Finished 'clean:build' after 7.25 ms
[10:40:06] Finished 'clean:dist' after 18 ms
[10:40:06] Starting 'copy:source'...
[10:40:06] Starting 'clean'...
[10:40:06] Finished 'clean' after 8.4 μs
[10:40:06] Starting 'build'...
[10:40:06] Finished 'build' after 3.81 μs
[10:40:06] Finished 'copy:source' after 47 ms
[10:40:06] Starting 'inline-resources'...
[10:40:06] Finished 'inline-resources' after 9.84 ms
[10:40:06] Starting 'ngc'...
[10:40:08] Finished 'ngc' after 1.97 s
[10:40:08] Starting 'rollup:fesm'...
'@uirouter/angular/index' is imported by build/index.js, but could not be resolved – treating it as an external dependency
[10:40:08] Finished 'rollup:fesm' after 208 ms
[10:40:08] Starting 'rollup:umd'...
'@uirouter/angular/index' is imported by build/index.js, but could not be resolved – treating it as an external dependency
[10:40:08] Finished 'rollup:umd' after 37 ms
[10:40:08] Starting 'copy:build'...
[10:40:08] Finished 'copy:build' after 6.91 ms
[10:40:08] Starting 'copy:manifest'...
[10:40:08] Finished 'copy:manifest' after 2.26 ms
[10:40:08] Starting 'copy:readme'...
[10:40:08] Finished 'copy:readme' after 1.91 ms
[10:40:08] Starting 'clean:build'...
[10:40:08] Finished 'clean:build' after 1.99 ms
[10:40:08] Starting 'clean:tmp'...
[10:40:08] Finished 'clean:tmp' after 1.39 ms
Compilation finished succesfully
```

Manually removing added `/index` from a `@uirouter/angular/index` string inside `dist/module.umd.js` and `dist/index.js` making bundled module to work correctly in consumer app.

Any thoughts on why ngc/rollup behaves that way?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with gulpfile.js and the npm run build pipeline, then inspect build/index.js around the rollup:fesm and rollup:umd steps. Compare the generated references in dist/module.umd.js and dist/index.js; done means the build no longer emits the unresolved @uirouter/angular/index warning and the bundled module works in a consumer application.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, javascript, rollup
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.