32 Commits

Author SHA1 Message Date
Gareth Barnard
257e2b414a
MDL-78400 JavaScript: Building JS puts build files in src dir on Win. 2023-06-05 14:52:16 +01:00
Paul Holden
e5132eff2f
MDL-77995 javascript: more precise path matching building JS. 2023-05-15 09:05:51 +01:00
Andrew Nicols
a9b4b297ac Merge branch 'MDL-77606' of https://github.com/skodak/moodle into MOODLE_401_STABLE 2023-04-17 10:34:55 +08:00
Petr Skoda
073deca0e1 MDL-77606 grunt: fix Windows compatibility
Backport of MDL-77748.
2023-04-17 10:34:09 +08:00
Petr Skoda
2cc1182b16 MDL-77606 core: switch to Dart sass
Backport of MDL-73144.
2023-04-17 10:33:50 +08:00
Eloy Lafuente (stronk7)
127174088a MDL-73610 nodejs: Small updates to required packages
The main goal of this issue is to avoid scanners (Dependabot
and friends), reporting about security issues with the current
xmldom 0.6.0 package.

Note that this doesn't affect prod at all, because it's a dev
dependency, hardly exploitable. So it's not a security fix, just
a security_benefit, if something.

So here, we are updating from xmldom 0.6.0 to @xmldom/xmldom 0.8.7
(note that the package was renamed in 0.7.0, so it's the very same)

Also, when proceeding with the changes, it was detected that we
are incorrectly declaring @babel/eslint-parser as a normal dependency
instead of a development one, so we are also fixing that little detail.

The commands executed to get the changes above applied have been:

- nvm use
- npm install @xmldom/xmldom@^0.8.7 --save-dev
- npm uninstall xmldom
- npm install @babel/eslint-parser@^7.17.0 --save-dev

(we haven't run a complete re-install because we only want to modify
the minimum possible at this stage).
2023-04-06 14:59:43 +02:00
Andrew Nicols
fefd6f2bd8 MDL-77559 js: Revert "MDL-75012 js: Remove grunt-contrib-uglify"
This reverts commit ca4614c2991c2cc2eed0a788f3bfd37b3d686dac.
2023-03-09 08:21:19 +08:00
Andrew Nicols
d209e2cc57 MDL-77559 js: Revert "MDL-75012 js: Bump stylelint and components"
This reverts commit 644e9da8bb8418c1223ed394528f48bf2d9dea9c.
2023-03-09 08:21:15 +08:00
Andrew Nicols
a96fcc22ca MDL-77559 js: Revert "MDL-75012 js: Update browserslist"
This reverts commit bf81d5f0ba5aedf74ce8cd4eb05bad372ac996de.
2023-03-09 08:21:12 +08:00
Andrew Nicols
63ecbc57d6 MDL-77559 js: Revert "MDL-75012 js: Use our own jsdoc wrapper"
This reverts commit 89f7402fc28a402e3380066c854f319d5896e97a.
2023-03-09 08:20:57 +08:00
Andrew Nicols
df1dc82fee MDL-77559 js: Revert "MDL-75012 js: Bump Babel dependencies"
This reverts commit b963401b8fa83b616fe1784a04c03d8d52d0d5f0.
2023-03-09 08:20:42 +08:00
Andrew Nicols
b963401b8f MDL-75012 js: Bump Babel dependencies
Please note that whilst some dependencies have higher versions
available, these are not compatible at this time.
2023-03-02 12:15:25 +08:00
Andrew Nicols
89f7402fc2 MDL-75012 js: Use our own jsdoc wrapper
grunt-jsdoc is abandoned and only works with an older version of jsdoc.

This is a very simple wrapper around jsdoc itself.
2023-02-28 10:19:51 +08:00
Andrew Nicols
bf81d5f0ba MDL-75012 js: Update browserslist
To avoid build changes we exclude older versions of Android browser
2023-02-28 10:19:51 +08:00
Andrew Nicols
644e9da8bb MDL-75012 js: Bump stylelint and components 2023-02-28 10:19:50 +08:00
Andrew Nicols
ca4614c299 MDL-75012 js: Remove grunt-contrib-uglify
We stopped using this when we updated our processes to support ESMs in
MDL-62497. Removal of the dependency was missed at the time.
2023-02-28 10:19:50 +08:00
Andrew Nicols
bb7cce1e56 MDL-76727 core: Allow phpcs configuration to be overridden locally
This change reduces the priority of the shipped phpcs configuration to
allow for local overrides.

This is beneficial in several situations:
- when users wish to apply stricter or additional standards
- when the integration team wishes to trial new rules
2022-12-20 09:35:45 +08:00
Andrew Nicols
ffac002f0d MDL-75783 javascript: Add optional jsconfig configuration
This commit adds a new Grunt task which generates a jsconfig.json file.

This file is described at
https://code.visualstudio.com/docs/languages/jsconfig and can be used
to configure vscode and other similar editors to understand our module
loading.

This task is an optional task for Grunt and can be run with:

    npx grunt jsconfig

The file is git-ignored and will not affect normal usage.
2022-10-18 09:33:04 +08:00
Andrew Nicols
1b18a4c142 MDL-74511 core: Add phpcs default config 2022-05-06 11:39:10 +08:00
Andrew Nicols
38fff2d83f MDL-74511 core: Add phpcs config generator 2022-04-18 15:38:14 +08:00
Andrew Nicols
e1b9d5f3cd MDL-73915 js: Drop support for IE and android
Moodle announced that support for IE would be dropped back in August
2020 with Moodle 3.9 but not active steps were taken at that time. That
decision was made in MDLSITE-6109 and this particular step was meant to
be taken in Moodle 3.10.

This is the first step taken to actively drop support for IE.

This commit also bumps the browser support pattern from 0.25% to 0.3%.
The percentage here includes any browser where at least this percentage
of users worldwide may be using a browser. In this case it causes
support for Android 4.3-4.4 to be dropped, which relate to Android
KitKat (released 2013).

This combination of changes means that all of the supported browsers in
our compatibility list support modern features including async,
for...of, classes, native Promises, and more which has a huge impact on
the ease of debugging code, and drastically reduces the minified file
size because a number of native Polyfills included by Babel are no
longer included.
2022-02-23 08:55:20 +08:00
Andrew Nicols
0a4047ab31 MDL-73915 js: Switch amd minification to terser
Unfortunately the babel minify-mangle plugin seems to be abandoned and
in certain circumstances can be very buggy. The only safe options are to
disable it, or to switch to a different minification library.

Not minifying our javascript is not ideal, so this commit updates the
javascript tasks to use a rollup, combined with babel, and terser.

Babel still converts code from ES/UMD/AMD to AMD modules with the
relevant browser support, whilst terser minifies the code.

The rollup bundler handles tracking and creation of sourcemaps, and
supports better parallelisation of the tasks.

Since the upgrade to Node LTS/Gallium requires an upgrade to @babel/core
and eslint, which change the built files anyway, this seems like the
ideal time to make this change.
2022-02-23 08:55:09 +08:00
Andrew Nicols
c1e639c41a MDL-71882 grunt: Replace module names
When a third-party AMD module is provided with an included name we must
replace it with a name that we are able to use.

The structure of an AMD module define function is:

    [name], [dependencies], [callback]
    String, Array,          Function

Each of these is (strangely) optional.

We know that the name is the only String and will always be the first,
and we can use AST to remove a provided name before adding the
Moodle-specific name.

This should be a safe change and not lead to any changes in built code,
but will make it easier to include third-party code.

An additional logging line is also included to inform developers that a
change was made.
2021-11-17 09:16:55 +08:00
Neill Magill
377c618083 MDL-72326 grunt: Fix component library grunt on Windows
Before this change grunt tried to use the Linux version of files in
node_modules/.bin rather than the Windows version which is generated
by npm.

To avoid this issue we need to run the components directly.
2021-10-04 13:18:08 +01:00
Bas Brands
3de68ad434 MDL-61460 tool_componentlibrary: Documentation for Moodle UI components
- This tool is only available for admins
- Before using this tool the hosting admin will need to have NPM installed and be able to run grunt
- To create the docs pages for the library run "grunt componentlibrary"
- After the pages are created the Library is available in Site adminstration > Development > UI Component Library
2021-07-08 09:51:02 +08:00
Andrew Nicols
fa073102d3 MDL-61460 Grunt: Add Component Library tasks
This new task handles building of component library documentation,
including the markdown to HTML, an index of the generated content used
for searching, and the CSS for the component library.
2021-07-08 09:51:02 +08:00
Andrew Nicols
2f2ecdae4a MDL-61460 Grunt: Make startup tasks configurable by tasks 2021-07-08 09:51:02 +08:00
Andrew Nicols
1a62c82fef MDL-71113 js: Add jsdoc configuration and Grunt 2021-06-18 09:38:04 +08:00
Andrew Nicols
657cbe587e MDL-71736 javascript: Run the ignorefiles command more liberally 2021-06-09 18:54:24 +08:00
Eloy Lafuente (stronk7)
2d287b8adf MDL-71365 grunt: fix boost ignores order and missing LF @ EOF 2021-04-18 00:10:46 +02:00
Andrew Nicols
32638b3a45 MDL-68496 Grunt: Stylelint should only lint relevant component files
Prior to this change the Grunt stylelint command was too greedy when
determining which files hsould be linted.

This change modifies the watch command to only watch relevant files and
subdirectories of each component directories. This means that unrelated
CSS and SCSS files are no longer watched for changes, and has the added
benefit of significantly increaseing the startup speed of grunt.

Without this patch applied the watch tasks were checking for matches in
the node_modules, and vendor directories.
2021-03-22 15:18:47 +08:00
Andrew Nicols
61fca0e05c MDL-68496 grunt: Restructure grunt tasks into subdirectories
Prior to this change all Grunt features were in a single Gruntfile.js
but this has become difficult to manage and maintain.

This commit moves the existing dependencies for component calculation
and babel moduel definition into a new .grunt directory, and
restructures the existing tasks in Gruntfile.js into separate task
configuration files.

This improves the maintainability of the Grunt build system and allows
for easier future expansion.
2021-03-19 12:56:35 +08:00