2019-12-02 18:55:19 +00:00
|
|
|
/**
|
|
|
|
* A Rollup plugin accepting a file overrides map and changing
|
|
|
|
* module sources to the overridden ones where provided. Files
|
|
|
|
* without overrides are loaded from disk.
|
|
|
|
*
|
|
|
|
* @param {Map<string, string>} fileOverrides
|
|
|
|
*/
|
2023-07-27 15:24:49 +00:00
|
|
|
export default function rollupFileOverrides( fileOverrides ) {
|
2019-12-02 18:55:19 +00:00
|
|
|
return {
|
|
|
|
name: "jquery-file-overrides",
|
|
|
|
load( id ) {
|
|
|
|
if ( fileOverrides.has( id ) ) {
|
|
|
|
|
|
|
|
// Replace the module by a fake source.
|
|
|
|
return fileOverrides.get( id );
|
|
|
|
}
|
|
|
|
|
|
|
|
// Handle this module via the file system.
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
};
|
2023-07-27 15:24:49 +00:00
|
|
|
}
|