mathjs: Unexpected token in round.js
When upgrading to MathJS 6.0.2, we get an error when trying to make use of mathjs in our application, compiling with Webpack 3.4.0:
11:13:27 webpack.1 | ERROR in ./node_modules/mathjs/src/function/arithmetic/round.js
11:13:27 webpack.1 | Module parse failed: Unexpected token (58:4)
11:13:27 webpack.1 | You may need an appropriate loader to handle this file type.
11:13:27 webpack.1 | | */
11:13:27 webpack.1 | | const round = typed(name, {
11:13:27 webpack.1 | | ...roundNumberSignatures,
11:13:27 webpack.1 | |
11:13:27 webpack.1 | | 'Complex': function (x) {
11:13:27 webpack.1 | @ ./node_modules/mathjs/src/factoriesAny.js 98:0-57
11:13:27 webpack.1 | @ ./node_modules/mathjs/src/entry/mainAny.js
11:13:27 webpack.1 | @ ./node_modules/mathjs/main/es6/index.js
11:13:27 webpack.1 | @ ./app/javascript/src/config/math.ts
Here’s what it looks like where we set up MathJS:
import {
create,
addDependencies,
BigNumberDependencies,
divideDependencies,
evaluateDependencies,
multiplyDependencies,
subtractDependencies,
} from 'mathjs';
// http://mathjs.org/docs/custom_bundling.html
const math = create([
addDependencies,
BigNumberDependencies,
divideDependencies,
evaluateDependencies,
multiplyDependencies,
subtractDependencies,
]);
export default math;
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 19 (12 by maintainers)
I may understand the issue now: the mathjs configuration in package.js has a
module
file which points to non-transpiled modules. I guess mathjs should transpile the modules:import
/export
must stay, butconst
,=>
,...
, etc must be transpiled. Will give that a try.