Monday, June 3, 2024
79
rated 0 times [  85] [ 6]  / answers: 1 / hits: 31904  / 9 Years ago, wed, december 23, 2015, 12:00:00

I have two javascript modules that looks like this:



// inner/mod.js
export function myFunc() {
// ...
}

// mod.js
import * as inner from ./inner/mod;


I would like to export myFunc from mod.js. How can I do this?



EDIT: I should clarify that the function is being exported as expected from inner/mod.js but I also want to export the funtion from the outer mod.js.



To those asking for clarification, I would like to achieve this:



// SomeOtherFile.js
import * as mod from mod; // NOT inner/mod

mod.myFunc();

More From » ecmascript-6

 Answers
18

I believe what you are looking for is



export * from './inner/mod';


That will reexports all exports of ./inner/mod. The spec actually has very nice tables listing all the possible import and export variants.


[#63961] Monday, December 21, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jordenfabiand

Total Points: 678
Total Questions: 107
Total Answers: 95

Location: Western Sahara
Member since Mon, May 3, 2021
3 Years ago
;