Minify: Compatibility for all vendors/*.js files

This commit is contained in:
Richard Hansen 2021-02-28 05:21:45 -05:00 committed by John McLear
parent b0d78d662e
commit 99b3918f2c

View file

@ -123,6 +123,15 @@ const sanitizePathname = (p) => {
return p; return p;
}; };
const compatPaths = {
'js/browser.js': 'js/vendors/browser.js',
'js/farbtastic.js': 'js/vendors/farbtastic.js',
'js/gritter.js': 'js/vendors/gritter.js',
'js/html10n.js': 'js/vendors/html10n.js',
'js/jquery.js': 'js/vendors/jquery.js',
'js/nice-select.js': 'js/vendors/nice-select.js',
};
/** /**
* creates the minifed javascript for the given minified name * creates the minifed javascript for the given minified name
* @param req the Express request * @param req the Express request
@ -139,11 +148,11 @@ const minify = async (req, res) => {
return; return;
} }
// Backward compatibility for plugins that were written when jQuery lived at // Backward compatibility for plugins that require() files from old paths.
// src/static/js/jquery.js. const newLocation = compatPaths[filename.replace(/^plugins\/ep_etherpad-lite\/static\//, '')];
if (['js/jquery.js', 'plugins/ep_etherpad-lite/static/js/jquery.js'].indexOf(filename) !== -1) { if (newLocation != null) {
logger.warn(`request for deprecated jQuery path: ${filename}`); logger.warn(`request for deprecated path "${filename}", replacing with "${newLocation}"`);
filename = 'js/vendors/jquery.js'; filename = newLocation;
} }
/* Handle static files for plugins/libraries: /* Handle static files for plugins/libraries: