I have a folder /app/libs/schemas with all my schemas in it. I also have an index.js file in there, which looks like this:
import { schema as Address } from './address';
// Some more imports ...
import { schema as User } from './user';
export {
Address,
// Some more exports ...
User
};
Now the strange thing: When I try to import { Address }, it doesn’t work. Importing * as schemas works though,
> import { Address } from '/app/lib/schemas'
> Address
ReferenceError: Address is not defined
> import * as schemas from '/app/lib/schemas'
> schemas.Address
{ [Function: Class] /* ... */ }
Because symbols imported using import are mutable bindings, a compiler for import statements needs the complete picture: not only what you imported and what module it came from, but where those symbols are used in the rest of your code. A REPL divorces the import statement from the symbol usage, making the compiler’s job impossible.
In short, when you’re using meteor shell, you need to use require.
No, it doesn’t. The issue then happens for another file. Maybe it’s because the files are in the same folder? I’m trying to use this import {} from '/app/lib/schemas inside of files, which are schemas themselves and are imported into the index.js file. Might be an issue with the loading order?