Skip to content

fix(webpack): chunk module path checking fails with dotted directories#4179

Merged
SychO9 merged 1 commit intoflarum:2.xfrom
glowingblue:di/webpack-config
Feb 8, 2025
Merged

fix(webpack): chunk module path checking fails with dotted directories#4179
SychO9 merged 1 commit intoflarum:2.xfrom
glowingblue:di/webpack-config

Conversation

@DavideIadeluca
Copy link
Contributor

@DavideIadeluca DavideIadeluca commented Feb 8, 2025

Fixes #0000
Resolves issues when the path contains unexpected dots. Also see https://discuss.flarum.org/d/36971-issues-developing-2x-locally

Changes proposed in this pull request:
Change algorithm for resolving chunks for code splitting in dev mode. GPT'd my way through resolving this issue... No idea if those changes introduced here are actually good or not / also work on other operating systems etc.

Feel free to close this PR and create a new one if this can be done better

Reviewers should focus on:
Leaving this PR as draft because I'm not too confident about this, but in theory, it would be ready for review

Screenshot

Necessity

  • Has the problem that is being solved here been clearly explained?
  • If applicable, have various options for solving this problem been considered?
  • For core PRs, does this need to be in core, or could it be in an extension?
  • Are we willing to maintain this for years / potentially forever?

Confirmed

  • Frontend changes: tested on a local Flarum installation.
  • Backend changes: tests are green (run composer test).
  • Core developer confirmed locally this works as intended.
  • Tests have been added, or are not appropriate here.

Required changes:

  • Related documentation PR: (Remove if irrelevant)

Resolves issues when the path contains unexpected periods
@SychO9
Copy link
Member

SychO9 commented Feb 8, 2025

what was the result of the logging? we have to know what the issue was first.

@SychO9
Copy link
Member

SychO9 commented Feb 8, 2025

nevermind I just saw the discuss comment

@DavideIadeluca
Copy link
Contributor Author

DavideIadeluca commented Feb 8, 2025

For completeness sake, here is the logging output (before changing the logic) after adding in the debugging logic you shared:

