aboutsummaryrefslogtreecommitdiffstats
path: root/build/tasks/lib/rollupFileOverridesPlugin.js
diff options
context:
space:
mode:
Diffstat (limited to 'build/tasks/lib/rollupFileOverridesPlugin.js')
-rw-r--r--build/tasks/lib/rollupFileOverridesPlugin.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/build/tasks/lib/rollupFileOverridesPlugin.js b/build/tasks/lib/rollupFileOverridesPlugin.js
new file mode 100644
index 000000000..fecb4efaa
--- /dev/null
+++ b/build/tasks/lib/rollupFileOverridesPlugin.js
@@ -0,0 +1,22 @@
+/**
+ * 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
+ */
+export default function rollupFileOverrides( fileOverrides ) {
+ 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;
+ }
+ };
+}