-
Notifications
You must be signed in to change notification settings - Fork 229
AOT building fails: Module not found: Error: Can't resolve 'ngx-infinite-scroll/index' #162
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
Comments
hi @cronosxfiles |
Hi @orizens,
|
hi. |
This IS the reason. Major jumps in versions, like that, is bound to cause issues. I'd advice towards updating to 4.x @cronosxfiles. |
closing this - as this occurs because of versions difference. |
This doesn't work with angular 4.3.6 for the above stated reason. The error is: |
This issue should be reopened. This module does not currently compile if it is included as a dependency in a library being bundled with rollup. I understand @orizens that you're compiling with aot with webpack but there is still something wrong here. |
hi @jcroll |
Hi @orizens I can but for now I am diving deeper into the problem. I believe it's because you only expose a Possibly related: rollup/rollup-plugin-typescript#62 If you could include a index.js or index.ts file in your dist I bet all this would go away! |
See below:
|
hi @jcroll |
@robisim74 |
@orizens I'll give it a look, and let you know. |
I can't recreate the problem without a repro, because they said that they are using this library as a dependency of another library. However: including index.js is useless, because the library provides for building using ES2015 the
because the old |
@orizens If you decide to deploy the library with the old index.js file as during Angular 2, that's enough that you remove these lines from the building process: https://github.com/orizens/ngx-infinite-scroll/blob/master/build.js#L54-L57 But as I said, it is not necessary. |
Ok (and forgive me if I'm wrong as I'm just learning rollup) but here you are suggesting compiling this library's code with my library's code. So instead of including Which I don't in theory have a problem with but my library has many dependencies and if I turn this on from what I can tell (and again please inform me if I am wrong here) I have to bundle every dependency my library has which becomes quite problematic. |
For the record I am using the starter pack https://github.com/jvandemo/generator-angular2-library It might be easier just to see if your library compiles with it. I might fork and give it a try myself. |
No, I'm not suggesting that. It's correct to keep it as a peer dependency. But by default, Rollup tries to use index.js, and not the "es2015" file. |
To me it implies including |
In another situation, I used resolve() and then I added the dependency in the But this is just one example: the point is that the problem is not in this library: the problem is in working with libraries that have other libraries as dependencies. |
Here is my rollup config: // Bundle's entry point
// See https://github.com/rollup/rollup/wiki/JavaScript-API#entry
entry: `${buildFolder}/index.js`,
// Allow mixing of hypothetical and actual files. "Actual" files can be files
// accessed by Rollup or produced by plugins further down the chain.
// This prevents errors like: 'path/file' does not exist in the hypothetical file system
// when subdirectories are used in the `src` directory.
allowRealFiles: true,
// A list of IDs of modules that should remain external to the bundle
// See https://github.com/rollup/rollup/wiki/JavaScript-API#external
external: [
'@angular/animations',
'@angular/common',
'@angular/compiler',
'@angular/compiler-cli',
'@angular/core',
'@angular/forms',
'@angular/http',
'@angular/platform-browser',
'@angular/platform-browser-dynamic',
'@angular/platform-server',
'@angular/router',
'@ng-bootstrap/ng-bootstrap',
'@ngrx/core',
'@ngrx/effects',
'@ngrx/store',
'@ngrx/store-devtools',
'@types/lodash',
'@types/numeral',
'angular2-jwt',
'angular2-ui-switch',
'bootstrap',
'chart.js',
'core-js',
'deep-diff',
'font-awesome',
'glyphicons-halflings',
'lodash',
'md5',
'moment',
'ng2-charts',
'ng2-nouislider',
'ng2-table',
'ngx-infinite-scroll',
'nouislider',
'numeral',
'rxjs',
'ts-helpers',
'typescript',
'web-animations-js',
'zone.js',
],
// Format of generated bundle
// See https://github.com/rollup/rollup/wiki/JavaScript-API#format
format: 'es',
plugins: [
resolve({
jsnext: true,
module: false,
}),
commonjs({
include: [
'node_modules/ngx-infinite-scroll/**',
],
exclude: [
'node_modules/@angular/animations/**',
'node_modules/@angular/common/**',
'node_modules/@angular/compiler/**',
'node_modules/@angular/compiler-cli/**',
'node_modules/@angular/core/**',
'node_modules/@angular/forms/**',
'node_modules/@angular/http/**',
'node_modules/@angular/platform-browser/**',
'node_modules/@angular/platform-browser-dynamic/**',
'node_modules/@angular/platform-server/**',
'node_modules/@angular/router/**',
'node_modules/@ng-bootstrap/ng-bootstrap/**',
'node_modules/@ngrx/core/**',
'node_modules/@ngrx/effects/**',
'node_modules/@ngrx/store/**',
'node_modules/@ngrx/store-devtools/**',
'node_modules/@types/lodash/**',
'node_modules/@types/numeral/**',
'node_modules/angular2-jwt/**',
'node_modules/angular2-ui-switch/**',
'node_modules/bootstrap/**',
'node_modules/chart.js/**',
'node_modules/core-js/**',
'node_modules/deep-diff/**',
'node_modules/font-awesome/**',
'node_modules/glyphicons-halflings/**',
'node_modules/lodash/**',
'node_modules/md5/**',
'node_modules/moment/**',
'node_modules/ng2-charts/**',
'node_modules/ng2-nouislider/**',
'node_modules/ng2-table/**',
// 'ngx-infinite-scroll',
'node_modules/nouislider/**',
'node_modules/numeral/**',
'node_modules/rxjs/**',
'node_modules/ts-helpers/**',
'node_modules/typescript/**',
'node_modules/web-animations-js/**',
'node_modules/zone.js/**',
],
}),
] When I attempt to compile I get:
I have tried to exclude rxjs twice in the above config. Any idea what I am missing? Additionally you can get an idea from the above how many libraries I've gotten to compile. It is just this one not working :( |
Are you using generator-angular2-library? Later I'll try to understand what's happening here. |
Yes, I am using that. That config is actually located in |
And as to your point above:
Yes. This library compiles fine into a binary using angular cli. But yeah, if being included as part of a library it does not seem to work. Up to you how important this is to you but perhaps hints at more compatibility issues down the line. I would try that starter pack, quite comprehensive! |
I'm trying this configuration (adding /index to the external property):
and it seems compile without problems: Try it, and let me know if this solution works also in your library. |
@orizens The problem here is that we are using to export the APIs a file called index instead of name-of-library: so Rollup tries to find 'ngx-infinite-scroll/index', but this should not happen. I'll try to update my repo, and if it works I'll do a pr also to this library. |
Yes @robisim74 your config is basically what I had when I first commented in this thread. My library compiled but when pulled into my angular-cli application as a npm dependency webpack does not compile with an error like so:
|
Get it. I'll fix the problem into my repo, and I'll do a pr to this library. |
@jcroll Are you still there? Could you try this quick fix? Go to node_modules/ngx-infinite-scroll and rename:
and:
Let me know (so you can work in the meantime). |
Yeah @robisim74 that appears to work!! |
Hi robisim74, where can i find Thanks you |
In your |
This is the building command:
ng build --environment=demos --aot --progress --verbose
and this is the error output:
ERROR in ./src/$$_gendir/app/app.module.ngfactory.ts Module not found: Error: Can't resolve 'ngx-infinite-scroll/index' in '/home/user/Git/project/Application/frontend/src/$$_gendir/app' @ ./src/$$_gendir/app/app.module.ngfactory.ts 16:0-53 @ ./src/main.ts @ multi ./src/main.ts
The code compiles correctly with
tsc
Installed version: ngx-infinite-scroll@0.5.1
The text was updated successfully, but these errors were encountered: