Skip to content

publicPath not being respected when accessing chunks on output module mode #19432

@bsunderhus

Description

@bsunderhus

Bug report

#19431

What is the current behavior?

This is a minimal example to showcase a problem with webpack5 and es modules async chunk loader.

Here's the reproduction codebase: https://stackblitz.com/edit/webpack-webpack-js-org-kxd532jl?file=README.md

It seems like publicPath is not being properly respected when loading chunks.

To test this out:

  1. npm run build
  2. npm start

npm start will run two servers:

  1. the main distribution folder with the html file pointing to the main entry output main.js
  2. the public folder containing all the chunks generated (port 9010)

If you try to access the application, if everything goes well you should see the number 1 on the page.
This won't happen in this case as webpack will try to access the chunk without properly following publicPatch (publicPath is pointing to http://localhost:9010/)

What is the expected behavior?

The expected behavior would be for the publicPath to be properly concatenated on the start of the chunk loading mechanism.

Other relevant information:
webpack version: 5.99.5
Node.js version: 20.19.0
Operating System: Windows
Additional tools:

Metadata

Metadata

Assignees

No one assigned

    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