Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve build tools for use with third-party extensions. (mathjax/MathJax#3086) #997

Merged
merged 1 commit into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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