Current Behavior
When using dynamic imports for an external NPM module (e.g., import('sortablejs')), the generated chunk URL is incorrect. Flarum attempts to load the file from assets/forum/sortablejs.js instead of the extension's directory (e.g., assets/js/your-extension/forum/sortablejs.js), resulting in a 404 error.
Steps to Reproduce
- In a Flarum extension, dynamically import an external npm package (e.g.,
import('sortablejs')).
- Build the extension.
- Trigger the dynamic import in the browser.
- Check the network tab: Flarum tries to load
assets/forum/sortable.js, which returns a 404.
Expected Behavior
Flarum should load the chunk from the extension's own assets directory (e.g., assets/js/your-extension/forum/sortablejs.js).
Screenshots
No response
Environment
- Flarum version: 2.0.0-rc.1
Output of php flarum info
No response
Possible Solution
A workaround is to create a local wrapper file inside the extension's src/ directory (e.g., src/forum/wrapper.js containing import sortablejs from 'sortablejs'; export default sortablejs;) and import that local file instead.
Additional Context
No response
Current Behavior
When using dynamic imports for an external NPM module (e.g.,
import('sortablejs')), the generated chunk URL is incorrect. Flarum attempts to load the file fromassets/forum/sortablejs.jsinstead of the extension's directory (e.g.,assets/js/your-extension/forum/sortablejs.js), resulting in a 404 error.Steps to Reproduce
import('sortablejs')).assets/forum/sortable.js, which returns a 404.Expected Behavior
Flarum should load the chunk from the extension's own assets directory (e.g.,
assets/js/your-extension/forum/sortablejs.js).Screenshots
No response
Environment
Output of
php flarum infoNo response
Possible Solution
A workaround is to create a local wrapper file inside the extension's
src/directory (e.g.,src/forum/wrapper.jscontainingimport sortablejs from 'sortablejs'; export default sortablejs;) and import that local file instead.Additional Context
No response