Minify: Move getTar() to static.js

`static.js` is the only file that uses it.
This commit is contained in:
Richard Hansen 2021-02-11 13:43:10 -05:00 committed by John McLear
parent 996dc81825
commit 7f4a7156e2
2 changed files with 24 additions and 21 deletions

View file

@ -48,26 +48,6 @@ const LIBRARY_WHITELIST = [
'unorm',
];
// Rewrite tar to include modules with no extensions and proper rooted paths.
exports.getTar = () => {
const prefixLocalLibraryPath = (path) => {
if (path.charAt(0) === '$') {
return path.slice(1);
} else {
return `ep_etherpad-lite/static/js/${path}`;
}
};
const tarJson = fs.readFileSync(path.join(__dirname, 'tar.json'), 'utf8');
const tar = {};
for (const [key, relativeFiles] of Object.entries(JSON.parse(tarJson))) {
const files = relativeFiles.map(prefixLocalLibraryPath);
tar[prefixLocalLibraryPath(key)] = files
.concat(files.map((p) => p.replace(/\.js$/, '')))
.concat(files.map((p) => `${p.replace(/\.js$/, '')}/index.js`));
}
return tar;
};
// What follows is a terrible hack to avoid loop-back within the server.
// TODO: Serve files from another service, or directly from the file system.
const requestURI = (url, method, headers, callback) => {