Added definition of getMainAssets method (#43168)

Co-authored-by: Ivan Zuev <i-zuev@yandex-team.ru>
This commit is contained in:
DavyJohnes 2020-03-23 18:51:29 +03:00 committed by GitHub
parent 47dd795052
commit 4cf0aeeab5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View File

@ -79,6 +79,11 @@ export class ChunkExtractor {
*/
requireEntrypoint(name?: string): { default: ComponentType };
/**
* Get required assets definition
*/
getMainAssets(scriptType?: string): Chunk[];
/**
* Get scripts as a string of `<script>` tags
*/

View File

@ -1,5 +1,5 @@
import * as React from 'react';
import { ChunkExtractor, AttrFn } from '@loadable/server';
import { ChunkExtractor, AttrFn, Chunk } from '@loadable/server';
// Should be satisfied by `stats` or `statsFile`
new ChunkExtractor({ stats: {} });
@ -16,7 +16,8 @@ const {
requireEntrypoint,
getInlineStyleTags,
getInlineStyleElements,
getCssString
getCssString,
getMainAssets
} = new ChunkExtractor({ stats: {} });
// collectChunks
@ -47,6 +48,13 @@ const attrFn: AttrFn = (chunk) => {
};
};
// getMainAssets
{
// should return an array of Chunk
const assets: Chunk[] = getMainAssets();
const typedAssets: Chunk[] = getMainAssets('script');
}
// getLinkElements
{
// Should return an array of React elements