As per severalguides, using Leaflet with Webpack requires the following import:
import 'leaflet/dist/leaflet.css';
The above path should be resolved relative to the node_modules directory (works correctly with style-loader in webpack), but, in esm-loader-css, it is instead resolved relative to the current directory (which is wrong, as the path does not begin with ./), leading to this error:
node:internal/process/esm_loader:34
internalBinding('errors').triggerUncaughtException(
^
[Error: ENOENT: no such file or directory, open '/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/lib/components/Leaflet/leaflet/dist/leaflet.css'] {
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '/Users/maxpatiiuk/site/python/specify7/specifyweb/frontend/js_src/lib/components/Leaflet/leaflet/dist/leaflet.css'
}
As per several guides, using Leaflet with Webpack requires the following import:
The above path should be resolved relative to the node_modules directory (works correctly with style-loader in webpack), but, in esm-loader-css, it is instead resolved relative to the current directory (which is wrong, as the path does not begin with
./
), leading to this error:same applies for Leaflet plugins:
Workaround for now is to explicitly spell out the path relative to node_modules in my import: