Merge pull request #15120 from overleaf/jpa-mj-val-loader

[web] migrate modules-ide/modules-main from val-loader to babel macro

GitOrigin-RevId: 5114dab96d5bf34285ae42f539fed78e2f068a12
This commit is contained in:
Jakob Ackermann
2023-10-16 08:04:12 +00:00
committed by Copybot
parent a4c426744d
commit 95148980bc
6 changed files with 29 additions and 92 deletions
+25
View File
@@ -1,6 +1,29 @@
const fs = require('fs')
const Path = require('path')
const { merge } = require('@overleaf/settings/merge')
const MODULES_PATH = Path.join(__dirname, '../modules')
const entryPointsIde = []
const entryPointsMain = []
fs.readdirSync(MODULES_PATH).forEach(module => {
const entryPathIde = Path.join(
MODULES_PATH,
module,
'/frontend/js/ide/index.js'
)
if (fs.existsSync(entryPathIde)) {
entryPointsIde.push(entryPathIde)
}
const entryPathMain = Path.join(
MODULES_PATH,
module,
'/frontend/js/main/index.js'
)
if (fs.existsSync(entryPathMain)) {
entryPointsMain.push(entryPathMain)
}
})
let defaultFeatures, siteUrl
// Make time interval config easier.
@@ -815,6 +838,8 @@ module.exports = {
oauth2Server: [],
managedGroupSubscriptionEnrollmentNotification: [],
managedGroupEnrollmentInvite: [],
entryPointsIde,
entryPointsMain,
},
moduleImportSequence: [
+2 -24
View File
@@ -1,25 +1,3 @@
const fs = require('fs')
const path = require('path')
import importOverleafModules from '../frontend/macros/import-overleaf-module.macro'
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'),
}
}
export default importOverleafModules('entryPointsIde')
+2 -24
View File
@@ -1,25 +1,3 @@
const fs = require('fs')
const path = require('path')
import importOverleafModules from '../frontend/macros/import-overleaf-module.macro'
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/main/index.js'
)
if (fs.existsSync(entryPath)) {
acc.push(entryPath)
}
return acc
}, entryPoints)
}
module.exports = function () {
return {
code: entryPoints.map(entryPoint => `import '${entryPoint}'`).join('\n'),
}
}
export default importOverleafModules('entryPointsMain')
-1
View File
@@ -343,7 +343,6 @@
"timekeeper": "^2.2.0",
"to-string-loader": "^1.2.0",
"typescript": "^5.0.4",
"val-loader": "^5.0.1",
"webpack": "^5.83.1",
"webpack-assets-manifest": "^5.1.0",
"webpack-cli": "^5.1.1",
-18
View File
@@ -209,24 +209,6 @@ module.exports = {
},
],
},
// Allow for injection of modules dependencies by reading contents of
// modules directory and adding necessary dependencies
{
test: path.join(__dirname, 'modules/modules-main.js'),
use: [
{
loader: 'val-loader',
},
],
},
{
test: path.join(__dirname, 'modules/modules-ide.js'),
use: [
{
loader: 'val-loader',
},
],
},
{
// Expose jQuery and $ global variables
test: require.resolve('jquery'),