Closed ggrossetie closed 6 years ago
I don't think we should do anything different than what Node does. I think it's up to the library creator to provide a script that can respond to a direct require call.
I added this support in Antora, so you can use that as a reference. See https://gitlab.com/antora/antora/blob/4f84db7edca0f859ee443d2f2dd74887ee97975c/packages/cli/lib/cli.js#L26-40
I don't think we should do anything different than what Node does. I think it's up to the library creator to provide a script that can respond to a direct require call.
I agree, keep it simple.
I added this support in Antora, so you can use that as a reference.
Thanks for sharing, that's exactly what we need 😄
Since library can export a function, we should maybe use a syntax to define explicitly how the library should be loaded. Eg:
This syntax could be useful but it has some limitations and it will be hard to cover all the cases (define initialization options, call a nested export objects/functions, use a multi-step initialization...)
Instead a user could create a file to initialize all the required libraries:
.lib-init.js