mirror of
https://github.com/moodle/moodle.git
synced 2026-03-13 08:23:51 +08:00
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
13 lines
299 B
JSON
13 lines
299 B
JSON
{
|
|
"extends": "./tsconfig.aliases.json", // Added to extend the generated aliases.
|
|
"compilerOptions": {
|
|
"target": "ES2020",
|
|
"module": "ESNext",
|
|
"moduleResolution": "Node",
|
|
"jsx": "react",
|
|
"strict": true,
|
|
"skipLibCheck": true
|
|
},
|
|
"include": ["public/**/esm/src/**/*"]
|
|
}
|