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-13 10:31:49 +02:00 committed by Copybot
parent 6212b352fb
commit 3e34467e12
6 changed files with 29 additions and 92 deletions

25
package-lock.json generated
View file

@ -41071,22 +41071,6 @@
"node": ">=10.12.0"
}
},
"node_modules/val-loader": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/val-loader/-/val-loader-5.0.1.tgz",
"integrity": "sha512-r4h7b9AuvGQU1vyC4rAMoJNMG8fJUE6CYAqlM265tOdnZrZC6axVawBg2GlQ9+6osPCJjw4/vyADiSBAFlhzlg==",
"dev": true,
"engines": {
"node": ">= 14.15.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/webpack"
},
"peerDependencies": {
"webpack": "^5.0.0"
}
},
"node_modules/valid-data-url": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/valid-data-url/-/valid-data-url-2.0.0.tgz",
@ -44645,7 +44629,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",
@ -53018,7 +53001,6 @@
"underscore": "^1.13.1",
"utf-8-validate": "^5.0.2",
"uuid": "^3.0.1",
"val-loader": "^5.0.1",
"valid-data-url": "^2.0.0",
"valid-url": "^1.0.9",
"webpack": "^5.83.1",
@ -79019,13 +79001,6 @@
"convert-source-map": "^1.6.0"
}
},
"val-loader": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/val-loader/-/val-loader-5.0.1.tgz",
"integrity": "sha512-r4h7b9AuvGQU1vyC4rAMoJNMG8fJUE6CYAqlM265tOdnZrZC6axVawBg2GlQ9+6osPCJjw4/vyADiSBAFlhzlg==",
"dev": true,
"requires": {}
},
"valid-data-url": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/valid-data-url/-/valid-data-url-2.0.0.tgz",

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: [

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')

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')

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",

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'),