diff --git a/.gitignore b/.gitignore index c6aca5c5a..5257230a6 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,6 @@ node_modules components/src/**/lib js +js6 es5 +es6 diff --git a/components/bin/build b/components/bin/build index 946cb0723..108962edf 100755 --- a/components/bin/build +++ b/components/bin/build @@ -49,7 +49,9 @@ const mjGlobal = path.join('..', mjPath, 'components', 'global.js'); /** * Read the configuration for the component */ -const config = JSON.parse(fs.readFileSync(process.argv[2] || 'build.json')); +const build = (process.argv[2] || 'build.json'); +process.chdir(path.dirname(build)); +const config = JSON.parse(fs.readFileSync(path.basename(build))); function getType() { const component = config.component || 'part'; diff --git a/components/bin/copy b/components/bin/copy index 6810045e4..b57ddfe5c 100755 --- a/components/bin/copy +++ b/components/bin/copy @@ -32,10 +32,18 @@ const path = require('path'); */ const INDENT = ' '; +/** + * The es value (6 or empty) + */ +const es = (process.argv[2] || '').replace(/^5$/, ''); + /** * The configuration data for the copy operation */ -const config = JSON.parse(fs.readFileSync(process.argv[2] || 'copy.json')); +const config = JSON.parse(fs.readFileSync(process.argv[3] || 'copy.json')); +if (es) { + config.to = config.to.replace(/\/es5\//, `/es${es}/`); +} /** * Get the directory for node modules (either the parent of the MathJax directory, diff --git a/components/bin/js2js6 b/components/bin/js2js6 new file mode 100755 index 000000000..ecde463a9 --- /dev/null +++ b/components/bin/js2js6 @@ -0,0 +1,34 @@ +#! /usr/bin/env node + +/************************************************************* + * + * Copyright (c) 2023 The MathJax Consortium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @fileoverview Changes js to js6 in compiled js files + * + * @author dpvc@mathjax.org (Davide Cervone) + */ + + +const fs = require("fs"); + +const file = process.argv[2]; + +const code = String(fs.readFileSync(file)).replace(/\/js\//, '/js6/'); +fs.writeFileSync(file, code); + + diff --git a/components/bin/makeAll b/components/bin/makeAll index 0f347fd2b..d6e4208e0 100755 --- a/components/bin/makeAll +++ b/components/bin/makeAll @@ -29,38 +29,70 @@ const fs = require('fs'); const path = require('path'); const {execSync} = require('child_process'); +/** + * The default options + */ const options = { - recursive: true + recursive: true, + verbose: true, + es: '' }; /** - * Get the directories to process and check for options + * Get the directories to process */ const dirs = process.argv.slice(2); -if (dirs[0] === '--no-subdirs') { - dirs.shift(); - options.recursive = false; +/** + * Check for options + */ +while (dirs[0].substr(0, 2) === '--') { + const option = dirs.shift(); + if (option === '--') { + break; + } + if (option === '--no-subdirs') { + options.recursive = false; + continue; + } + if (option.substr(0, 4) === '--es') { + options.es = option.substr(4).replace(/^5$/, ''); + continue; + } + if (option === '--terse') { + options.verbose = false; + continue; + } } +// +// Make sure there is at least one directory +// if (dirs.length === 0) { dirs.push('.'); } /** - * The commads to runb the bin/build scripts - * (on Unix, could be done without the 'node ' prefix, but - * for Windows, these are needed.) + * The commads to run the various scripts + * (on Unix, could be done without the 'node ' prefix, but for Windows, these are needed.) */ const build = `node '${path.join(__dirname, 'build')}'`; -const copy = `node '${path.join(__dirname, 'copy')}'`; -const pack = `node '${path.join(__dirname, 'pack')}'`; +const copy = `node '${path.join(__dirname, 'copy')}' '${options.es}'`; +const pack = `node '${path.join(__dirname, 'pack')}' '${options.es}'`; + +/** + * @param {string} name The file name to turn into a Regular expression + * @return {RegExp} The regular expression for the name, + */ +function fileRegExp(name) { + return new RegExp(name.replace(/([\\.{}[\]()?*^$])/g, '\\$1'), 'g'); +} /** * Regular expression for the components directory */ -const compRE = new RegExp(path.dirname(__dirname).replace(/([\\.{}[\]()?*^$])/g, '\\$1')); -const dirRE = new RegExp(process.cwd().replace(/([\\.{}[\]()?*^$])/g, '\\$1')); +const compRE = fileRegExp(path.dirname(__dirname)); +const dirRE = fileRegExp(process.cwd()); /** * Process the contents of an array of directories @@ -117,7 +149,9 @@ function buildLib(dir) { try { process.chdir(dir); const result = execSync(build); - console.info(' ' + String(result).replace(/\n/g, '\n ')); + if (options.verbose) { + console.info(' ' + String(result).replace(/\n/g, '\n ')); + } } catch (err) { console.info(' ' + err.message); } @@ -137,7 +171,9 @@ function webpackLib(dir) { try { process.chdir(dir); const result = execSync(pack); - console.info(' ' + String(result).replace(/\n/g, '\n ')); + if (options.verbose) { + console.info(' ' + String(result).replace(/\n/g, '\n ')); + } } catch (err) { console.info(' ' + err.message); } @@ -152,11 +188,13 @@ function webpackLib(dir) { function copyLib(dir) { const file = path.join(dir, 'copy.json'); if (!fs.existsSync(file)) return; - console.info('Copying ' + dir.replace(compRE, '')); + console.info('Copying ' + dir.replace(compRE, '').replace(dirRE, '.')); try { process.chdir(dir); const result = execSync(copy); - console.info(' ' + String(result).replace(/\n/g, '\n ')); + if (options.verbose) { + console.info(' ' + String(result).replace(/\n/g, '\n ')); + } } catch (err) { console.info(' ' + err.message); } diff --git a/components/bin/pack b/components/bin/pack index d0a67b06a..07df609ca 100755 --- a/components/bin/pack +++ b/components/bin/pack @@ -1,6 +1,5 @@ #! /usr/bin/env node - /************************************************************* * * Copyright (c) 2018 The MathJax Consortium @@ -29,6 +28,11 @@ const fs = require('fs'); const path = require('path'); const {spawn} = require('child_process'); +/** + * The es version (6 or '') + */ +const es = (process.argv[2] || '').replace(/^5$/, ''); + /** * @param {string} name The file name to turn into a Regular expression * @return {RegExp} The regular expression for the name, @@ -48,9 +52,12 @@ function fileSize(file) { /** * Regular expressions for the components directory and the MathJax .js location */ +const nodePath = path.join(path.dirname(path.dirname(__dirname)), 'node_modules'); +const jsPath = path.join(path.dirname(path.dirname(__dirname)), 'js' + es); const compRE = fileRegExp(path.dirname(__dirname)); -const rootRE = fileRegExp(path.join(path.dirname(path.dirname(__dirname)), 'js')); -const nodeRE = fileRegExp(path.join(path.dirname(path.dirname(__dirname)), 'node_modules')); +const rootRE = fileRegExp(jsPath); +const nodeRE = fileRegExp(nodePath); +const fontRE = new RegExp(path.join('^.*\\/(mathjax-.*?)(?:-font)?', 'js' + es)); /** * @return {JSON} The parsed JSON from webpack @@ -58,7 +65,7 @@ const nodeRE = fileRegExp(path.join(path.dirname(path.dirname(__dirname)), 'node async function readJSON() { return new Promise((ok, fail) => { const buffer = []; - const child = spawn('npx', ['webpack', '--json']); + const child = spawn('npx', ['webpack', '--json', '--env', 'es=' + es]); child.stdout.on('data', (data) => buffer.push(String(data))); child.stdout.on('close', (code) => { const json = JSON.parse(buffer.join('')); @@ -83,7 +90,11 @@ async function webpackLib(dir) { // // Get js directory from the webpack.config.js file // - const jsdir = require(path.resolve(dir, 'webpack.config.js')).plugins[0].definitions.__JSDIR__; + let package = require(path.resolve(dir, 'webpack.config.js')); + if (typeof package === 'function') { + package = package({es}); + } + const jsdir = package.plugins?.[0]?.definitions?.__JSDIR__ || process.cwd(); const jsRE = fileRegExp(jsdir); const libRE = fileRegExp(path.resolve(jsdir, '..', 'components')); @@ -109,6 +120,7 @@ async function webpackLib(dir) { let name = module.name .replace(compRE, '[components]') .replace(rootRE, '[mathjax]') + .replace(fontRE, '[$1]') .replace(nodeRE, '[node]') .replace(jsRE, '[js]') .replace(libRE, '[lib]'); @@ -129,4 +141,4 @@ async function webpackLib(dir) { } } -webpackLib(process.argv[2] || '.'); +webpackLib(process.argv[3] || '.'); diff --git a/components/bin/version b/components/bin/version index 5eb0c6dab..357c95042 100755 --- a/components/bin/version +++ b/components/bin/version @@ -32,7 +32,7 @@ const version = require(package).version; const lines = `/************************************************************* * - * Copyright (c) 2022 The MathJax Consortium + * Copyright (c) 2023 The MathJax Consortium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/components/src/a11y/assistive-mml/webpack.config.js b/components/src/a11y/assistive-mml/webpack.config.js index b89b94d5b..ee8318bd0 100644 --- a/components/src/a11y/assistive-mml/webpack.config.js +++ b/components/src/a11y/assistive-mml/webpack.config.js @@ -1,11 +1,10 @@ const PACKAGE = require('../../../webpack.common.js'); -module.exports = PACKAGE( - 'a11y/assistive-mml', // the package to build - '../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'a11y/assistive-mml', + libs: [ 'components/src/input/mml/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/a11y/complexity/webpack.config.js b/components/src/a11y/complexity/webpack.config.js index c049f6d89..5d85d1f8c 100644 --- a/components/src/a11y/complexity/webpack.config.js +++ b/components/src/a11y/complexity/webpack.config.js @@ -1,12 +1,11 @@ const PACKAGE = require('../../../webpack.common.js'); -module.exports = PACKAGE( - 'a11y/complexity', // the package to build - '../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'a11y/complexity', + libs: [ 'components/src/a11y/semantic-enrich/lib', 'components/src/input/mml/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/a11y/explorer/webpack.config.js b/components/src/a11y/explorer/webpack.config.js index b44c45e70..4f2ea01a6 100644 --- a/components/src/a11y/explorer/webpack.config.js +++ b/components/src/a11y/explorer/webpack.config.js @@ -1,14 +1,13 @@ const PACKAGE = require('../../../webpack.common.js'); -module.exports = PACKAGE( - 'a11y/explorer', // the package to build - '../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'a11y/explorer', + libs: [ 'components/src/ui/menu/lib', 'components/src/a11y/semantic-enrich/lib', 'components/src/a11y/sre/lib', 'components/src/input/mml/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/a11y/semantic-enrich/webpack.config.js b/components/src/a11y/semantic-enrich/webpack.config.js index 8de3e025f..24a0a46fd 100644 --- a/components/src/a11y/semantic-enrich/webpack.config.js +++ b/components/src/a11y/semantic-enrich/webpack.config.js @@ -1,12 +1,11 @@ const PACKAGE = require('../../../webpack.common.js'); -module.exports = PACKAGE( - 'a11y/semantic-enrich', // the package to build - '../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'a11y/semantic-enrich', + libs: [ 'components/src/input/mml/lib', 'components/src/core/lib', 'components/src/a11y/sre/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/a11y/sre/webpack.config.js b/components/src/a11y/sre/webpack.config.js index c89adb4b7..84a1cb4dc 100644 --- a/components/src/a11y/sre/webpack.config.js +++ b/components/src/a11y/sre/webpack.config.js @@ -1,12 +1,11 @@ const PACKAGE = require('../../../webpack.common.js'); -module.exports = PACKAGE( - 'a11y/sre', // the package to build - '../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'a11y/sre', + libs: [ 'components/src/input/mml/lib', 'components/src/core/lib', 'components/src/startup/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/adaptors/liteDOM/webpack.config.js b/components/src/adaptors/liteDOM/webpack.config.js index 6c29ad8c4..62d5bcb36 100644 --- a/components/src/adaptors/liteDOM/webpack.config.js +++ b/components/src/adaptors/liteDOM/webpack.config.js @@ -1,8 +1,7 @@ const PACKAGE = require('../../../webpack.common.js'); -module.exports = PACKAGE( - 'adaptors/liteDOM', // the package to build - '../../../../js', // location of the MathJax js library - ['components/src/core/lib'], // packages to link to - __dirname // our directory -); +module.exports = PACKAGE({ + name: 'adaptors/liteDOM', + libs: ['components/src/core/lib'], + dir: __dirname +}); diff --git a/components/src/core/webpack.config.js b/components/src/core/webpack.config.js index c52325252..649e6a178 100644 --- a/components/src/core/webpack.config.js +++ b/components/src/core/webpack.config.js @@ -1,8 +1,6 @@ const PACKAGE = require('../../webpack.common.js'); -module.exports = PACKAGE( - 'core', // the package to build - '../../../js', // location of the MathJax js library - [], // packages to link to - __dirname // our directory -); +module.exports = PACKAGE({ + name: 'core', + dir: __dirname +}); diff --git a/components/src/input/asciimath/webpack.config.js b/components/src/input/asciimath/webpack.config.js index 7f9850852..d8ca06680 100644 --- a/components/src/input/asciimath/webpack.config.js +++ b/components/src/input/asciimath/webpack.config.js @@ -1,8 +1,7 @@ const PACKAGE = require('../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/asciimath', // the package to build - '../../../../js', // location of the MathJax js library - ['components/src/core/lib'], // packages to link to - __dirname // our directory -); +module.exports = PACKAGE({ + name: 'input/asciimath', + libs: ['components/src/core/lib'], + dir: __dirname +}); diff --git a/components/src/input/mml/entities/webpack.config.js b/components/src/input/mml/entities/webpack.config.js index 2386e2bcc..45b03dad5 100644 --- a/components/src/input/mml/entities/webpack.config.js +++ b/components/src/input/mml/entities/webpack.config.js @@ -1,8 +1,7 @@ const PACKAGE = require('../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/mml/entities', // the package to build - '../../../../../js', // location of the MathJax js library - ['components/src/core/lib'], // packages to link to - __dirname // our directory -); +module.exports = PACKAGE({ + name: 'input/mml/entities', + libs: ['components/src/core/lib'], + dir: __dirname +}); diff --git a/components/src/input/mml/extensions/mml3/webpack.config.js b/components/src/input/mml/extensions/mml3/webpack.config.js index b09f30c9f..5d7683fc6 100644 --- a/components/src/input/mml/extensions/mml3/webpack.config.js +++ b/components/src/input/mml/extensions/mml3/webpack.config.js @@ -1,11 +1,10 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/mml/extensions/mml3', // the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/mml/extensions/mml3', + libs: [ 'components/src/input/mml/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/mml/webpack.config.js b/components/src/input/mml/webpack.config.js index 301b5f845..3a48ec9e1 100644 --- a/components/src/input/mml/webpack.config.js +++ b/components/src/input/mml/webpack.config.js @@ -1,8 +1,7 @@ const PACKAGE = require('../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/mml', // the package to build - '../../../../js', // location of the MathJax js library - ['components/src/core/lib'], // packages to link to - __dirname // our directory -); +module.exports = PACKAGE({ + name: 'input/mml', + libs: ['components/src/core/lib'], + dir: __dirname +}); diff --git a/components/src/input/tex-base/webpack.config.js b/components/src/input/tex-base/webpack.config.js index df380e755..1d27f7d01 100644 --- a/components/src/input/tex-base/webpack.config.js +++ b/components/src/input/tex-base/webpack.config.js @@ -1,8 +1,7 @@ const PACKAGE = require('../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex-base', // the package to build - '../../../../js', // location of the MathJax js library - ['components/src/core/lib'], // packages to link to - __dirname // our directory -); +module.exports = PACKAGE({ + name: 'input/tex-base', + libs: ['components/src/core/lib'], + dir: __dirname +}); diff --git a/components/src/input/tex-full/webpack.config.js b/components/src/input/tex-full/webpack.config.js index 6c65c1a88..ac4f104a4 100644 --- a/components/src/input/tex-full/webpack.config.js +++ b/components/src/input/tex-full/webpack.config.js @@ -1,11 +1,10 @@ const PACKAGE = require('../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex-full', // the package to build - '../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex-full', + libs: [ 'components/src/startup/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/action/webpack.config.js b/components/src/input/tex/extensions/action/webpack.config.js index 4375ae570..7351c0acd 100644 --- a/components/src/input/tex/extensions/action/webpack.config.js +++ b/components/src/input/tex/extensions/action/webpack.config.js @@ -1,11 +1,10 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/action', // the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/action', + libs: [ 'components/src/input/tex-base/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/all-packages/webpack.config.js b/components/src/input/tex/extensions/all-packages/webpack.config.js index bdb842437..63b478757 100644 --- a/components/src/input/tex/extensions/all-packages/webpack.config.js +++ b/components/src/input/tex/extensions/all-packages/webpack.config.js @@ -1,12 +1,11 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/all-packages',// the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/all-packages', + libs: [ 'components/src/input/tex-base/lib', 'components/src/startup/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/ams/webpack.config.js b/components/src/input/tex/extensions/ams/webpack.config.js index 1bff208a7..d178aef9e 100644 --- a/components/src/input/tex/extensions/ams/webpack.config.js +++ b/components/src/input/tex/extensions/ams/webpack.config.js @@ -1,11 +1,10 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/ams', // the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/ams', + libs: [ 'components/src/input/tex-base/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/amscd/webpack.config.js b/components/src/input/tex/extensions/amscd/webpack.config.js index c4fa76238..a0b07fe99 100644 --- a/components/src/input/tex/extensions/amscd/webpack.config.js +++ b/components/src/input/tex/extensions/amscd/webpack.config.js @@ -1,11 +1,10 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/amscd', // the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/amscd', + libs: [ 'components/src/input/tex-base/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/autoload/webpack.config.js b/components/src/input/tex/extensions/autoload/webpack.config.js index 353163dd3..b047f248a 100644 --- a/components/src/input/tex/extensions/autoload/webpack.config.js +++ b/components/src/input/tex/extensions/autoload/webpack.config.js @@ -1,13 +1,12 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/autoload', // the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/autoload', + libs: [ 'components/src/input/tex/extensions/require/lib', 'components/src/input/tex-base/lib', 'components/src/startup/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/bbox/webpack.config.js b/components/src/input/tex/extensions/bbox/webpack.config.js index 26cf2d1a7..da97b01e5 100644 --- a/components/src/input/tex/extensions/bbox/webpack.config.js +++ b/components/src/input/tex/extensions/bbox/webpack.config.js @@ -1,11 +1,10 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/bbox', // the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/bbox', + libs: [ 'components/src/input/tex-base/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/boldsymbol/webpack.config.js b/components/src/input/tex/extensions/boldsymbol/webpack.config.js index a71489413..33851ae7c 100644 --- a/components/src/input/tex/extensions/boldsymbol/webpack.config.js +++ b/components/src/input/tex/extensions/boldsymbol/webpack.config.js @@ -1,11 +1,10 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/boldsymbol', // the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/boldsymbol', + libs: [ 'components/src/input/tex-base/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/braket/webpack.config.js b/components/src/input/tex/extensions/braket/webpack.config.js index 04df1028d..efb84e0b5 100644 --- a/components/src/input/tex/extensions/braket/webpack.config.js +++ b/components/src/input/tex/extensions/braket/webpack.config.js @@ -1,11 +1,10 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/braket', // the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/braket', + libs: [ 'components/src/input/tex-base/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/bussproofs/webpack.config.js b/components/src/input/tex/extensions/bussproofs/webpack.config.js index 2afad5e71..74ed7f50d 100644 --- a/components/src/input/tex/extensions/bussproofs/webpack.config.js +++ b/components/src/input/tex/extensions/bussproofs/webpack.config.js @@ -1,11 +1,11 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/bussproofs', // the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/bussproofs', + js: '../../../../../../js', + libs: [ 'components/src/input/tex-base/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/cancel/webpack.config.js b/components/src/input/tex/extensions/cancel/webpack.config.js index 0324cb7a1..5de1bb1fb 100644 --- a/components/src/input/tex/extensions/cancel/webpack.config.js +++ b/components/src/input/tex/extensions/cancel/webpack.config.js @@ -1,12 +1,11 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/cancel', // the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/cancel', + libs: [ 'components/src/input/tex-base/lib', 'components/src/input/tex/extensions/enclose/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/cases/webpack.config.js b/components/src/input/tex/extensions/cases/webpack.config.js index 057036b38..25158d570 100644 --- a/components/src/input/tex/extensions/cases/webpack.config.js +++ b/components/src/input/tex/extensions/cases/webpack.config.js @@ -1,14 +1,13 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/cases', // the package to build - '../../../../../../js', // location of the compiled js files - [ // packages to link to (relative to Mathjax components) +module.exports = PACKAGE({ + name: 'input/tex/extensions/cases', + libs: [ 'components/src/input/tex-base/lib', 'components/src/input/tex/extensions/ams/lib', 'components/src/input/tex/extensions/empheq/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/centernot/webpack.config.js b/components/src/input/tex/extensions/centernot/webpack.config.js index 28d313fdf..4e65d1317 100644 --- a/components/src/input/tex/extensions/centernot/webpack.config.js +++ b/components/src/input/tex/extensions/centernot/webpack.config.js @@ -1,11 +1,10 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/centernot', // the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/centernot', + libs: [ 'components/src/input/tex-base/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/color/webpack.config.js b/components/src/input/tex/extensions/color/webpack.config.js index 3a656402f..b0f700c4e 100644 --- a/components/src/input/tex/extensions/color/webpack.config.js +++ b/components/src/input/tex/extensions/color/webpack.config.js @@ -1,11 +1,10 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/color', // the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/color', + libs: [ 'components/src/input/tex-base/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/colortbl/webpack.config.js b/components/src/input/tex/extensions/colortbl/webpack.config.js index 74b52a8d3..81c54db93 100644 --- a/components/src/input/tex/extensions/colortbl/webpack.config.js +++ b/components/src/input/tex/extensions/colortbl/webpack.config.js @@ -1,11 +1,10 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/colortbl', // the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/colortbl', + libs: [ 'components/src/input/tex-base/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/colorv2/webpack.config.js b/components/src/input/tex/extensions/colorv2/webpack.config.js index cb7959bc3..d31d6af08 100644 --- a/components/src/input/tex/extensions/colorv2/webpack.config.js +++ b/components/src/input/tex/extensions/colorv2/webpack.config.js @@ -1,11 +1,10 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/colorv2', // the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/colorv2', + libs: [ 'components/src/input/tex-base/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/configmacros/webpack.config.js b/components/src/input/tex/extensions/configmacros/webpack.config.js index a7b83b2e7..b60948826 100644 --- a/components/src/input/tex/extensions/configmacros/webpack.config.js +++ b/components/src/input/tex/extensions/configmacros/webpack.config.js @@ -1,13 +1,12 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/configmacros',// the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/configmacros', + libs: [ 'components/src/input/tex/extensions/newcommand/lib', 'components/src/input/tex-base/lib', 'components/src/core/lib', 'components/src/startup/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/empheq/webpack.config.js b/components/src/input/tex/extensions/empheq/webpack.config.js index 735dd6d90..fe314be80 100644 --- a/components/src/input/tex/extensions/empheq/webpack.config.js +++ b/components/src/input/tex/extensions/empheq/webpack.config.js @@ -1,12 +1,11 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/empheq', // the package to build - '../../../../../../js', // location of the compiled js files - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/empheq', + libs: [ 'components/src/input/tex-base/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/enclose/webpack.config.js b/components/src/input/tex/extensions/enclose/webpack.config.js index a1bf56ae0..4955b549a 100644 --- a/components/src/input/tex/extensions/enclose/webpack.config.js +++ b/components/src/input/tex/extensions/enclose/webpack.config.js @@ -1,11 +1,10 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/enclose', // the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/enclose', + libs: [ 'components/src/input/tex-base/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/extpfeil/webpack.config.js b/components/src/input/tex/extensions/extpfeil/webpack.config.js index 018ceff34..6fade67e4 100644 --- a/components/src/input/tex/extensions/extpfeil/webpack.config.js +++ b/components/src/input/tex/extensions/extpfeil/webpack.config.js @@ -1,13 +1,12 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/extpfeil', // the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/extpfeil', + libs: [ 'components/src/input/tex/extensions/ams/lib', 'components/src/input/tex/extensions/newcommand/lib', 'components/src/input/tex-base/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/gensymb/webpack.config.js b/components/src/input/tex/extensions/gensymb/webpack.config.js index 808daa560..5285dfbc3 100644 --- a/components/src/input/tex/extensions/gensymb/webpack.config.js +++ b/components/src/input/tex/extensions/gensymb/webpack.config.js @@ -1,11 +1,10 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/gensymb', // the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/gensymb', + libs: [ 'components/src/input/tex-base/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/html/webpack.config.js b/components/src/input/tex/extensions/html/webpack.config.js index 4fae2f816..094b83a3c 100644 --- a/components/src/input/tex/extensions/html/webpack.config.js +++ b/components/src/input/tex/extensions/html/webpack.config.js @@ -1,11 +1,10 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/html', // the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/html', + libs: [ 'components/src/input/tex-base/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/mathtools/webpack.config.js b/components/src/input/tex/extensions/mathtools/webpack.config.js index 1b882c5ae..7b493e9ab 100644 --- a/components/src/input/tex/extensions/mathtools/webpack.config.js +++ b/components/src/input/tex/extensions/mathtools/webpack.config.js @@ -1,13 +1,12 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/mathtools', // the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/mathtools', + libs: [ 'components/src/input/tex/extensions/ams/lib', 'components/src/input/tex/extensions/newcommand/lib', 'components/src/input/tex-base/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/mhchem/webpack.config.js b/components/src/input/tex/extensions/mhchem/webpack.config.js index c50bd476b..cba65cedd 100644 --- a/components/src/input/tex/extensions/mhchem/webpack.config.js +++ b/components/src/input/tex/extensions/mhchem/webpack.config.js @@ -1,12 +1,11 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/mhchem', // the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/mhchem', + libs: [ 'components/src/input/tex/extensions/ams/lib', 'components/src/input/tex-base/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/newcommand/webpack.config.js b/components/src/input/tex/extensions/newcommand/webpack.config.js index 1deed0d0f..6451f9c6d 100644 --- a/components/src/input/tex/extensions/newcommand/webpack.config.js +++ b/components/src/input/tex/extensions/newcommand/webpack.config.js @@ -1,11 +1,10 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/newcommand', // the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/newcommand', + libs: [ 'components/src/input/tex-base/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/noerrors/webpack.config.js b/components/src/input/tex/extensions/noerrors/webpack.config.js index 6e9290157..d1a0b7b18 100644 --- a/components/src/input/tex/extensions/noerrors/webpack.config.js +++ b/components/src/input/tex/extensions/noerrors/webpack.config.js @@ -1,11 +1,10 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/noerrors', // the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/noerrors', + libs: [ 'components/src/input/tex-base/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/noundefined/webpack.config.js b/components/src/input/tex/extensions/noundefined/webpack.config.js index 177ff29d1..1b1799997 100644 --- a/components/src/input/tex/extensions/noundefined/webpack.config.js +++ b/components/src/input/tex/extensions/noundefined/webpack.config.js @@ -1,11 +1,10 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/noundefined', // the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/noundefined', + libs: [ 'components/src/input/tex-base/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/physics/webpack.config.js b/components/src/input/tex/extensions/physics/webpack.config.js index fbfa9a71c..6a538029a 100644 --- a/components/src/input/tex/extensions/physics/webpack.config.js +++ b/components/src/input/tex/extensions/physics/webpack.config.js @@ -1,11 +1,10 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/physics', // the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/physics', + libs: [ 'components/src/input/tex-base/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/require/webpack.config.js b/components/src/input/tex/extensions/require/webpack.config.js index 63ff19488..b4cf52862 100644 --- a/components/src/input/tex/extensions/require/webpack.config.js +++ b/components/src/input/tex/extensions/require/webpack.config.js @@ -1,12 +1,11 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/require', // the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/require', + libs: [ 'components/src/input/tex-base/lib', 'components/src/core/lib', 'components/src/startup/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/setoptions/webpack.config.js b/components/src/input/tex/extensions/setoptions/webpack.config.js index 1260438d7..355189570 100644 --- a/components/src/input/tex/extensions/setoptions/webpack.config.js +++ b/components/src/input/tex/extensions/setoptions/webpack.config.js @@ -1,11 +1,10 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/setoptions', // the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/setoptions', + libs: [ 'components/src/input/tex-base/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/tagformat/webpack.config.js b/components/src/input/tex/extensions/tagformat/webpack.config.js index 35bb113e1..5f77032ba 100644 --- a/components/src/input/tex/extensions/tagformat/webpack.config.js +++ b/components/src/input/tex/extensions/tagformat/webpack.config.js @@ -1,11 +1,10 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/tagformat', // the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/tagformat', + libs: [ 'components/src/input/tex-base/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/texhtml/webpack.config.js b/components/src/input/tex/extensions/texhtml/webpack.config.js index 85853b1aa..0239dbf8a 100644 --- a/components/src/input/tex/extensions/texhtml/webpack.config.js +++ b/components/src/input/tex/extensions/texhtml/webpack.config.js @@ -1,11 +1,10 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/texhtml', // the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/texhtml', + libs: [ 'components/src/input/tex-base/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/textcomp/webpack.config.js b/components/src/input/tex/extensions/textcomp/webpack.config.js index 364a539ef..ee9d795e5 100644 --- a/components/src/input/tex/extensions/textcomp/webpack.config.js +++ b/components/src/input/tex/extensions/textcomp/webpack.config.js @@ -1,12 +1,11 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/textcomp', // the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/textcomp', + libs: [ 'components/src/input/tex/extensions/textmacros/lib', 'components/src/input/tex-base/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/textmacros/webpack.config.js b/components/src/input/tex/extensions/textmacros/webpack.config.js index 8a6488382..a0a833c7f 100644 --- a/components/src/input/tex/extensions/textmacros/webpack.config.js +++ b/components/src/input/tex/extensions/textmacros/webpack.config.js @@ -1,11 +1,10 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/textmacros', // the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/textmacros', + libs: [ 'components/src/input/tex-base/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/unicode/webpack.config.js b/components/src/input/tex/extensions/unicode/webpack.config.js index 8054276b3..1852def11 100644 --- a/components/src/input/tex/extensions/unicode/webpack.config.js +++ b/components/src/input/tex/extensions/unicode/webpack.config.js @@ -1,11 +1,10 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/unicode', // the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/unicode', + libs: [ 'components/src/input/tex-base/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/units/webpack.config.js b/components/src/input/tex/extensions/units/webpack.config.js index 99f9ecf6c..c7bffe9dc 100644 --- a/components/src/input/tex/extensions/units/webpack.config.js +++ b/components/src/input/tex/extensions/units/webpack.config.js @@ -1,11 +1,10 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/units', // the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/units', + libs: [ 'components/src/input/tex-base/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/upgreek/webpack.config.js b/components/src/input/tex/extensions/upgreek/webpack.config.js index d47c688b0..d45445520 100644 --- a/components/src/input/tex/extensions/upgreek/webpack.config.js +++ b/components/src/input/tex/extensions/upgreek/webpack.config.js @@ -1,11 +1,10 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/upgreek', // the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/upgreek', + libs: [ 'components/src/input/tex-base/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/extensions/verb/webpack.config.js b/components/src/input/tex/extensions/verb/webpack.config.js index 48bb2b8f4..4d5cba711 100644 --- a/components/src/input/tex/extensions/verb/webpack.config.js +++ b/components/src/input/tex/extensions/verb/webpack.config.js @@ -1,11 +1,10 @@ const PACKAGE = require('../../../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex/extensions/verb', // the package to build - '../../../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex/extensions/verb', + libs: [ 'components/src/input/tex-base/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/input/tex/webpack.config.js b/components/src/input/tex/webpack.config.js index dd3dc693e..55aef78ad 100644 --- a/components/src/input/tex/webpack.config.js +++ b/components/src/input/tex/webpack.config.js @@ -1,11 +1,10 @@ const PACKAGE = require('../../../webpack.common.js'); -module.exports = PACKAGE( - 'input/tex', // the package to build - '../../../../js', // location of the MathJax js library - [ // packages to link to +module.exports = PACKAGE({ + name: 'input/tex', + libs: [ 'components/src/startup/lib', 'components/src/core/lib' ], - __dirname // our directory -); + dir: __dirname +}); diff --git a/components/src/latest/webpack.config.js b/components/src/latest/webpack.config.js index ff1fb8529..22445001d 100644 --- a/components/src/latest/webpack.config.js +++ b/components/src/latest/webpack.config.js @@ -1,8 +1,6 @@ const PACKAGE = require('../../webpack.common.js'); -module.exports = PACKAGE( - 'latest', // the package to build - '../../../js', // location of the MathJax js library - [], // packages to link to - __dirname // our directory -); +module.exports = PACKAGE({ + name: 'latest', + dir: __dirname +}); diff --git a/components/src/loader/webpack.config.js b/components/src/loader/webpack.config.js index f23953bb7..3373b2e3b 100644 --- a/components/src/loader/webpack.config.js +++ b/components/src/loader/webpack.config.js @@ -1,8 +1,6 @@ const PACKAGE = require('../../webpack.common.js'); -module.exports = PACKAGE( - 'loader', // the package to build - '../../../js', // location of the MathJax js library - [], // packages to link to - __dirname // our directory -); +module.exports = PACKAGE({ + name: 'loader', + dir: __dirname +}); diff --git a/components/src/mml-chtml-nofont/webpack.config.js b/components/src/mml-chtml-nofont/webpack.config.js index f82db4bf4..f36d64806 100644 --- a/components/src/mml-chtml-nofont/webpack.config.js +++ b/components/src/mml-chtml-nofont/webpack.config.js @@ -1,8 +1,6 @@ const PACKAGE = require('../../webpack.common.js'); -module.exports = PACKAGE.NOFONT( - 'mml-chtml-nofont', // the package to build - '../../../js', // location of the MathJax js library - [], // packages to link to - __dirname // our directory -); +module.exports = PACKAGE.NOFONT({ + name: 'mml-chtml-nofont', + dir: __dirname +}); diff --git a/components/src/mml-chtml/webpack.config.js b/components/src/mml-chtml/webpack.config.js index c488da142..bfd70522f 100644 --- a/components/src/mml-chtml/webpack.config.js +++ b/components/src/mml-chtml/webpack.config.js @@ -1,8 +1,6 @@ const PACKAGE = require('../../webpack.common.js'); -module.exports = PACKAGE( - 'mml-chtml', // the package to build - '../../../js', // location of the MathJax js library - [], // packages to link to - __dirname // our directory -); +module.exports = PACKAGE({ + name: 'mml-chtml', + dir: __dirname +}); diff --git a/components/src/mml-svg-nofont/webpack.config.js b/components/src/mml-svg-nofont/webpack.config.js index 62dd495e9..5236812b9 100644 --- a/components/src/mml-svg-nofont/webpack.config.js +++ b/components/src/mml-svg-nofont/webpack.config.js @@ -1,8 +1,6 @@ const PACKAGE = require('../../webpack.common.js'); -module.exports = PACKAGE.NOFONT( - 'mml-svg-nofont', // the package to build - '../../../js', // location of the MathJax js library - [], // packages to link to - __dirname // our directory -); +module.exports = PACKAGE.NOFONT({ + name: 'mml-svg-nofont', + dir: __dirname +}); diff --git a/components/src/mml-svg/webpack.config.js b/components/src/mml-svg/webpack.config.js index 0d2fe5c4b..5b2ecfaff 100644 --- a/components/src/mml-svg/webpack.config.js +++ b/components/src/mml-svg/webpack.config.js @@ -1,8 +1,6 @@ const PACKAGE = require('../../webpack.common.js'); -module.exports = PACKAGE( - 'mml-svg', // the package to build - '../../../js', // location of the MathJax js library - [], // packages to link to - __dirname // our directory -); +module.exports = PACKAGE({ + name: 'mml-svg', + dir: __dirname +}); diff --git a/components/src/node-main/webpack.config.js b/components/src/node-main/webpack.config.js index ea41c8c12..424e2aec5 100644 --- a/components/src/node-main/webpack.config.js +++ b/components/src/node-main/webpack.config.js @@ -1,17 +1,18 @@ const PACKAGE = require('../../webpack.common.js'); -const package = PACKAGE( - 'node-main', // the package to build - '../../../js', // location of the MathJax js library - [], // packages to link to - __dirname // our directory -); +module.exports = env => { + const package = PACKAGE({ + name: 'node-main', + dir: __dirname + })(env); -// make node-main.js exports available to caller -package.output.library = { - name: 'init', - type: 'commonjs', - export: 'init' -}; + // make node-main.js exports available to caller + package.output.library = { + name: 'init', + type: 'commonjs', + export: 'init' + }; + + return package; +} -module.exports = package; diff --git a/components/src/output/chtml/webpack.config.js b/components/src/output/chtml/webpack.config.js index 6ade21b85..3ee8cfe07 100644 --- a/components/src/output/chtml/webpack.config.js +++ b/components/src/output/chtml/webpack.config.js @@ -1,8 +1,7 @@ const PACKAGE = require('../../../webpack.common.js'); -module.exports = PACKAGE.NOFONT( - 'output/chtml', // the package to build - '../../../../js', // location of the MathJax js library - ['components/src/core/lib'], // packages to link to - __dirname // our directory -); +module.exports = PACKAGE.NOFONT({ + name: 'output/chtml', + libs: ['components/src/core/lib'], + dir: __dirname +}); diff --git a/components/src/output/svg/webpack.config.js b/components/src/output/svg/webpack.config.js index 89f3773ab..aa3fe2be7 100644 --- a/components/src/output/svg/webpack.config.js +++ b/components/src/output/svg/webpack.config.js @@ -1,8 +1,7 @@ const PACKAGE = require('../../../webpack.common.js'); -module.exports = PACKAGE.NOFONT( - 'output/svg', // the package to build - '../../../../js', // location of the MathJax js library - ['components/src/core/lib'], // packages to link to - __dirname // our directory -); +module.exports = PACKAGE.NOFONT({ + name: 'output/svg', + libs: ['components/src/core/lib'], + dir: __dirname +}); diff --git a/components/src/startup/webpack.config.js b/components/src/startup/webpack.config.js index 46f7f97e1..ac0c0d3e7 100644 --- a/components/src/startup/webpack.config.js +++ b/components/src/startup/webpack.config.js @@ -1,8 +1,6 @@ const PACKAGE = require('../../webpack.common.js'); -module.exports = PACKAGE( - 'startup', // the package to build - '../../../js', // location of the MathJax js library - [], // packages to link to - __dirname // our directory -); +module.exports = PACKAGE({ + name: 'startup', + dir: __dirname +}); diff --git a/components/src/tex-chtml-nofont/webpack.config.js b/components/src/tex-chtml-nofont/webpack.config.js index 6f8352ed1..af145031f 100644 --- a/components/src/tex-chtml-nofont/webpack.config.js +++ b/components/src/tex-chtml-nofont/webpack.config.js @@ -1,8 +1,6 @@ const PACKAGE = require('../../webpack.common.js'); -module.exports = PACKAGE.NOFONT( - 'tex-chtml-nofont', // the package to build - '../../../js', // location of the MathJax js library - [], // packages to link to - __dirname // our directory -); +module.exports = PACKAGE.NOFONT({ + name: 'tex-chtml-nofont', + dir: __dirname +}); diff --git a/components/src/tex-chtml/webpack.config.js b/components/src/tex-chtml/webpack.config.js index 2d5c67f1b..5d40566ec 100644 --- a/components/src/tex-chtml/webpack.config.js +++ b/components/src/tex-chtml/webpack.config.js @@ -1,8 +1,6 @@ const PACKAGE = require('../../webpack.common.js'); -module.exports = PACKAGE( - 'tex-chtml', // the package to build - '../../../js', // location of the MathJax js library - [], // packages to link to - __dirname // our directory -); +module.exports = PACKAGE({ + name: 'tex-chtml', + dir: __dirname +}); diff --git a/components/src/tex-mml-chtml-nofont/webpack.config.js b/components/src/tex-mml-chtml-nofont/webpack.config.js index 0fdc087c2..8030e07f3 100644 --- a/components/src/tex-mml-chtml-nofont/webpack.config.js +++ b/components/src/tex-mml-chtml-nofont/webpack.config.js @@ -1,8 +1,6 @@ const PACKAGE = require('../../webpack.common.js'); -module.exports = PACKAGE.NOFONT( - 'tex-mml-chtml-nofont', // the package to build - '../../../js', // location of the MathJax js library - [], // packages to link to - __dirname // our directory -); +module.exports = PACKAGE.NOFONT({ + name: 'tex-mml-chtml-nofont', + dir: __dirname +}); diff --git a/components/src/tex-mml-chtml/webpack.config.js b/components/src/tex-mml-chtml/webpack.config.js index 2d1195b86..001f2aaef 100644 --- a/components/src/tex-mml-chtml/webpack.config.js +++ b/components/src/tex-mml-chtml/webpack.config.js @@ -1,8 +1,6 @@ const PACKAGE = require('../../webpack.common.js'); -module.exports = PACKAGE( - 'tex-mml-chtml', // the package to build - '../../../js', // location of the MathJax js library - [], // packages to link to - __dirname // our directory -); +module.exports = PACKAGE({ + name: 'tex-mml-chtml', + dir: __dirname +}); diff --git a/components/src/tex-mml-svg-nofont/webpack.config.js b/components/src/tex-mml-svg-nofont/webpack.config.js index 3be3e0fda..f837afbdc 100644 --- a/components/src/tex-mml-svg-nofont/webpack.config.js +++ b/components/src/tex-mml-svg-nofont/webpack.config.js @@ -1,8 +1,6 @@ const PACKAGE = require('../../webpack.common.js'); -module.exports = PACKAGE.NOFONT( - 'tex-mml-svg-nofont', // the package to build - '../../../js', // location of the MathJax js library - [], // packages to link to - __dirname // our directory -); +module.exports = PACKAGE.NOFONT({ + name: 'tex-mml-svg-nofont', + dir: __dirname +}); diff --git a/components/src/tex-mml-svg/webpack.config.js b/components/src/tex-mml-svg/webpack.config.js index 1323d6731..7312d036c 100644 --- a/components/src/tex-mml-svg/webpack.config.js +++ b/components/src/tex-mml-svg/webpack.config.js @@ -1,8 +1,6 @@ const PACKAGE = require('../../webpack.common.js'); -module.exports = PACKAGE( - 'tex-mml-svg', // the package to build - '../../../js', // location of the MathJax js library - [], // packages to link to - __dirname // our directory -); +module.exports = PACKAGE({ + name: 'tex-mml-svg', + dir: __dirname +}); diff --git a/components/src/tex-svg-nofont/webpack.config.js b/components/src/tex-svg-nofont/webpack.config.js index b119ebabf..a69967c13 100644 --- a/components/src/tex-svg-nofont/webpack.config.js +++ b/components/src/tex-svg-nofont/webpack.config.js @@ -1,8 +1,6 @@ const PACKAGE = require('../../webpack.common.js'); -module.exports = PACKAGE.NOFONT( - 'tex-svg-nofont', // the package to build - '../../../js', // location of the MathJax js library - [], // packages to link to - __dirname // our directory -); +module.exports = PACKAGE.NOFONT({ + name: 'tex-svg-nofont', + dir: __dirname +}); diff --git a/components/src/tex-svg/webpack.config.js b/components/src/tex-svg/webpack.config.js index 3a0b36889..a2f538ee4 100644 --- a/components/src/tex-svg/webpack.config.js +++ b/components/src/tex-svg/webpack.config.js @@ -1,8 +1,6 @@ const PACKAGE = require('../../webpack.common.js'); -module.exports = PACKAGE( - 'tex-svg', // the package to build - '../../../js', // location of the MathJax js library - [], // packages to link to - __dirname // our directory -); +module.exports = PACKAGE({ + name: 'tex-svg', + dir: __dirname +}); diff --git a/components/src/ui/lazy/webpack.config.js b/components/src/ui/lazy/webpack.config.js index ce8209ecc..1e39a4889 100644 --- a/components/src/ui/lazy/webpack.config.js +++ b/components/src/ui/lazy/webpack.config.js @@ -1,10 +1,7 @@ const PACKAGE = require('../../../webpack.common.js'); -module.exports = PACKAGE( - 'ui/lazy', // the package to build - '../../../../js', // location of the MathJax js library - [ // packages to link to - 'components/src/core/lib' - ], - __dirname // our directory -); +module.exports = PACKAGE({ + name: 'ui/lazy', + libs: ['components/src/core/lib'], + dir: __dirname +}); diff --git a/components/src/ui/menu/webpack.config.js b/components/src/ui/menu/webpack.config.js index 8788bae4c..61ecdf0d6 100644 --- a/components/src/ui/menu/webpack.config.js +++ b/components/src/ui/menu/webpack.config.js @@ -1,8 +1,10 @@ const PACKAGE = require('../../../webpack.common.js'); -module.exports = PACKAGE( - 'ui/menu', // the package to build - '../../../../js', // location of the MathJax js library - ['components/src/core/lib', 'node_modules/mj-context-menu/js'], // packages to link to - __dirname // our directory -); +module.exports = PACKAGE({ + name: 'ui/menu', + libs: [ + 'components/src/core/lib', + 'node_modules/mj-context-menu/js' + ], + dir: __dirname +}); diff --git a/components/src/ui/safe/webpack.config.js b/components/src/ui/safe/webpack.config.js index a95788a0c..d729f37f5 100644 --- a/components/src/ui/safe/webpack.config.js +++ b/components/src/ui/safe/webpack.config.js @@ -1,8 +1,7 @@ const PACKAGE = require('../../../webpack.common.js'); -module.exports = PACKAGE( - 'ui/safe', // the package to build - '../../../../js', // location of the MathJax js library - ['components/src/core/lib'], // packages to link to - __dirname // our directory -); +module.exports = PACKAGE({ + name: 'ui/safe', + libs: ['components/src/core/lib'], + dir: __dirname +}); diff --git a/components/webpack.common.js b/components/webpack.common.js index 869837ca4..c77d72115 100644 --- a/components/webpack.common.js +++ b/components/webpack.common.js @@ -36,6 +36,15 @@ function quoteRE(string) { return string.replace(/([\\.{}[\]()?*^$])/g, '\\$1') } +function fullPath(resource) { + const file = resource.request ? + (resource.request.charAt(0) === '.' ? + path.resolve(resource.path, resource.request) : + resource.request) : + resource.path; + return file.charAt(0) === '/' ? file : require.resolve(file); +} + /** * Creates the plugin needed for including jsdir in the output * @@ -43,10 +52,8 @@ function quoteRE(string) { * @param {string} dir The directory of the component being built * @return {any[]} The plugin array (empty or with the conversion plugin) */ -const PLUGINS = function (js, dir) { - const mjdir = path.resolve(__dirname, '..', 'js'); - const jsdir = path.resolve(dir, js); - +const PLUGINS = function (js, dir, es) { + const jsdir = path.resolve(dir, js + es); // // Record the js directory for the pack command // @@ -59,47 +66,46 @@ const PLUGINS = function (js, dir) { * Creates the plugin needed for converting mathjax references to component/lib references * * @param {string} js The location of the compiled js files - * @param {string[]} lib The component library directories to be linked against * @param {string} dir The directory of the component being built - * @return {any[]} The plugin array (empty or with the conversion plugin) + * @param {string[]} libs The component library directories to be linked against + * @return {Object} The plugin object: {plugins: [...]} */ -const RESOLVE = function (js, libs, dir) { - const mjdir = path.resolve(__dirname, '..', 'js'); +const RESOLVE = function (js, dir, es, libs) { + // + // Get directories and regular expressions for them + // + const sep = quoteRE(path.sep); + const root = path.dirname(__dirname); + const mjdir = path.resolve(root, 'js'); const jsdir = path.resolve(dir, js); - const mjRE = new RegExp('^(?:' + quoteRE(jsdir) + '|' + quoteRE(mjdir) + ')' + quoteRE(path.sep)); - const root = path.dirname(mjdir); + const jsRE = new RegExp((es ? quoteRE(jsdir).replace(/^(.*\/js)(\/|$)/, '$1' + es + '?$2') : quoteRE(jsdir)) + sep); + const mjRE = new RegExp((es ? quoteRE(mjdir) + es + '?' : quoteRE(mjdir)) + sep); // // Add directory names to libraries // - libs = libs.map(lib => path.join(lib.charAt(0) === '.' ? dir : root, lib) + path.sep); + const libREs = libs.map( + lib => (lib.charAt(0) === '.' ? + [jsRE, path.join(dir, lib) + path.sep] : + [mjRE, path.join(root, lib) + path.sep]) + ); // - // Function replace imported files by ones in the specified component lib directories. + // Function to replace imported files by ones in the specified component lib directories. // const replaceLibs = (resource) => { + const request = fullPath(resource); // - // The full file name to check. + // Loop through the libraries and see if the imported file is there, + // and return it if so. // - const request = require.resolve( - resource.request ? - resource.request.charAt(0) === '.' ? path.resolve(resource.path, resource.request) : resource.request : - resource.path - ); - // - // Only check files in the MathJax js directory. - // - if (!request.match(mjRE)) return; - // - // Loop through the libraries and see if the imported file is there. - // If so, replace the request with the library version and return. - // - for (const lib of libs) { - const file = request.replace(mjRE, lib); - if (fs.existsSync(file)) { - resource.path = file; - resource.request = undefined; - return; + for (const [re, lib] of libREs) { + const match = request.match(re); + if (match) { + const file = lib + request.substr(match[0].length); + if (fs.existsSync(file)) { + return file; + } } } } @@ -108,13 +114,42 @@ const RESOLVE = function (js, libs, dir) { // A plugin that looks for files and modules to see if they need replacing with library versions. // class ResolveReplacementPlugin { - apply(compiler) { - compiler.hooks.file.tap(ResolveReplacementPlugin.name, replaceLibs); - compiler.hooks.module.tap(ResolveReplacementPlugin.name, replaceLibs); + apply(resolver) { + const target = resolver.ensureHook("resolved"); + resolver + .getHook('normalResolve') + .tapAsync(ResolveReplacementPlugin.name, (request, resolveContext, callback) => { + const file = replaceLibs(request); + if (!file) return callback(); + resolver.doResolve( + target, + {...request, path: file, request: undefined}, + 'library redirect', + resolveContext, + callback + ); + }); } } - return {plugins: [new ResolveReplacementPlugin()]}; + // + // The resolve object to use + // + const resolve = {plugins: [new ResolveReplacementPlugin()]}; + + // + // Add aliases for js => js6, if needed + // + if (es) { + const src = path.join(path.dirname(require.resolve('mathjax-full/package.json')), 'js'); + resolve.alias = { + [jsdir]: jsdir + es, + 'mathjax-full/js': 'mathjax-full/js' + es, + [src]: src + es // needed for development environment with symbolic link to mathjax-full + } + } + + return resolve; } /** @@ -147,59 +182,85 @@ const MODULE = function (dir) { /** * Create a webpack configuration for a distribution file * - * @param {string} name The name of the component to create - * @param {string} js The path to the compiled .js files - * @param {string[]} libs Array of paths to component lib directories to link against - * @param {string} dir The directory of the component buing built - * @param {string} dist The path to the directory where the component .js file will be placed - * (defaults to es5 in the same directory as the js directory) + * @param {{ + * name: string, // The name of the component to create + * js: string, // The path to the compiled .js files (default is mathjax js directory) + * libs: string[], // Array of paths to component lib directories to link against + * dir: string, // The directory of the component being built + * dist: string // The path to the directory where the component .js file will be placed + * (defaults to es5 or es6 in the same directory as the js directory) + * }} options + * @return {object} The webpack configuration object */ -const PACKAGE = function (name, js, libs, dir, dist) { - const distDir = dist ? path.resolve(dir, dist) : - path.resolve(path.dirname(js), 'es5', path.dirname(name)); - name = path.basename(name); - return { - name: name, - entry: path.join(dir, name + '.js'), - output: { - path: distDir, - filename: name + (dist === '.' ? '.min.js' : '.js') - }, - target: ['web', 'es5'], // needed for IE11 and old browsers - plugins: PLUGINS(js, dir), - resolve: RESOLVE(js, libs, dir), - module: MODULE(dir), - performance: { - hints: false - }, - optimization: { - minimize: true, - minimizer: [new TerserPlugin({ - extractComments: false, - terserOptions: { - output: { - ascii_only: true +const PACKAGE = function (options) { + let {name, js, libs = [], dir, dist = ''} = options; + if (!js) { + js = path.relative(dir, path.resolve(__dirname, '..', 'js')); + } + return (env) => { + const es = env.es || ''; + const distDir = dist ? path.resolve(dir, dist) : + path.resolve(js, '..', 'es' + (es || 5), path.dirname(name)); + const basename = path.basename(name); + return { + name: basename, + entry: path.join(dir, basename + '.js'), + output: { + path: distDir, + filename: basename + (dist === '.' ? '.min.js' : '.js') + }, + target: ['web', 'es' + (es || 5)], // needed for IE11 and old browsers + plugins: PLUGINS(js, dir, es), + resolve: RESOLVE(js, dir, es, libs), + module: (es ? undefined : MODULE(dir)), + performance: { + hints: false + }, + optimization: { + minimize: true, + minimizer: [new TerserPlugin({ + extractComments: false, + parallel: true, + terserOptions: { + output: { + ascii_only: true + } } - } - })] - }, - mode: 'production' + })] + }, + mode: 'production' + }; }; } -PACKAGE.NOFONT = function (name, js, libs, dir, dist) { - const package = PACKAGE(name, js, libs, dir, dist); - const jax = (name.match(/chtml|svg/) || ['chtml'])[0]; +/** + * Create a webpack configuration for a distribution file with no default font + * + * @param {{ + * name: string, // The name of the component to create + * js: string, // The path to the compiled .js files (default is mathjax js directory) + * libs: string[], // Array of paths to component lib directories to link against + * dir: string, // The directory of the component being built + * dist: string // The path to the directory where the component .js file will be placed + * (defaults to es5 or es6 in the same directory as the js directory) + * }} options + * @return {object} The webpack configuration object + */ +PACKAGE.NOFONT = function (options) { + const jax = (options.name.match(/chtml|svg/) || ['chtml'])[0]; const nofont = path.resolve(__dirname, 'src', 'output', jax, 'nofont.js'); - package.plugins.push( - new webpack.NormalModuleReplacementPlugin( - /DefaultFont.js/, - function (resource) { - resource.request = path.relative(resource.context, nofont).replace(/^([^.])/, './$1'); - } - ) - ); - return package; + return (env) => { + const package = PACKAGE(options)(env); + package.plugins.push( + new webpack.NormalModuleReplacementPlugin( + /DefaultFont.js/, + function (resource) { + resource.request = path.relative(resource.context, nofont).replace(/^([^.])/, './$1'); + } + ) + ); + return package; + } } module.exports = PACKAGE; diff --git a/package-lock.json b/package-lock.json index 6746f21d4..25b385d72 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "Apache-2.0", "dependencies": { "esm": "^3.2.25", - "mathjax-modern-font": "^1.0.0-beta.2", + "mathjax-modern-font": "^1.0.0-beta.3", "mhchemparser": "^4.1.0", "mj-context-menu": "^0.6.1", "speech-rule-engine": "^4.1.0-beta.2" @@ -3484,9 +3484,9 @@ } }, "node_modules/mathjax-modern-font": { - "version": "1.0.0-beta.2", - "resolved": "https://registry.npmjs.org/mathjax-modern-font/-/mathjax-modern-font-1.0.0-beta.2.tgz", - "integrity": "sha512-qvOwjHAikxsvbjPMNo041trcKQMn07zPfgvaHzCjYfWjT6UHfe7QOWn7ens8OkaT3UssEYxtKFxYDaFZ7RBJXg==" + "version": "1.0.0-beta.3", + "resolved": "https://registry.npmjs.org/mathjax-modern-font/-/mathjax-modern-font-1.0.0-beta.3.tgz", + "integrity": "sha512-J12xtqG8dlP4bamE4pk8Exg8ivINnf9k12avyioFautVrb3yOnDuSgdCJqD3S0BCj5MLpT+5pfPH5zrRZTppQQ==" }, "node_modules/merge-stream": { "version": "2.0.0", @@ -7594,9 +7594,9 @@ } }, "mathjax-modern-font": { - "version": "1.0.0-beta.2", - "resolved": "https://registry.npmjs.org/mathjax-modern-font/-/mathjax-modern-font-1.0.0-beta.2.tgz", - "integrity": "sha512-qvOwjHAikxsvbjPMNo041trcKQMn07zPfgvaHzCjYfWjT6UHfe7QOWn7ens8OkaT3UssEYxtKFxYDaFZ7RBJXg==" + "version": "1.0.0-beta.3", + "resolved": "https://registry.npmjs.org/mathjax-modern-font/-/mathjax-modern-font-1.0.0-beta.3.tgz", + "integrity": "sha512-J12xtqG8dlP4bamE4pk8Exg8ivINnf9k12avyioFautVrb3yOnDuSgdCJqD3S0BCj5MLpT+5pfPH5zrRZTppQQ==" }, "merge-stream": { "version": "2.0.0", diff --git a/package.json b/package.json index 9d2091977..086888812 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,9 @@ "main": "components/src/node-main/node-main.js", "files": [ "/es5", + "/es6", "/js", + "/js6", "/ts", "/components", "LICENSE", @@ -29,20 +31,38 @@ "AsciiMath" ], "scripts": { - "clean:js": "npx rimraf js", - "clean:es5": "npx rimraf es5", + "clean5:js": "npx rimraf js", + "clean6:js": "npx rimraf js6", + "clean5:es": "npx rimraf es5", + "clean6:es": "npx rimraf es6", "clean:lib": "npx rimraf 'components/src/**/lib'", - "clean": "npm run --silent clean:js && npm run --silent clean:es5 && npm run --silent clean:lib", - "copy:mj2": "npx copyfiles -u 1 'ts/input/asciimath/mathjax2/**/*' js", - "copy:mml3": "npx copyfiles -u 1 'ts/input/mathml/mml3/mml3.sef.json' js", - "precompile": "npm run --silent clean:js", + "clean5": "npm run -s clean5:js && npm run -s clean5:es && npm run -s clean:lib", + "clean6": "npm run -s clean6:js && npm run -s clean6:es && npm run -s clean:lib", + "clean": "npm run -s clean5 && npm run -s clean6", + "=============================================================================== copy": "", + "copy5:mj2": "npx copyfiles -u 1 'ts/input/asciimath/mathjax2/**/*' js", + "copy5:mml3": "npx copyfiles -u 1 'ts/input/mathml/mml3/mml3.sef.json' js", + "copy6:mj2": "npx copyfiles -u 1 'ts/input/asciimath/mathjax2/**/*' js6", + "copy6:mml3": "npx copyfiles -u 1 'ts/input/mathml/mml3/mml3.sef.json' js6", + "js6:chtml": "node components/bin/js2js6 js6/output/chtml/DefaultFont.js", + "js6:svg": "node components/bin/js2js6 js6/output/svg/DefaultFont.js", + "=============================================================================== compile": "", + "precompile": "npm run -s clean5:js", "compile": "npx tsc", - "postcompile": "npm run --silent copy:mj2 && npm run --silent copy:mml3", - "premake-components": "npm run --silent clean:es5 && npm run --silent clean:lib", - "make-components": "cd components && node bin/makeAll src | grep --line-buffered 'Building\\|Webpacking\\|Copying\\|npx'", + "postcompile": "npm run -s copy5:mj2 && npm run -s copy5:mml3", + "precompile6": "npm run -s clean6:js", + "compile6": "npx tsc --project tsconfig-es6.json", + "postcompile6": "npm run -s js6:chtml && npm run -s js6:svg && npm run -s copy6:mj2 && npm run -s copy6:mml3", + "=============================================================================== components": "", + "premake-components": "npm run -s clean5:es && npm run -s clean:lib", + "make-components": "components/bin/makeAll --terse components/src", + "premake-components6": "npm run -s clean6:es && npm run -s clean:lib", + "make-components6": "node components/bin/makeAll --es6 --terse components/src", + "=============================================================================== mml3": "", "premake-mml3-xslt": "cd ts/input/mathml/mml3 && grep '^\\s*\\(<\\|or\\|xmlns\\|excl\\|\">\\)' mml3.ts > mml3.xsl", "make-mml3-xslt": "cd ts/input/mathml/mml3 && npx xslt3 -t -xsl:mml3.xsl -export:mml3.sef.json -nogo", "postmake-mml3-xslt": "npx rimraf ts/input/mathml/mml3/mml3.xsl", + "=============================================================================== install": "", "link:mathjax-full": "node -e 'require(\"fs\").symlinkSync(process.cwd(), \"node_modules/mathjax-full\")'", "install": "npm run -s link:mathjax-full" }, @@ -65,7 +85,7 @@ }, "dependencies": { "esm": "^3.2.25", - "mathjax-modern-font": "^1.0.0-beta.2", + "mathjax-modern-font": "^1.0.0-beta.3", "mhchemparser": "^4.1.0", "mj-context-menu": "^0.6.1", "speech-rule-engine": "^4.1.0-beta.2" diff --git a/ts/components/global.ts b/ts/components/global.ts index 9ef413fd4..3d76c9ea8 100644 --- a/ts/components/global.ts +++ b/ts/components/global.ts @@ -73,7 +73,7 @@ export function combineConfig(dst: any, src: any): any { if (isObject(dst[id]) && isObject(src[id]) && !(src[id] instanceof Promise) /* needed for IE polyfill */) { combineConfig(dst[id], src[id]); - } else if (src[id] !== null && src[id] !== undefined) { + } else if (src[id] !== null && src[id] !== undefined && dst[id] !== src[id]) { dst[id] = src[id]; } } diff --git a/ts/output/chtml/DefaultFont.ts b/ts/output/chtml/DefaultFont.ts index 92042ea9f..40bc8a7e9 100644 --- a/ts/output/chtml/DefaultFont.ts +++ b/ts/output/chtml/DefaultFont.ts @@ -1,6 +1,6 @@ import {ChtmlFontData} from './FontData.js'; -import {Font} from 'mathjax-modern-font/js/mathjax-modern/chtml/default.js'; +import {Font} from 'mathjax-modern-font/js/chtml/default.js'; export const fontName = Font.fontName; export const DefaultFont = Font.DefaultFont as typeof ChtmlFontData; diff --git a/ts/output/svg/DefaultFont.ts b/ts/output/svg/DefaultFont.ts index 1353647fa..1f08cc92a 100644 --- a/ts/output/svg/DefaultFont.ts +++ b/ts/output/svg/DefaultFont.ts @@ -1,6 +1,6 @@ import {SvgFontData} from './FontData.js'; -import {Font} from 'mathjax-modern-font/js/mathjax-modern/svg/default.js'; +import {Font} from 'mathjax-modern-font/js/svg/default.js'; export const fontName = Font.fontName; export const DefaultFont = Font.DefaultFont as typeof SvgFontData; diff --git a/ts/output/svg/Wrappers/math.ts b/ts/output/svg/Wrappers/math.ts index 8e057ebb3..fb756a94e 100644 --- a/ts/output/svg/Wrappers/math.ts +++ b/ts/output/svg/Wrappers/math.ts @@ -79,7 +79,7 @@ export const SvgMath = (function (): SvgMathClass { // Avoid message about base constructors not having the same type // (they should both be SvgWrapper, but are thought of as different by typescript) // @ts-ignore - return class SvgMath extends Base extends SvgMathNTD { + return class SvgMath extends Base implements SvgMathNTD { /** * @override diff --git a/tsconfig-es6.json b/tsconfig-es6.json new file mode 100644 index 000000000..68e21ae38 --- /dev/null +++ b/tsconfig-es6.json @@ -0,0 +1,9 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "target": "ES6", + "outDir": "js6", + "module": "ES6", + "moduleResolution": "node" + } +} diff --git a/tsconfig.json b/tsconfig.json index e2de26531..b687d6739 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,12 +13,11 @@ "resolveJsonModule": true, "esModuleInterop": true, "baseUrl": ".", - "lib": ["es6", "dom"], + "lib": ["ES6", "DOM", "ES2019"], "noLib": false, "sourceMap": true, "outDir": "js", "typeRoots": ["./typings"] }, - "include": ["ts/**/*"], - "exclude": ["js", "es5", "components"] + "include": ["ts/**/*"] } diff --git a/tslint.json b/tslint.json index fc1c530be..a800667f9 100644 --- a/tslint.json +++ b/tslint.json @@ -13,7 +13,6 @@ "comment-format": [ true, "check-space" -// "check-uppercase" ], "curly": [ true,