utils/mathlib.js
export function add(x, y) {
return x + y;
}
export function subtract(x, y) {
return x - y;
}
main.js
import add from "./../utils/mathlib"; //not working. but if I do default export like `export default function add(x, y)` it will work
import { add } from "./../utils/mathlib"; //working
import * as MathLib from "./../utils/mathlib"; //working
But I want to import all the functions available in the module with the same identifier without importing separately or through importing object. Something like the below,
import * from "./../utils/mathlib"
I should be able to use add, subtract function.
The reasoning behind this use case is, Whenever I add new functions in MathLib.js it should be available without modifying.(I took MathLib as sample use case only, in my real use case all the functions is necessary whenever I import the module).
Aucun commentaire:
Enregistrer un commentaire