Repository navigation
Universal --bundle-dependencies=all works with --aot but fails with --prod #8900
Copy link
Copy link
Closed
Labels
area: @angular-devkit/build-angularfreq1: lowOnly reported by a handful of users who observe it rarelyOnly reported by a handful of users who observe it rarelyseverity5: regressiontype: bug/fix
Milestone
Description
Versions
Angular CLI: 1.6.0
Node: 8.9.1
OS: win32 x64
Angular: 5.1.0
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router
@angular/cdk: 5.0.1
@angular/cli: 1.6.0
@angular/flex-layout: 2.0.0-beta.11-b01c2d7
@angular/material: 5.0.1
@angular-devkit/build-optimizer: 0.0.35
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.40
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.0
@schematics/angular: 0.1.10
@schematics/schematics: 0.0.10
typescript: 2.4.2
webpack: 3.10.0
Repro steps
When using below command it works perfectly.
ng build -- --app=ssr --output-hashing=media --aot --bundle-dependencies=all
But when we run below command:
ng build -- --app=ssr --output-hashing=media --prod --bundle-dependencies=all
It throws below warnings:
WARNING in ./node_modules/@angular/core/bundles/core.umd.js
6579:23-44 Critical dependency: the request of a dependency is an expression
at ImportLazyContextDependency.getWarnings (D:\MyProject\ClientApp\node_modules\webpack\lib\dependencies\ContextDependency.js:39:18)
at Compilation.reportDependencyErrorsAndWarnings (D:\MyProject\ClientApp\node_modules\webpack\lib\Compilation.js:703:24)
at Compilation.finish (D:\MyProject\ClientApp\node_modules\webpack\lib\Compilation.js:561:9)
at applyPluginsParallel.err (D:\MyProject\ClientApp\node_modules\webpack\lib\Compiler.js:502:17)
at D:\MyProject\ClientApp\node_modules\tapable\lib\Tapable.js:289:11
at _addModuleChain (D:\MyProject\ClientApp\node_modules\webpack\lib\Compilation.js:507:11)
at processModuleDependencies.err (D:\MyProject\ClientApp\node_modules\webpack\lib\Compilation.js:477:14)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)
@ ./node_modules/@angular/core/bundles/core.umd.js
@ ./src/main.server.ts
@ multi ./src/main.server.ts
WARNING in ./node_modules/@angular/core/bundles/core.umd.js
6599:23-110 Critical dependency: the request of a dependency is an expression
at ImportLazyContextDependency.getWarnings (D:\MyProject\ClientApp\node_modules\webpack\lib\dependencies\ContextDependency.js:39:18)
at Compilation.reportDependencyErrorsAndWarnings (D:\MyProject\ClientApp\node_modules\webpack\lib\Compilation.js:703:24)
at Compilation.finish (D:\MyProject\ClientApp\node_modules\webpack\lib\Compilation.js:561:9)
at applyPluginsParallel.err (D:\MyProject\ClientApp\node_modules\webpack\lib\Compiler.js:502:17)
at D:\MyProject\ClientApp\node_modules\tapable\lib\Tapable.js:289:11
at _addModuleChain (D:\MyProject\ClientApp\node_modules\webpack\lib\Compilation.js:507:11)
at processModuleDependencies.err (D:\MyProject\ClientApp\node_modules\webpack\lib\Compilation.js:477:14)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)
@ ./node_modules/@angular/core/bundles/core.umd.js
@ ./src/main.server.ts
@ multi ./src/main.server.ts
And when we run the app it shows below error in log:
StaticInjectorError[InjectionToken DocumentToken]:
StaticInjectorError[InjectionToken DocumentToken]:
Right-hand side of 'instanceof' is not an object
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area: @angular-devkit/build-angularfreq1: lowOnly reported by a handful of users who observe it rarelyOnly reported by a handful of users who observe it rarelyseverity5: regressiontype: bug/fix
Activity
hansl commentedon Dec 19, 2017
Hi @naveedahmed1
Could you try with
--build-optimizer=false? Also, we need a reproduction here. That doesn't look like a new application (or perhaps it is?).naveedahmed1 commentedon Dec 20, 2017
Thank you so much @hansl
It seems that
--build-optimizer=falsedoesnt make any difference and show same warning.To reproduce, you can use the universal starter repo https://github.com/angular/universal-starter and run the below command:
ng build --app=1 --output-hashing=media --prod --bundle-dependencies=allnaveedahmed1 commentedon Dec 27, 2017
Just to add the issue still exists in v 1.6.3
naveedahmed1 commentedon Dec 27, 2017
Probably its the reason why server bundles aren't working with
--bundle-dependencies=alland throwing below error in log:naveedahmed1 commentedon Jan 3, 2018
@Brocco can you please confirm if you were able to reproduce this issue?
naveedahmed1 commentedon Jan 5, 2018
Ok I think the issue is with the uglifyjs plugin. It seems that angular cli is using
--compressand--mangleoption with this plugin for server bundles and its causing the issue.To confirm this, I first build bundle using below command:
ng build --app=ssr --output-hashing=media --aot --bundle-dependencies=allThen I used
uglifyjsusing below commanduglifyjs main.bundle.js --output output.js(main.bundle.js is the server bundle generated in 1st command)
the bundle generated after above command worked perfectly.
Then I tried generating a bundle with --compress and --mangle
uglifyjs main.bundle.js --output output.js --compress --manglewhen I used this bundle it threw the error I mentioned in my 2nd last comment.
24 remaining items
speige commentedon Sep 27, 2018
I agree that the deployment issue is caused by visual studio's publish. That's why I'd suggest not deploying node_modules through visual studio & instead doing npm install on the server. I haven't personally tried it, but it seems plausible that it'd work.
naveedahmed1 commentedon Sep 27, 2018
I doubt if its supported on Windows IIS web server. May be that would work when you have root access of the server, login using remote desktop and then run npm install on that specific site directory with admin permissions.
speige commentedon Sep 27, 2018
It could probably also be done remotely through powershell.
naveedahmed1 commentedon Sep 27, 2018
I am not sure about it, but I think that would still require elevated permissions.
speige commentedon Sep 27, 2018
True. Elevated permissions would probably be required. I didn't realize this would be an issue, because I wasn't thinking about support for shared web hosts.
I assume the linux+node/express setup also requires running npm install on the server.
Maybe if you're on a shared web host (or don't have elevated permissions) you shouldn't be doing Universal/SSR ?
naveedahmed1 commentedon Sep 27, 2018
No I am not talking about shared host but for website deployment you shouldn't be requiring elevated permissions a simple access through ftp account should be sufficient.
speige commentedon Sep 27, 2018
You're logging a bug because you don't want to type your password?
If there's a valid workaround, let's move on & let them work on more important stuff like Angular v7 & ivy.
I'll drop out of this conversation now. Not trying to start a flaming war & I don't have anything else useful to contribute. But, the issue feels unnecessary to me.
alan-agius4 commentedon Sep 2, 2019
Thanks for reporting this issue. This issue is now obsolete due to changes in the recent releases. Please update to the most recent Angular CLI version.
If the problem persists after upgrading, please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior.
angular-automatic-lock-bot commentedon Oct 3, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.