overleaf/services/web/scripts/check_overleafModuleImports.mjs
Liangjun Song 26f3f3e2e2 Merge pull request #21097 from overleaf/ls-scripts-to-esm-1
Migrate scripts folder to esm 1/x

GitOrigin-RevId: 4a4bc9a161f144fdb40ce3f2a0a9313b36c6df81
2024-10-21 08:04:42 +00:00

26 lines
813 B
JavaScript

import CE_CONFIG from '../config/settings.defaults.js'
import PRO_CONFIG from '../config/settings.overrides.server-pro.js'
import SAAS_CONFIG from '../config/settings.webpack.js'
function getOverleafModuleImports(settings) {
return Object.keys(settings.overleafModuleImports).sort().join(',')
}
function main() {
const CE = getOverleafModuleImports(CE_CONFIG)
const PRO = getOverleafModuleImports(CE_CONFIG.mergeWith(PRO_CONFIG))
const SAAS = getOverleafModuleImports(CE_CONFIG.mergeWith(SAAS_CONFIG))
if (CE !== PRO) {
throw new Error(
'settings.defaults is missing overleafModuleImports defined in settings.overrides.server-pro'
)
}
if (CE !== SAAS) {
throw new Error(
'settings.defaults is missing overleafModuleImports defined in settings.webpack'
)
}
}
main()