20 lines
864 B
JavaScript
20 lines
864 B
JavaScript
/**
|
|
* Make `import './thing.css'` a no-op under the Node test runner.
|
|
*
|
|
* Vite turns a CSS import into a side effect that injects a stylesheet; Node
|
|
* has no such notion and refuses the file outright with
|
|
* ERR_UNKNOWN_FILE_EXTENSION. That is fine for the pure tests, which never
|
|
* import a component — but the map has to be MOUNTED to be tested at all, and
|
|
* leaflet's own stylesheet comes with it.
|
|
*
|
|
* Styling is not what those tests check. They count polylines and markers in
|
|
* the document, which leaflet creates regardless of whether any CSS loaded. So
|
|
* every `.css` specifier resolves to an empty module and the import vanishes.
|
|
*/
|
|
export function resolve(specifier, context, next) {
|
|
if (specifier.endsWith('.css')) {
|
|
return { url: 'data:text/javascript,export default {}', shortCircuit: true };
|
|
}
|
|
return next(specifier, context);
|
|
}
|