overleaf/services/web/modules/modules-ide.js
nate stemen 49066b6ffe Merge pull request #2855 from overleaf/msm-update-modules-imports-esm
Update modules-ide and modules-main to generate ESM modules

GitOrigin-RevId: 2463591afd50a71cf6a4f728b54db3289f9c13ed
2020-05-22 03:24:43 +00:00

25 lines
554 B
JavaScript

const fs = require('fs')
const path = require('path')
const MODULES_PATH = path.join(__dirname, './')
const entryPoints = []
if (fs.existsSync(MODULES_PATH)) {
fs.readdirSync(MODULES_PATH).reduce((acc, module) => {
const entryPath = path.join(
MODULES_PATH,
module,
'/frontend/js/ide/index.js'
)
if (fs.existsSync(entryPath)) {
acc.push(entryPath)
}
return acc
}, entryPoints)
}
module.exports = function() {
return {
code: entryPoints.map(entryPoint => `import '${entryPoint}'`).join('\n')
}
}