Fix: infer publicPath from webpack output.publicPath for import map#61
Merged
titouanmathis merged 3 commits intodevelopfrom Mar 11, 2026
Merged
Conversation
Move publicPath resolution from resolveDependencies() (called before webpack config is built) into the preset's extendWebpack callback, where the consumer's output.publicPath is already available. - Extract resolvePublicPath() into a shared utility - Mutate twigData.importMap in extendWebpack to prefix self-hosted entries - Remove publicPath param from resolveDependencies() (always bare paths) - Update PlaygroundDependenciesPlugin to use shared resolvePublicPath() Fixes #60 Co-authored-by: Claude <claude@anthropic.com>
Deploying studiometa-playground with
|
| Latest commit: |
fe758c0
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://ca9444b7.studiometa-playground.pages.dev |
| Branch Preview URL: | https://feature--60-import-map-infer.studiometa-playground.pages.dev |
Export SizeUnchanged@studiometa/playground
|
Co-authored-by: Claude <claude@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #61 +/- ##
===========================================
+ Coverage 17.82% 18.51% +0.68%
===========================================
Files 53 54 +1
Lines 937 940 +3
Branches 165 165
===========================================
+ Hits 167 174 +7
+ Misses 757 753 -4
Partials 13 13
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
The plugin already owns self-hosted dep bundling, _headers emission, and publicPath resolution. The import map mutation is the same concern and now lives in the plugin's thisCompilation hook instead of the preset's extendWebpack callback. The plugin receives the twigData.importMap reference and prefixes self-hosted entries during compilation — before HtmlWebpackPlugin renders templates. Co-authored-by: Claude <claude@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #60 — the
publicPathpreset option is now truly optional. When omitted, it is automatically inferred from webpack'soutput.publicPath.Problem
resolveDependencies()was called in the preset handler before the webpack config was built. At that point,output.publicPathdidn't exist yet — it was only set later when the consumer'swebpack()callback ran. This forced consumers to duplicate the publicPath value in both the preset options and the webpack config.Solution
resolveDependencies()no longer accepts apublicPathparameter — self-hosted entries always get bare paths (e.g./static/deps/…)extendWebpackcallback (which runs after all consumer config callbacks), the effective publicPath is resolved and used to mutatetwigData.importMap— prefixing self-hosted entries. This works because the twig data object is a reference captured by the prototyping preset's closure.resolvePublicPath()utility is extracted and used by both the preset andPlaygroundDependenciesPlugin.Changes
resolve-public-path.tsresolve-dependencies.tspublicPathparam andnormalizePublicPath()playground.ts(preset)extendWebpackPlaygroundDependenciesPlugin.tsresolvePublicPath()instead of private method