JS/TS Non-glob import with prefix

Viewed 83

I have been doing this all over:

import * as math from 'mathjs';

But that leads to the whole MathJS library in my Webpack bundle, so I'm trying to stop using * imports.

It is very nice, though, having the math prefix when I call a function, e.g. math.round or math.add. It helps distinguish a bunch of generic function names.

Can I have both named (non-glob) imports, and a prefix for all the functions coming from the same package?

I've tried

import { add, divide, parse, simplify, round } as math from 'maths';

But no luck.

0 Answers
Related