Skip to content
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

Universal server side rendering #764

Merged
merged 2 commits into from
Jun 1, 2017
Merged

Universal server side rendering #764

merged 2 commits into from
Jun 1, 2017

Conversation

stupiduglyfool
Copy link
Contributor

@stupiduglyfool stupiduglyfool commented May 19, 2017

What kind of change does this PR introduce? (check one with "x")

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior? (You can also link to an open issue here)
Any references to Window, Document, MouseEvent, KeyboardEvent cause errors.

#173

What is the new behavior?
Similar to the comment here..
#173 (comment)

I've gone through all references and attempted to create a suitable workaround when the mentioned references are used.

Does this PR introduce a breaking change? (check one with "x")

  • Yes
  • No

If this PR contains a breaking change, please describe the impact and migration path for existing applications: ...

Other information:
Open to suggestions if anyone can suggest better approaches to my workarounds.

@amcdnl
Copy link
Contributor

amcdnl commented May 20, 2017

Doesn't typescript handle the MouseEvent and KeyboardEvent types automatically?

@stupiduglyfool
Copy link
Contributor Author

stupiduglyfool commented May 20, 2017

If you look at the transpiled code

https://github.com/swimlane/ngx-datatable/blob/master/release/index.js#L3809

There are dozens of mentions of MouseEvent and KeyboardEvent, all these are not defined.

This seems to be a common problem with angular components as I've found other have faced similar problems.

leovo2708/ng2-dropdown-treeview#23
valor-software/ngx-bootstrap#964

@rsparrow
Copy link
Contributor

What's the status on this PR? We are looking for the same change.

@amcdnl amcdnl merged commit f9e7bc7 into swimlane:master Jun 1, 2017
@amcdnl
Copy link
Contributor

amcdnl commented Jun 1, 2017

Merged.

@rsparrow
Copy link
Contributor

rsparrow commented Jun 2, 2017

@stupiduglyfool This has now been merged into version 9.3.0 but on the universal side of things I'm still getting the following error:


/usr/src/project/node_modules/@swimlane/ngx-datatable/release/index.js:9038
var testStyle = document !== undefined ? document.createElement('div').style : undefined;
                ^

ReferenceError: document is not defined
    at Object../src/utils/prefixes.ts (/usr/src/project/node_modules/@swimlane/ngx-datatable/release/index.js:9038:17)
    at __webpack_require__ (/usr/src/project/node_modules/@swimlane/ngx-datatable/release/index.js:35:30)
    at Object../src/utils/index.ts (/usr/src/project/node_modules/@swimlane/ngx-datatable/release/index.js:8812:10)
    at __webpack_require__ (/usr/src/project/node_modules/@swimlane/ngx-datatable/release/index.js:35:30)
    at Object../src/components/datatable.component.ts (/usr/src/project/node_modules/@swimlane/ngx-datatable/release/index.js:5325:15)
    at __webpack_require__ (/usr/src/project/node_modules/@swimlane/ngx-datatable/release/index.js:35:30)
    at Object../src/components/index.ts (/usr/src/project/node_modules/@swimlane/ngx-datatable/release/index.js:7307:10)
    at __webpack_require__ (/usr/src/project/node_modules/@swimlane/ngx-datatable/release/index.js:35:30)
    at Object../src/datatable.module.ts (/usr/src/project/node_modules/@swimlane/ngx-datatable/release/index.js:7471:20)
    at __webpack_require__ (/usr/src/project/node_modules/@swimlane/ngx-datatable/release/index.js:35:30)

Any suggestions?

@rsparrow
Copy link
Contributor

rsparrow commented Jun 2, 2017

@stupiduglyfool and @amcdnl I've found a solution. I'll issue a bug and a pull request later today.

rsparrow pushed a commit to rsparrow/ngx-datatable that referenced this pull request Jun 2, 2017
@rsparrow rsparrow mentioned this pull request Jun 2, 2017
9 tasks
@mattma
Copy link

mattma commented Jun 29, 2017

Using 9.3.0, still experience the same issue just like @rsparrow .

Using with @angular/service-worker

@compitDanielos
Copy link

@rsparrow I think all document !== undefined and window !== undefined whould to be changed to typeof document !== 'undefined' and typeof window !== 'undefined'

@rsparrow
Copy link
Contributor

@mattma My fixes didn't get packaged into a release until 9.3.1...

@mattma
Copy link

mattma commented Jul 24, 2017

by updating to 9.3.1, it works as expected. Still waiting on 10.0.0 release for the immutability data.

I am using ngrx and ngrx-store-freeze module. Due to the library modifying the original dataset with $$, I have to disable the storeFreeze. I believe @amcdnl will fix it by ``10.0.0` release.

Is there a timeline on when the feature will drop?

Thinking of switching to Angular CDK table module. i will be a quick bit of code refactor that I hope I can avoid with the future release of the library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants