Skip to content

Commit 55967ea

Browse files
committed
update readme
1 parent 897b415 commit 55967ea

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,24 @@ const MyPage = () => (
434434
);
435435
```
436436

437+
## Webpack integration (experimental)
438+
439+
```js
440+
// get mark somehow
441+
import {getMarkedChunks} from 'react-imported-component/server';
442+
443+
const chunkNames = getMarkedChunks(marks);
444+
445+
// use flush-webpack-chunks to discover assets behind chunk name
446+
```
447+
448+
## React-snap
449+
`react-imported-component` is the only (even) theoretically compatible loader for [react-snap](https://github.com/stereobooster/react-snap).
450+
451+
452+
## Webpack-external-import
453+
`react-imported-component` is the only (even) theoretically compatible loader for [webpack-external-import](https://github.com/ScriptedAlchemy/webpack-external-import).
454+
437455
## SSR (Server side rendering)
438456
It was usually a headache - async components and SSR, which is currently sync.
439457
React-imported-component break this cycle, making ServerSide rendering sync, and providing

src/markerMapper.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@ import {Mark, MarkMeta} from "./types";
22
import {markMeta} from "./loadable";
33
import {markerOverlap} from "./marks";
44

5-
const getMarkedMeta = (marks: Mark, mapping: (meta: MarkMeta) => string) => (
6-
(new Set(
5+
const getMarkedMeta = (marks: Mark, mapping: (meta: MarkMeta) => string) => {
6+
if (markMeta.length === 0) {
7+
throw new Error('react-imported-component: no import meta-information found. Have you imported async-requires?');
8+
}
9+
10+
return Array.from(new Set(
711
markMeta
812
.filter(meta => markerOverlap(meta.mark, marks))
913
.map(mapping)
1014
.filter(Boolean)
11-
)).values()
12-
);
15+
).values());
16+
};
1317

1418
export const getMarkedChunks = (marks: Mark) => getMarkedMeta(marks, meta => meta.chunkName);
1519
export const getMarkedFileNames = (marks: Mark) => getMarkedMeta(marks, meta => meta.fileName);

0 commit comments

Comments
 (0)