Skip to content

Conversation

@thet
Copy link
Member

@thet thet commented Nov 24, 2022

Basically this PR fixes a problem where including e.g. pat-tiptap which depends on pat-tootip also includes pat-markdown and pat-syntax-highlight with all the language definitions. This makes the generated bundle huge and creates a suboptimal situation for module federation bundles. Because I want to add the generated bundles to npm packages directly, so that they can be used via unpkg or jsdelivr CDN services. Therefore I'd like to have small bundles and not upload dozens of MB to npm and pollute node_modules directories unnecessarily.

Note: what is not used is not downloaded, so this PR solves not a runtime problem. Except for this one commit except for the one commit where:

Loading of pat-syntax-highlight is optimized - before all languages were bundled into the highlight.js chunk, now each language is loaded on demand.

@thet thet marked this pull request as draft November 28, 2022 08:33
thet added 11 commits December 7, 2022 00:43
Avoid code linting problem and make clear the init method is/can be
asynchronous.
Add "is_input" to test if a element is of input type.
This is basically the same as $(":input") from Sizzle/jQuery.
…-inject.

Wait a tick before registering the markdown type handler for pat-inject.

With that there is no need for pat-inject to be imported before
pat-markdown, as long as it is imported side by side with pat-markdown.
Only register the markdown data type handler when the pattern is available.

Not hard-depending and importing pat-markdown fixes a problem where only
including pat-tooltip also included pat-markdown and
pat-syntax-highlight with it's big highlight.js library.

This can reduce the generated bundle size significantly.
Only highlight code blocks when the pattern is available.

Not hard-depending and importing pat-syntax-highlight fixes a problem
where only including pat-markup also included pat-syntax-highlight and
it's big highlight.js library.

This can reduce the generated bundle size significantly.
Fix a typo where all languages were registered as "javascript".
Change the import so that no language is included by default.
Instead import the languages dynamically.

This reduces the download size when pat-syntaax-highlight is used
significantly.
@thet thet force-pushed the thet-optimizations branch from 6dec1f8 to c34d4a0 Compare December 6, 2022 23:55
@thet thet marked this pull request as ready for review December 6, 2022 23:56
@thet thet merged commit 46ba4df into master Dec 6, 2022
@thet thet deleted the thet-optimizations branch December 6, 2022 23:57
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.

2 participants