-
Notifications
You must be signed in to change notification settings - Fork 12k
@ngtools/webpack failing to build, "Can't resolve './../../$$_gendir/..." #5678
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
I am having the same issue. can any body pls help? |
@jbarr33 Unfortunately this still gives the same error: // workaround https://github.com/angular/angular-cli/issues/5329
var aotPlugin = new AotPlugin({
tsConfigPath: path.join(__dirname, '../tsconfig.json')
});
aotPlugin._compilerHost._resolve = function(path_to_resolve) {
path_1 = require("path");
path_to_resolve = aotPlugin._compilerHost._normalizePath(path_to_resolve);
if (path_to_resolve[0] == '.') {
return aotPlugin._compilerHost._normalizePath(path_1.join(aotPlugin._compilerHost.getCurrentDirectory(), path_to_resolve));
}
else if (path_to_resolve[0] == '/' || path_to_resolve.match(/^\w:\//)) {
return path_to_resolve;
}
else {
return aotPlugin._compilerHost._normalizePath(path_1.join(aotPlugin._compilerHost._basePath, path_to_resolve));
}
};
config.plugins.push(
/*new AotPlugin({
tsConfigPath: path.join(__dirname, '../tsconfig.json')
})*/
aotPlugin
); ERROR in ./src/scripts/main.ts
Module not found: Error: Can't resolve './../../$$_gendir/src/scripts/app.module.ngfactory' in 'D:\Media\Programming\IntelliJ IDEA Projects\Emoji Tools\src\scripts'
@ ./src/scripts/main.ts 22:29-90 Thanks for the help |
Try changing If that doesn't work, maybe try moving the var aotPlugin = new AotPlugin({
// ...
entryModule: path.join(__dirname, '../src/scripts/app.module#AppModule')
}); It's hard to get this configuration right, it took me a while for my project and then it breaks again with every other update. |
@tinchou Changing the |
https://github.com/MitchTalmadge/Angular-AoT-Error-Example Here is a pretty minimal example of the error. Hope it helps |
I was able to build for production without aot thou. Note : if anyone is using angular2-datatable component please ve advice to update to current version. |
Yeah, JIT building works fine. AoT is my goal though. Also, as I mentioned in my original post, running |
@MitchTalmadge I was able to get your example working by adding ".ts" extension to the
I think because these are physical paths, without the extension it is a problem. If using relative path syntax such as below, this is when @tinchou fix from #5329 is needed:
It's hard for me to tell when it's OK to give Webpack relative path syntax and when it expects the physical path to be resolved. Some guidance would be great on this. I was also actually a little confused by the results and whether AoT code was actually getting generated but it seems like it is. Angular 4 changed the way AoT code is generated and I had been using Angular 2.x. Almost forgot, to get your example to actually run you need to change the tag in index.html.ejs to Hope this helps. |
Oops I forgot to change that tag haha. Thanks for the help! I'll try that out today and see if it works for me too. |
@jbarr33 Thank you so much, that fixed it for me! 🎉 😄 Adding |
I still have this errror ngtools/webpack 1.5.2 , and tried all of the above.. Really frustrating |
At some point my deployment broke because of the issue @TheOriginalJosh mentions, even though I had file names with extensions. As of today, updating to the latest |
use @angular/[email protected] solved my problem! |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Bug Report or Feature Request (mark with an
x
)Versions.
from package.json
Repro steps.
Example Repo:
https://github.com/MitchTalmadge/Angular-AoT-Error-Example
I am facing a problem trying to use
@ngtools/webpack
to enable AoT for Angular 4. When I run my webpack script, I receive an error telling me that theapp.module.ngfactory
cannot be resolved. Nogendir
is ever created, even when specifically declaringgenDir
in thetsconfig.json
. However, if I usengc .
then the gendir is created, all files compile, and everything works great.Here are my webpack configs in question:
webpack.common.config.js
webpack.dev.config.js (the file passed in as the
--config
forwebpack
)And here is my tsconfig.json
... and my main.ts
The log given by the failure.
Stack Trace:
Full Log:
Desired functionality.
I expect the main.ts to be converted by the plugin into an AoT compatible file, using generated
ngfactory
files, then bundled into js files.Mention any other details that might be useful.
My webpack scripts are in
/webpack
, my tsconfig.json is in/
, my main.ts and app.module.ts are in/src/scripts
.Thanks for any help. I'm really stuck on this one.
The text was updated successfully, but these errors were encountered: