jvandemo / generator-angular2-library

Yeoman generator to create an Angular library
MIT License
752 stars 122 forks source link

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

Open Kamilius opened 7 years ago

Kamilius commented 7 years ago

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:

[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?

Kamilius commented 7 years ago

As appeared, that's a known issue https://github.com/angular/angular/issues/19327 which is a duplicate of following issue https://github.com/angular/angular/issues/19026

Janatbek commented 7 years ago

I used gulp rename task to rename whatever you have a problem with. In your case write a task that takes that line of code in index.js and renames it without "/index/"