Skip to content

Commit b69239d

Browse files
authored
Merge pull request #164 from topcoder-platform/develop
code split and misc updates
2 parents e9c7e32 + 8752dcf commit b69239d

File tree

47 files changed

+2527
-836
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2527
-836
lines changed

__tests__/shared/components/tc-communities/communities/wipro/__snapshots__/Learn.jsx.snap

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,23 @@ exports[`Snapshot match 1`] = `
4040
<div
4141
className="src-shared-components-tc-communities-communities-wipro-Learn-___style__message___WgkPL"
4242
>
43+
<p>
44+
If you are accessing TopGear
45+
<span
46+
className="src-shared-components-tc-communities-communities-wipro-Learn-___style__highlighted___3U2lK"
47+
>
48+
Learning
49+
</span>
50+
Platform from
51+
<strong>
52+
Wipro backbone network
53+
</strong>
54+
, click on “
55+
<strong>
56+
CONTINUE
57+
</strong>
58+
” to access the platform.
59+
</p>
4360
<p>
4461
<ThemedGenericButton
4562
composeTheme="deeply"
@@ -59,23 +76,6 @@ exports[`Snapshot match 1`] = `
5976
Continue
6077
</ThemedGenericButton>
6178
</p>
62-
<p>
63-
If you are accessing TopGear
64-
<span
65-
className="src-shared-components-tc-communities-communities-wipro-Learn-___style__highlighted___3U2lK"
66-
>
67-
Learning
68-
</span>
69-
Platform from
70-
<strong>
71-
Wipro backbone network
72-
</strong>
73-
, click on “
74-
<strong>
75-
CONTINUE
76-
</strong>
77-
” to access the platform.
78-
</p>
7979
<p>
8080
To access TopGear
8181
<span

config/webpack/production.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,13 @@ module.exports = webpackMerge(defaultConfig, {
5252
},
5353
}),
5454
new OptimizeCssAssetsPlugin(),
55-
new webpack.optimize.ModuleConcatenationPlugin(),
55+
56+
/* TODO: It tends to make problems with dynamically loaded chunks,
57+
* I guess it may move some code between modules being in different
58+
* chunks, thus breaking the code when they are loaded in different
59+
* order. Should be further investigated. */
60+
// new webpack.optimize.ModuleConcatenationPlugin(),
61+
5662
new webpack.optimize.UglifyJsPlugin(),
5763
],
5864
});

docs/code-splitting.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ First of all, under the hood `SplitRoute` uses **react-router**'s `Route` to mak
8484
8585
- By default, when you leave a split route, the CSS reference is removed from the document. You can pass in boolean `cacheCss` option to prevent it.
8686
87+
### Caveats
88+
89+
Here are some non-trivial points, that should be merged into the body of documentation above, but for now they are just mentioned here as points to remember:
90+
91+
- Although `<SplitRoute>` is technically a route, it is not quite possible to use it inside `<Switch>`, so in many cases you just have to use it as a usual component.
92+
93+
- If the chunk of code you split uses routing, you should use `<StaticRouter>` inside `renderServer` prop.
94+
8795
### Demo / Test
8896
8997
A simple demo / test of the code splitting is available at `/examples/code-splitting` endpoint of the app.

docs/how-to-add-a-new-topcoder-community.md

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -114,23 +114,12 @@ To add a new community with the name **demo**, we should follow the following pr
114114
- `description`: A berief description which will be displayed in dashboard.
115115
- `image`: A image that located at `/assets/images/tc-communities/background` will be displayed in dashboard
116116
3. Custom pages of the community (anything beside `Challenges` and `Leaderboard`) should be created inside `/src/shared/components/tc-communities/communities/demo`. At the moment all communities have two custom pages: `Home` and `Learn`, you may just copy these from an existing community, and then customize to your particular needs.
117-
4. Created custom pages should be registered inside `/src/shared/containers/tc-communities/Page/index.jsx`.
118-
- First, import your custom pages into the file as
119-
```js
120-
import DemoHome from 'components/tc-communities/communities/demo/Home';
121-
import DemoLearn from 'components/tc-communities/communities/demo/Learn';
122-
```
123-
- Second, add them into `renderCustomPage()` method. It includes a big `if-else` block, where you should add something similar to:
124-
```js
125-
} else if (communityId === 'demo') {
126-
switch (pageId) {
127-
case 'home': pageContent = <DemoHome />; break;
128-
case 'learn': pageContent = <DemoLearn />; break;
129-
default: break;
130-
}
131-
}
132-
```
133-
here the page IDs inside the switch statement should match the relative URLs you have configured inside `metadata.json` file (the address `.` is internally aliased to `home`, thus `home` pageId should be used to specify the page at the `.` route).
117+
118+
4. The routing inside community, and code splitting of the related code, should be set up inside `/src/shared/routes/Communities`:
119+
- Copy/paste one of the existing community folders and rename it into `/src/shared/routes/Communities/Demo`;
120+
- Inside `/src/shared/routes/Communities/Demo/index.jsx` you should change the name of code chunk in two places it is present (as value of `chunkName` prop, and inside `webpackChunkName` "magic comment");
121+
- Inside `/src/shared/routes/Communities/Demo/Routes.jsx` you define necesary routing, as with usual `react-router` routing code;
122+
- Finally, you link this routing code into `/src/shared/routes/Communities/Routes.jsx`.
134123

135124
5. At this point **demo** community is ready and accessible at the `/community/demo` route of the App (i.e., if we deploy dev version of the App to `community-west.topcoder-dev.com`, community will be accessible as `community-west.topcoder-dev.com/community/demo`).
136125

0 commit comments

Comments
 (0)