cd1dae7c3c
Introduces the tooling to discover, build, and watch TypeScript/TSX React
source files across Moodle core and plugin components.
Build pipeline (.esbuild/)
- build.mjs: entry point; generates TS path aliases then runs all component
builds; accepts --dev flag for development mode; throws on build failure
- generate-aliases.mjs: scans component metadata to produce
tsconfig.aliases.json (@moodle/lms/<component>/* paths); skips rewrite
when content is unchanged
- plugin/plugincomponents.mjs: single source of all React build logic:
- buildPluginComponents(isDev): discovers and builds all components in
parallel via a single glob (public/**/js/react/src/**/*.{ts,tsx});
throws on any failure
- watchComponents(isDev, onRebuild): starts esbuild in native watch mode
using a shared incremental context; calls onRebuild with rebuilt source
paths after each change so callers can run follow-up tasks (e.g. lint)
- createBuildConfig(isDev): shared esbuild options (bundle, esm,
jsx:automatic, minify/sourcemap/jsxDev per mode); define derived
internally from isDev
- resolveComponentPaths(entry): exported src->build path mapping so both
full and single-file builders use the same resolution logic
- React, ReactDOM and @moodle/lms/* marked external via inline array;
no custom esbuild plugin needed
Grunt integration (.grunt/)
- tasks/react.js: single react task with three modes:
- grunt react — production build
- grunt react:dev — development build (sourcemaps, no minification)
- grunt react:watch — esbuild native watch; uses esbuild's own
context.watch() rather than grunt-contrib-watch so the incremental
build graph is preserved across rebuilds; ESLint runs in check-only
mode after each change to avoid re-triggering esbuild
- tasks/javascript.js: loads react.js and includes react in the js task
chain alongside amd and yui; all JS pipeline orchestration in one place
- tasks/startup.js: includes js/react/src/** in the startup file glob
- tasks/eslint.js: adds react ESLint target (fix: true) for source linting
- components.js: adds getReactTsSrcGlobList() for watch file patterns
- Gruntfile.js: exposes reactSrc glob and inReact flag in moodleEnv;
react task is not loaded directly — javascript.js owns that
Config / deps
- tsconfig.json: base TypeScript config; extends tsconfig.aliases.json
- tsconfig.aliases.json: initial generated @moodle/lms/* path mappings
- .eslintrc: adds react ESLint overrides for TypeScript/TSX files
- package.json: adds esbuild and @typescript-eslint/parser
69 lines
1.9 KiB
JSON
69 lines
1.9 KiB
JSON
{
|
|
"name": "Moodle",
|
|
"private": true,
|
|
"description": "Moodle",
|
|
"scripts": {
|
|
"upgradenote": "node .grunt/upgradenotes.mjs create"
|
|
},
|
|
"devDependencies": {
|
|
"@babel/core": "7.17.5",
|
|
"@babel/eslint-parser": "^7.21.3",
|
|
"@babel/eslint-plugin": "7.19.1",
|
|
"@typescript-eslint/parser": "^8.53.1",
|
|
"@babel/preset-env": "7.16.11",
|
|
"@xmldom/xmldom": "^0.8.7",
|
|
"ajv": "^8.12.0",
|
|
"async": "^3.2.5",
|
|
"babel-plugin-system-import-transformer": "^4.0.0",
|
|
"babel-plugin-transform-es2015-modules-amd-lazy": "2.0.1",
|
|
"babel-preset-minify": "0.5.1",
|
|
"chalk": "^5.3.0",
|
|
"commander": "^12.0.0",
|
|
"cross-env": "^7.0.3",
|
|
"docdash": "^2.0.2",
|
|
"eslint": "^8.56.0",
|
|
"esbuild": "^0.25.0",
|
|
"eslint-plugin-jsdoc": "^48.0.4",
|
|
"eslint-plugin-promise": "6.0.0",
|
|
"fb-watchman": "^2.0.2",
|
|
"gherkin-lint": "^4.2.2",
|
|
"git-tags-remote": "^1.0.5",
|
|
"glob": "^10.3.10",
|
|
"grunt": "^1.6.1",
|
|
"grunt-contrib-watch": "1.1.0",
|
|
"grunt-eslint": "24.0.0",
|
|
"grunt-rollup": "^11.9.0",
|
|
"grunt-sass": "3.1.0",
|
|
"grunt-stylelint": "^0.19.0",
|
|
"hugo-bin": "^0.80.2",
|
|
"hugo-lunr-indexer": "^1.1.3",
|
|
"inquirer": "^9.2.15",
|
|
"inquirer-search-list": "^1.2.6",
|
|
"jsdoc": "^4.0.2",
|
|
"jsdoc-to-markdown": "^8.0.0",
|
|
"jshint": "^2.13.4",
|
|
"jstoxml": "^3.2.3",
|
|
"npm-run-all": "^4.1.5",
|
|
"postcss-scss": "^4.0.9",
|
|
"rollup-plugin-terser": "^7.0.2",
|
|
"sass": "^1.58.3",
|
|
"semver": "7.3.5",
|
|
"shifter": "https://github.com/andrewnicols/shifter/archive/v1.2.0_moodle-0.tar.gz",
|
|
"stylelint": "^15.11.0",
|
|
"stylelint-csstree-validator": "^3.0.0",
|
|
"winston": "^3.13.0",
|
|
"xpath": "0.0.32"
|
|
},
|
|
"engines": {
|
|
"node": ">=22.11.0 <23"
|
|
},
|
|
"browserslist": [
|
|
">0.3%",
|
|
"last 2 versions",
|
|
"not ie >= 0",
|
|
"not op_mini all",
|
|
"not Opera > 0",
|
|
"not dead"
|
|
]
|
|
}
|