-
Notifications
You must be signed in to change notification settings - Fork 348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug in mesh build when composer does not export defaults
#2968
Comments
It needs some work on |
I did a test run via patch-package and it does seem to work without issues. Since you are generating a typescript document first and then compile to js the typescript compiler seems to resolve the In js: In mjs: Since I couldn't keep my hands still in #2970 you can see a the first swing at a solution meant for discussion. Also fixed a minor typing error. |
@ardatan Might have missed something completely, what do you mean by needs some work on runtime package? |
The mesh build command produces invalid
index.js
file when no default exports are defined. This is a very common scenario when using typescript, but does also applies to js composers without default exports.To Reproduce
This does generate the following code in the index file:
Expected behavior
Mesh build should generate a valid import for composers without default export.
Additional context
There three ways I can think of to check if a composer has defaults exports:
export defaults
import * as DUMMY from '.mycomposer'
and then check ifDUMMY['defaults']
isundefined
* as
import, but use the default import as actual import + fallback to* as
if no default export existsSummary
The last solution seems to be the most straight forward. It does not extend build time, while only having a absolutely tiny effect on startup time.
Let me know if you agree with the approach (or suggest a different one) and I will make a PR.
The text was updated successfully, but these errors were encountered: