Skip to content

Dynamic hostname publicPath feature (from --target lib config) is broken for early resolved resources #1253

Closed
@doublemarked

Description

@doublemarked

Version

3.0.0-beta.9

Reproduction link

https://github.com/doublemarked/vue-libconf-issues

Steps to reproduce

  1. git clone https://github.com/doublemarked/vue-libconf-issues.git
  2. npm install && npm run build && npm run demo
  3. Load http://localhost:8000
  4. Observe errors in browser console

What is expected?

The library entry code sports the excellent idea of assigning Webpack's publicPath at runtime to allow modules to be used cross domain / webroot. Per the comments in resolveLibConfig.js:

  // use dynamic publicPath so this can be deployed anywhere
  // the actual path will be determined at runtime by checking
  // document.currentScript.src.

It is expected that the dynamic publicPath should be resolved early enough to apply to all resource loading.

What is actually happening?

That functionality, implemented in entry-lib.js, unfortunately does not run early enough to affect resources that are loaded as part of the initial code chunk. It seems to currently only work if you call import() later, after initial load.


Context: In my real-world project this bug is preventing me from loading CSS in my library and having webpack properly resolve the hostname for the bundled assets (fonts, images, etc).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions