Skip to content

Commit

Permalink
Merge pull request #997 from mathjax/issue3086
Browse files Browse the repository at this point in the history
Improve build tools for use with third-party extensions.  (mathjax/MathJax#3086)
  • Loading branch information
dpvc authored Sep 15, 2023
2 parents 04fb966 + d2ea1c7 commit 4d2f170
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion components/bin/build
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const EXCLUDE = new Map((config.exclude || []).map(name => [name, true])); // f
const EXCLUDESUBDIRS = !!config.excludeSubdirs; // exclude subdirectories or not
const JS = config.js || config.mathjax || mjPath; // path to the compiled .js files
const LIB = config.lib || './lib'; // path to the lib directory to create
const TS = config.ts || JS.replace(/[cm]js$/, 'ts'); // path to the .ts files
const TS = config.ts || path.join(JS, '..', 'ts'); // path to the .ts files
const GLOBAL = config.global || mjGlobal; // path to the global.js file
const VERSION = config.version || mjGlobal.replace(/global/, 'version'); // path to the version.js file
const TYPE = config.type || getType(); // the module type
Expand Down
4 changes: 3 additions & 1 deletion components/bin/pack
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ async function webpackLib(dir) {
if (!config) return;
const jsdir = (config.js ? path.resolve(dir, config.js).replace(/js$/, target) : jsPath);
const jsRE = fileRegExp(jsdir);
const jsRE2 = (config.js ? fileRegExp(path.resolve(dir, config.js)) : /^$/);
const libRE = fileRegExp(path.resolve(jsdir, '..', 'components'));

//
Expand Down Expand Up @@ -131,7 +132,8 @@ async function webpackLib(dir) {
.replace(rootRE, '[mathjax]')
.replace(fontRE, '[$1]/$2')
.replace(jsRE, '[js]')
.replace(libRE, '[lib]');
.replace(jsRE2, '[js]')
.replace(libRE, '[build]');
if (name.charAt(0) !== '.' && name.charAt(0) !== '[') {
name = path.relative(dir, name);
}
Expand Down
7 changes: 7 additions & 0 deletions components/webpack.common.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ function fullPath(resource) {
const PLUGINS = function (js, dir, target, font, jax, name) {
//
// Replace a11y/util and components/mjs/root with the webpack versions
// and map mathjax-full/js to mathjax-full/${target}
//
const plugins = [
new webpack.NormalModuleReplacementPlugin(
Expand All @@ -76,6 +77,12 @@ const PLUGINS = function (js, dir, target, font, jax, name) {
new webpack.NormalModuleReplacementPlugin(
/mjs\/components\/mjs\/root\.js/,
'../../../components/root-pack.js'
),
new webpack.NormalModuleReplacementPlugin(
/mathjax-full\/js\//,
function (resource) {
resource.request = resource.request.replace(/mathjax-full\/js\//, `mathjax-full/${target}/`);
}
)
];

Expand Down

0 comments on commit 4d2f170

Please sign in to comment.