Why does this work:
const str = \'stuff\';
export {
str
};
But not this:
export default {
str: \'stuff\'
};
The main reason of the export statement is to be used to export functions, objects or primitives from a given file (or module).
But you need an identifier in order to be exported (so that it can be imported via import
in another script).
You can simply do:
export const obj = {
str: 'stuff'
};
During the import, you will be able to use the same name obj
to refer to the corresponding value.
And import it like:
import { obj } from 'myLib';