vi a.mjs
затем напишите:
export default () => {
let store = 'createStore';
let persistor = 'persistStore';
return { store, persistor }
}
let store = 'createStore';
let persistor = 'persistStore';
export { store, persistor }
vi b.mjs
затем напишите:
import a from './a.mjs';
import * as $a from './a.mjs';
import { store, persistor } from './a.mjs';
console.log('export default function:', a);
console.log('export object:', $a);
console.log('export object.default:', $a.default);
console.log('export { store, persistor }:', store, persistor);
node --experimental-modules b.mjs
И вы получите результат как это:
export default function: [Function: default]
export object: [Module] {
default: [Function: default],
persistor: 'persistStore',
store: 'createStore'
}
export object.default: [Function: default]
export { store, persistor }: createStore persistStore