Skip to content

Commit 431ba7a

Browse files
Code splitting
1 parent 9f8ab3c commit 431ba7a

File tree

7 files changed

+8597
-17
lines changed

7 files changed

+8597
-17
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ bin/
99
output/
1010
.fake/
1111
temp/
12+
.idea/

package-lock.json

Lines changed: 8575 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"bulma": "^0.7.4",
1313
"bulma-pageloader": "^2.1.0",
1414
"lowdb": "^1.0.0",
15-
"marked": "^0.6.1",
15+
"marked": "^0.6.2",
1616
"react": "^16.8.5",
1717
"react-dom": "^16.8.5",
1818
"showdown": "^1.9.0"
@@ -24,7 +24,7 @@
2424
"copy-webpack-plugin": "^5.0.2",
2525
"core-js": "^3.0.0",
2626
"css-loader": "^2.1.1",
27-
"fable-compiler": "^2.2.0",
27+
"fable-compiler": "^2.3.0-beta-001",
2828
"fable-loader": "^2.1.5",
2929
"file-loader": "^3.0.1",
3030
"html-webpack-plugin": "^3.2.0",

paket.lock

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ NUGET
1818
Fable.Browser.Event (>= 1.0.0-alpha-001)
1919
Fable.Core (>= 2.1.0-alpha-002)
2020
FSharp.Core (>= 4.5.2)
21-
Fable.Core (3.0.0-beta-005)
21+
Fable.Core (3.0.0-beta-006)
2222
FSharp.Core (>= 4.5.2)
2323
Fable.Elmish (3.0.0-beta-7)
2424
Fable.Core (>= 3.0.0-beta-004)
@@ -53,8 +53,9 @@ NUGET
5353
Fable.Promise (2.0.0-beta-001)
5454
Fable.Core (>= 3.0.0-beta-002)
5555
FSharp.Core (>= 4.5.2)
56-
Fable.React (5.0.0-beta-001)
56+
Fable.React (5.0.0-beta-007)
5757
Fable.Browser.Dom (>= 1.0.0-alpha-004)
58+
Fable.Core (>= 3.0.0-beta-006)
5859
FSharp.Core (>= 4.5.2)
5960
FSharp.Core (4.6.2) - redirects: force
6061
Fulma (2.0.0-beta-003)

src/Question/Dispatcher/View.fs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
module Question.Dispatcher.View
22

3+
open Fable.React
34
open Types
45

6+
let QuestionShow =
7+
LazyComponent.FromExternalFunction(
8+
Question.Show.View.root,
9+
div [] [str "Loading..."])
10+
511
let root user model dispatch =
612
match model with
713
| { CurrentPage = Router.QuestionPage.Index
814
IndexModel = Some extractedModel } -> Question.Index.View.root extractedModel (IndexMsg >> dispatch)
915

1016
| { CurrentPage = Router.QuestionPage.Show _
11-
ShowModel = Some extractedModel } -> Question.Show.View.root user extractedModel (ShowMsg >> dispatch)
17+
ShowModel = Some extractedModel } ->
18+
QuestionShow {| user = user
19+
model = extractedModel
20+
dispatch = ShowMsg >> dispatch |}
1221

1322
| { CurrentPage = Router.QuestionPage.Create
1423
CreateModel = Some extractedModel } -> Question.Create.View.root user extractedModel (CreateMsg >> dispatch)

src/Question/Show/View.fs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,12 @@ let private pageContent user question model dispatch =
7777
questionsView question model.Answers dispatch
7878
replyView user model dispatch ]
7979

80-
let root user model dispatch =
81-
match model.Question with
80+
let root (props: {| user: User
81+
model: Model
82+
dispatch: Msg->unit |}) =
83+
match props.model.Question with
8284
| Some question ->
83-
pageContent user question model dispatch, false
85+
pageContent props.user question props.model props.dispatch, false
8486
| None -> div [ ] [ ], true
8587
|> (fun (pageContent, isLoading) ->
8688
Container.container [ ]

webpack.config.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,8 @@ module.exports = {
6868
mode: isProduction ? "production" : "development",
6969
devtool: isProduction ? "source-map" : "eval-source-map",
7070
optimization: {
71-
// Split the code coming from npm packages into a different file.
72-
// 3rd party dependencies change less often, let the browser cache them.
7371
splitChunks: {
74-
cacheGroups: {
75-
commons: {
76-
test: /node_modules/,
77-
name: "vendors",
78-
chunks: "all"
79-
}
80-
}
72+
chunks: "all"
8173
},
8274
},
8375
// Besides the HtmlPlugin, we use the following plugins:

0 commit comments

Comments
 (0)