js git:(2.x) ✗ yarn dev
yarn run v1.22.22
$ webpack --mode development --watch
importPathResolved /Users/iadeluca/Documents/GitHub/docker-flarum-2.x/flarum-framework-2.x/framework/core/js/src/forum/components/SignUpModal
module.resource /Users/iadeluca/Documents/GitHub/docker-flarum-2.x/flarum-framework-2.x/framework/core/js/src/forum/components/SignUpModal.tsx
condition false
Could not find chunk for /Users/iadeluca/Documents/GitHub/docker-flarum-2.x/flarum-framework-2.x/framework/core/js/src/forum/components/SignUpModal
Could not find chunk for /Users/iadeluca/Documents/GitHub/docker-flarum-2.x/flarum-framework-2.x/framework/core/js/src/forum/components/PostStream
Could not find chunk for /Users/iadeluca/Documents/GitHub/docker-flarum-2.x/flarum-framework-2.x/framework/core/js/src/forum/components/PostStreamScrubber
Could not find chunk for /Users/iadeluca/Documents/GitHub/docker-flarum-2.x/flarum-framework-2.x/framework/core/js/src/forum/components/ReplyComposer
Could not find chunk for /Users/iadeluca/Documents/GitHub/docker-flarum-2.x/flarum-framework-2.x/framework/core/js/src/forum/components/LogInModal
importPathResolved /Users/iadeluca/Documents/GitHub/docker-flarum-2.x/flarum-framework-2.x/framework/core/js/src/forum/components/SignUpModal
module.resource /Users/iadeluca/Documents/GitHub/docker-flarum-2.x/flarum-framework-2.x/framework/core/js/src/forum/components/SignUpModal.tsx
condition false
Could not find chunk for /Users/iadeluca/Documents/GitHub/docker-flarum-2.x/flarum-framework-2.x/framework/core/js/src/forum/components/SignUpModal
Could not find chunk for /Users/iadeluca/Documents/GitHub/docker-flarum-2.x/flarum-framework-2.x/framework/core/js/src/forum/components/LogInModal
Could not find chunk for /Users/iadeluca/Documents/GitHub/docker-flarum-2.x/flarum-framework-2.x/framework/core/js/src/common/components/SearchModal
Could not find chunk for /Users/iadeluca/Documents/GitHub/docker-flarum-2.x/flarum-framework-2.x/framework/core/js/src/forum/components/EditPostComposer
Could not find chunk for /Users/iadeluca/Documents/GitHub/docker-flarum-2.x/flarum-framework-2.x/framework/core/js/src/common/components/EditUserModal
Could not find chunk for /Users/iadeluca/Documents/GitHub/docker-flarum-2.x/flarum-framework-2.x/framework/core/js/src/forum/components/PostsPage
Could not find chunk for /Users/iadeluca/Documents/GitHub/docker-flarum-2.x/flarum-framework-2.x/framework/core/js/src/forum/components/DiscussionsUserPage
Could not find chunk for /Users/iadeluca/Documents/GitHub/docker-flarum-2.x/flarum-framework-2.x/framework/core/js/src/forum/components/SettingsPage
Could not find chunk for /Users/iadeluca/Documents/GitHub/docker-flarum-2.x/flarum-framework-2.x/framework/core/js/src/forum/components/UserSecurityPage
Could not find chunk for /Users/iadeluca/Documents/GitHub/docker-flarum-2.x/flarum-framework-2.x/framework/core/js/src/forum/components/NotificationsPage
Could not find chunk for /Users/iadeluca/Documents/GitHub/docker-flarum-2.x/flarum-framework-2.x/framework/core/js/src/forum/components/DiscussionComposer
Could not find chunk for /Users/iadeluca/Documents/GitHub/docker-flarum-2.x/flarum-framework-2.x/framework/core/js/src/forum/components/LogInModal
Could not find chunk for /Users/iadeluca/Documents/GitHub/docker-flarum-2.x/flarum-framework-2.x/framework/core/js/src/forum/components/Composer
Could not find chunk for /Users/iadeluca/Documents/GitHub/docker-flarum-2.x/flarum-framework-2.x/framework/core/js/src/common/components/SearchModal
Could not find chunk for /Users/iadeluca/Documents/GitHub/docker-flarum-2.x/flarum-framework-2.x/framework/core/js/src/common/components/EditUserModal
Could not find chunk for /Users/iadeluca/Documents/GitHub/docker-flarum-2.x/flarum-framework-2.x/framework/core/js/src/forum/components/LogInModal
importPathResolved /Users/iadeluca/Documents/GitHub/docker-flarum-2.x/flarum-framework-2.x/framework/core/js/src/forum/components/SignUpModal
module.resource /Users/iadeluca/Documents/GitHub/docker-flarum-2.x/flarum-framework-2.x/framework/core/js/src/forum/components/SignUpModal.tsx
condition false
Could not find chunk for /Users/iadeluca/Documents/GitHub/docker-flarum-2.x/flarum-framework-2.x/framework/core/js/src/forum/components/SignUpModal
assets by path forum/components/*.js 169 KiB
  asset forum/components/UserSecurityPage.js 27.5 KiB [compared for emit] (name: forum/components/UserSecurityPage) 1 related asset
  asset forum/components/SettingsPage.js 25.4 KiB [compared for emit] (name: forum/components/SettingsPage) 1 related asset
  asset forum/components/PostStream.js 22.7 KiB [compared for emit] (name: forum/components/PostStream) 1 related asset
...

Copy link
Member

@SychO9 SychO9 left a comment

Choose a reason for hiding this comment

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

Yup this will do it. Thanks!

@SychO9 SychO9 changed the title chore(webpack): change algorithm for resolving chunks fix(webpack): change algorithm for resolving chunks Feb 8, 2025
@DavideIadeluca DavideIadeluca marked this pull request as ready for review February 8, 2025 16:49
@DavideIadeluca DavideIadeluca requested a review from a team as a code owner February 8, 2025 16:49
@SychO9 SychO9 changed the title fix(webpack): change algorithm for resolving chunks fix(webpack): chunk module path checking fails with dotted directories Feb 8, 2025
@SychO9 SychO9 added this to the 2.0.0-beta.3 milestone Feb 8, 2025
@SychO9 SychO9 added the type/bug label Feb 8, 2025
@SychO9 SychO9 merged commit 333bbb1 into flarum:2.x Feb 8, 2025
21 checks passed
@DavideIadeluca DavideIadeluca deleted the di/webpack-config branch February 10, 2025 05:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants