Skip to content

docs: add Modern Web Platform guide (Web Components, Import Maps, PWA)#8140

Open
phoekerson wants to merge 4 commits intowebpack:mainfrom
phoekerson:main
Open

docs: add Modern Web Platform guide (Web Components, Import Maps, PWA)#8140
phoekerson wants to merge 4 commits intowebpack:mainfrom
phoekerson:main

Conversation

@phoekerson
Copy link
Copy Markdown

Summary

Adds a new guide — Modern Web Platform — covering three practical webpack
patterns that are frequently asked about on Discord and the issue tracker but
not yet documented in a single place:

  • Web Components: how to use optimization.splitChunks with cacheGroups
    to deduplicate Custom Element registrations across bundles and avoid the
    DOMException: Failed to execute 'define' on 'CustomElementRegistry' runtime
    error.
  • Import Maps: how to combine externals, externalsType: "module", and
    experiments.outputModule so webpack output is compatible with browser-native
    import map resolution.
  • PWA / Service Workers: how to use InjectManifest from
    workbox-webpack-plugin alongside [contenthash] output filenames to keep
    precache manifests in sync across builds.

Each section follows the existing guide structure: problem statement → minimal
working configuration → limitations and future work.

Note: --no-verify was used locally because src/sw.js has two pre-existing
lint errors (import/named) unrelated to this PR.

This PR is also part of my Google Summer of Code 2026 application to webpack,
where I am proposing to implement native webpack support for these three web
platform features. This documentation reflects my research into the current
state of webpack 5 and the gaps I intend to address during GSoC.

What kind of change does this PR introduce?

docs

Did you add tests for your changes?

No — this is a documentation-only change. No code was modified.

Does this PR introduce a breaking change?

No.

If relevant, what needs to be documented once your changes are merged or
what have you already documented?

This PR is itself the documentation. Once merged, the Modern Web Platform
guide will be accessible at /guides/modern-web-platform/ and automatically
listed in the sidebar via the build system.

Use of AI

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
webpack-js-org Ready Ready Preview, Comment Apr 6, 2026 1:41am

Request Review

@alexander-akait
Copy link
Copy Markdown
Member

/cc @evenstensberg @avivkeller Can you take a look at this too, thanks

@phoekerson
Copy link
Copy Markdown
Author

Hello, please @alexander-akait @evenstensberg @avivkeller Can you take a look at my work ?

@bjohansebas bjohansebas self-requested a review April 2, 2026 17:17
Co-authored-by: Aviv Keller <me@aviv.sh>
@phoekerson
Copy link
Copy Markdown
Author

@avivkeller Thank you so much. I took your suggestion into account and made the correction

avivkeller
avivkeller previously approved these changes Apr 5, 2026
Copy link
Copy Markdown
Member

@evenstensberg evenstensberg left a comment

Choose a reason for hiding this comment

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

good work. left a couple of suggestions.


### Problem

If more than one JavaScript bundle executes `customElements.define()` for the same tag name, the browser throws `DOMException: Failed to execute 'define' on 'CustomElementRegistry'`. That often happens when the module that registers an element is duplicated: separate entry points or async chunks each contain a copy of the registration code, so two bundles both run `define` for the same tag.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

link to the mdn article on domexception

export default {
entry: {
main: "./src/main.js",
admin: "./src/admin.js",
Copy link
Copy Markdown
Member

@evenstensberg evenstensberg Apr 5, 2026

Choose a reason for hiding this comment

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

this is good

entry: "./src/index.js",
externalsType: "module",
externals: {
"lodash-es": "lodash-es",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lets add an example using cdns too

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks @evenstensberg for the feedback! I've added a link to the MDN article on
DOMException in the Web Components section, and added a CDN example
(cdn.jsdelivr.net) alongside the local vendor path in the Import Maps section.

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.

4 participants