Skip to content
This repository has been archived by the owner on Jan 8, 2018. It is now read-only.

dependency on compiler #9

Closed
dipunm opened this issue Jun 14, 2017 · 11 comments
Closed

dependency on compiler #9

dipunm opened this issue Jun 14, 2017 · 11 comments

Comments

@dipunm
Copy link

dipunm commented Jun 14, 2017

I'm submitting a ... (check one with "x")

[x ] bug report => check the README and search github for a similar issue or PR before submitting
[ ] support request => check the README and search github for a similar issue or PR before submitting
[ ] feature request

Current behavior

Add the following line into your AppModule
import { BrowserStateTransferModule } from '@ngx-universal/state-transfer';

Expected/desired behavior

This file imports the ServerStateTransferModule which in turn imports @angular/platform-server.
Desired: The project should not be dependant on @angular/platform-server because of the above steps

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

By importing the server platform, the client script grows from less than 800kb to 4mb. Also, the compiler is included even though the client script is aot compiled.

Please tell us about your environment:

  • Angular version: 4.1.0
  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
  • Language: [all | TypeScript X.X | ES6/7 | ES5]

  • Node (for AoT issues): node --version = v7.8.0

@hmagrini
Copy link

I was just about to report the same issue. Here are some repro steps:

  • create clean repo ng new compiler-bug --skip-git
  • add minimal deps yarn add webpack-bundle-analyzer @angular/platform-server @ngx-universal/state-transfer
  • run build to test that AOT should net a vendor.js ~850 kB and doesn't include angular/compiler : ng build --prod --stats-json && ./node_modules/.bin/webpack-bundle-analyzer ./dist/stats.json.
  • add any of the modules from ngx-universal/state-transfer:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { HttpTransferModule } from '@ngx-universal/state-transfer';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    HttpTransferModule.forRoot()
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }
  • run build with cmd from above, now vendor.js is ~2.84 MB

@fulls1z3
Copy link
Owner

Hi folks, sorry for replying late I'll be checking the issue to generate a possible solution soon (upcoming holidays).

@fulls1z3 fulls1z3 self-assigned this Jun 27, 2017
@fulls1z3 fulls1z3 changed the title Dependency on compiler [enhancement] dependency on compiler Jun 27, 2017
@hmagrini
Copy link

@fulls1z3 Hi there! any update on this? I'm more than happy to take a crack on this if pointed in the right direction 👍

@fulls1z3
Copy link
Owner

fulls1z3 commented Aug 2, 2017

@dipunm @hermagrini I'm on it now 🤔

@fulls1z3
Copy link
Owner

fulls1z3 commented Aug 2, 2017

@dipunm @hermagrini well, I had a look on the source files, and confirmed that there's a direct dependency to @angular/platform-server, we use it to retrieve the document according to Universal Gotchas, as below:

import { PlatformState } from '@angular/platform-server';
...
constructor(@Inject(STATE_ID) private readonly stateId: string,
              private readonly platformState: PlatformState,
...
const document: any = this.platformState.getDocument();

If someone has a better idea at this point, please don't hesitate to share with me.

@fulls1z3
Copy link
Owner

fulls1z3 commented Aug 2, 2017

@theomathieubhvr as I mentioned you on fulls1z3/universal#43, this issue might also give you some hints.

@dipunm
Copy link
Author

dipunm commented Aug 2, 2017

I just checked it out and had a look. I made some changes, but I have no idea how to test it. I installed karma, but it complains that there is no karma.config file in the config folder.

Reckon I should do a PR anyway?

@fulls1z3
Copy link
Owner

fulls1z3 commented Aug 2, 2017

@dipunm you can upload right here at the topic in a zip file

@dipunm
Copy link
Author

dipunm commented Aug 3, 2017

Archive.zip
Here it is

@dipunm
Copy link
Author

dipunm commented Aug 15, 2017

any thoughts on the zip?

@fulls1z3
Copy link
Owner

@dipunm I'm working on a general update on all repos - it means a tremendous amount of issues will be resolved, and I'll analyze (highly probable implement) the changes in that zip file.

@fulls1z3 fulls1z3 added this to the v0.4.0 milestone Sep 3, 2017
@fulls1z3 fulls1z3 modified the milestones: v4.1.0, v4.0.0 Sep 6, 2017
@fulls1z3 fulls1z3 changed the title [enhancement] dependency on compiler dependency on compiler Sep 16, 2017
@fulls1z3 fulls1z3 closed this as completed Jan 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants