-
Notifications
You must be signed in to change notification settings - Fork 12k
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
ng serve -prod fails (beta 5) #847
Comments
OS X Mac El Capitan
|
ng serve
and ng build
fails in production when tries to concat vendor polyfills
This issue is also affecting Windows. The "BundlePlugin" is throwing an exception when building for PROD. angular-cli: 1.0.0-beta.5
|
It seems that your error is different than mine. Did you make any change in the code before serve or build as prod? Did you create the app via |
@ddiazpinto I create app via |
@ddiazpinto Same here. That is a brand new angular-cli solution. I used the "new" keyword to generate the solution, and ran "ng build -prod" without touching any of the files. |
+1 |
4 similar comments
+1 |
+1 |
+1 |
+1 |
Heya all, just wanted to let you know that we're aware of this issue and that I'm picking it up later today to try and fix it. |
This broke angular-cli retroactively (all the way back to 0.0.37), so it appears to be a problem with a dep. i.e. fixing that dep's version number in the package.json "should" resolve it. (That said, i have no idea which dep, nor which version.) |
A workaround for desperate users: revert to ng 0.0.34. You won't get bundles (so 300+ requests at app startup), but it otherwise seems to work. |
I know which dependency broke it. It was SystemJS, and #839 should have fixed it for new projects... but apparently it didn't? The issue described by @ddiazpinto seems to be different, and related to differences between mobile and non-mobile build steps. |
Guys, I just tried this with a branch new
@ddiazpinto your issue is different though, I need to research it more thoroughly. |
@filipesilva those exact steps work for me now (they didn't when i filed #888 a couple hours ago!), but it's not working in our project tree: we are stuck with beta.1 because of #833. Testing with that version and systemjs 0.19.26 (same as current ng new) we are still getting the missing map error:
So.... i mangled our tree to work around #833, just to try it out, but the error remains. Any hint on which toggle i need here would be much appreciated! i have tried simply disabling maps via tsconfig, but it still wants the maps at bundle-time. |
@sgbeal for existing projects, the fix should be this:
|
@filipesilva you are my hero :). That works... but we can't use beta.5 because of #833 (imports in environment.xxx.ts cannot be resolved, and we rely on that to import dev-time mocks and set up logging service log levels in prod) :(. Just tried that same thing with beta 1, but it's still looking for maps :(. |
Just re-verified: the above fix works for us with beta.5 only if we remove all imports and references to globals (e.g. window and console) from environment.prod.ts. As soon as we reference, or try to import, any external symbols, they cannot be imported/resolved. |
As far as globals are concerned, they are a typings issue - compounded with bad module resolution for env files on the cli part. You should be able to get around it with something like |
That same set of config changes still works with 0.0.34, so we'll stick with that for the time being. Thank you once again for the quick assistance, @filipesilva :). |
(further commentary/details moved to #833, to stop hijacking this thread.) |
CORRECTION: the above-mentioned config changes lead to (build -prod) not failing, but it's missing our core-most JS files, e.g. system.js and rxjs are now missing, so index.html cannot find them:
Reverting to beta.1 leads to it the build process looking for .map files (tried systemjs .26 and .27). Reverting to 0.0.34 (without bundling) and it all works again. |
Hi @filipesilva The error reported by @Codenator81 and @zorthgo is different than mine like we see in the error log. |
Not sure if this helps, but I can run |
Facing the error similar to second post in this issue here. I noted the following in error details.
@filipesilva , in my case, it looks to me, the approach to calculate the source map path need to fix. |
I turned off sourceMaps and all accompanied settings in tsconfig.json Still an error
tsconfig.json (relevant parts)
I also tried generating a completely new project with beta 5 and this kinda works. I created the project with an older version von angular-cli (I think it was beta 4). So this might be a cause |
Close angular#847 (see 847#issuecomment-221285753)
Apologies for being so late in getting back to this topic. @ddiazpinto the solution presented by @RainerAtSpirit seems to be working for me as well. I believe the TS file is needed for one of the extra plugins that the mobile mode uses for builds. I'll add in a PR with that change for new projects. @jbouzekri could you put up a repo so I can have a look and try to fix? @jd4u you're right in saying that the source map is wrong. I believe at the time @hmrc87 That issue is due to the project having initially been created with beta.4. The steps in #847 (comment) should fix it. |
Thank you Filipe,
Do I need to have @angular in the vendor folder or does the prod-built squash everything together in main.js (Mine is like 30k lines of code for a quite small project). When I built without prod all the vendor-files appear in the dist-folder including the sourcemaps. Where is the difference in the cli-tool building process between --prod and non-prod? I saw that in prod-mode the bundler will gather all files under app and put them into main.js I played around with the GLOB-syntaxc in angular-cli-build.js and find it somehow weird:
|
@filipesilva Thank you. Even if adding But thank you again ;) |
@hmrc87 @ddiazpinto I haven't fully looked at the logic behind the mobile builds, but I suspect it's related with the offline compiler and how it's importing dependencies. |
@filipesilva Thank you for the explanation. So I kinda got it to serve/build without an error but now nothing happens. The app does not load, there is no console output at "ng serve --prod", main.js is loaded according to the network tab. The main.js is 30k lines long and about 1.7MB large. How could I debug it? I suppose it has something to do with my dependencies like:
|
i was able to reproduce the exact same error (or lack thereof) as @hmrc87 yesterday - blank page, no error messages. To get that far i had to move all my 3rd-party imports (jquery, bootstrap, etc) from index.html to systemjs, and add an (import 'jquery' (etc)) call in index.ts to tell the bundler to include them (as suggested in an earlier comment in this thread). Build runs w/o an error but serving just delivers a blank page with no errors. |
@sgbeal Yes, now I am in the same situation. I have included jQuery, bootstrap, chartjs in my angular-cli-build.js. I am not sure if jQuery for example has been correclty funneled into main.js since a Search within that file for "jQuery" does not bring up any result. |
@hmrc87 @sgbeal what you describe seems to be related to #951. Can you have a look there? Basically it seems that SystemJS bundling might not go very smoothly if the module format isn't specified in |
@filipesilva Is this is issue in |
@Codenator81 the initial |
@filipesilva This is a hard problem but also an area where Angular CLI faces an uphill battle. Why? Because the most obvious competition, webpack, most of the time "just works". It bundles common JS modules resolved in the standard node way, the enormous number of packages out there published in the standard node way typically work the first time without any package specific configuration, without the user even knowing that there exists such a thing as different library module types. Now course there are lots of downsides there, lack of tree shaking with common JS modules etc. So clearly something better is needed. But to be that better thing, and gain a high "market share", it seems to me that installing at least the hundred most common add-ons needs to work very easily out of the box. I don't really know the goals of the project though, so these are just ideas floating out there, hope this helps. |
Close angular#847 (see 847#issuecomment-221285753)
Close #847 (see 847#issuecomment-221285753)
I totally agree with @kylecordes. I'm new to JS/Angular development and chose CLI as it sounds good to have a solid frame for projects/builds. However, after using it in a few toy projects to learn, it essentially just postpones the issues: on the positive side I get a nice base project and can easily generate routes/componets/etc. However, it seems to me that many of the github starter projects for Angular2 also deliver that. And when it comes to integrating 3rd party libraries, it's really painful. Basically every module has a different way to integrating it, so as soon as I want to use another library which I haven't used before, I know I'll spend probably the rest of the day trying out various modifications and browsing for solutions. Maybe it's just a personal issue of not having the background about the different kinds of JS modules and their loaders, but whenever I'm searching for a solution, I find a lot of other posts with a similar issue, so this might affect a large number of potential CLI users. |
Close angular#847 (see 847#issuecomment-221285753)
Close angular#847 (see 847#issuecomment-221285753)
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. |
OS?
Debian Jessie
Versions. Please run
ng --version
.angular-cli: 1.0.0-beta.5
node: 5.11.1
os: linux x64
Repro steps. Was this an app that wasn't created using the CLI? What change did you
do on your code? etc.
ng new ngtestmobile --mobile
cd ngtestmobile
ng serve
-- works normally.ng serve -prod
-- doesn't work.No changes in the code.
The log given by the failure. Normally this include a stack trace and some
more information.
This problem only happen using the
--mobile
flag when tries to concat the vendor polyfills to buildapp-concat.js
in index.html.The text was updated successfully, but these errors were encountered: