Skip to content

pat-syntax-highlight bundles every highlight.js theme four times over #1318

Todo

Description

@petschki

With highlight.js 11 the latest @plone/mockup bundle contains 516 theme chunks. With highlight.js 10.7.3 (Mockup 5.7.0-alpha.3) it was about 100.

The cause is the dynamic import in src/pat/syntax-highlight/syntax-highlight--implementation.js:

`highlight.js/styles/${theme_name}.css`

webpack creates a chunk for every file this can match. highlight.js 11.12.0 ships:

Files in styles/ Count
*.css 82
*.min.css 82
base16/*.css 176
base16/*.min.css 176

The .min.css files match too, with a theme name like github.min. They are the same themes again, so 258 chunks are duplicates.

Suggestion: exclude the minified files from the import context.

await import(
    /* webpackExclude: /\.min\.css$/ */
    `highlight.js/styles/${theme_name}.css`
);

I have not tried this. Whether the base16/ themes should stay is your call: they are 176 more chunks, but someone may use them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions