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

Dynamically import marked module #97

Merged
merged 4 commits into from
Mar 17, 2023
Merged

Conversation

jafaircl
Copy link
Contributor

@jafaircl jafaircl commented Apr 5, 2018

Import marked module dynamically so it's only loaded when the markdown pipe is used.


@Pipe({name: 'markdown'})
export class MarkdownPipe implements PipeTransform {
transform(content: string): string {
async transform(content: string): Promise<string> {
const marked = await import('marked');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any advantage behind doing import('marked') inside transform method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It splits the marked module into its own chunk so that it’s only loaded if necessary.

@geromegrignon geromegrignon merged commit 2faae23 into gothinkster:master Mar 17, 2023
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.

3 participants