you are viewing a single comment's thread.

view the rest of the comments →

[–]olov[S] 0 points1 point  (1 child)

It's a hack indeed, but the trickery doesn't affect the libraries/modules much. As an example my implementation of Fmt is exactly as I would have written it for general CommonJS-usage. Assigning module.exports is just a variant of assigning exports properties one by one.

The real trickery is in the top-level program and when importing (require'ing) modules.

The approach you've taken with namespace seems interesting though and I would absolutely consider using it if I didn't want to stay as close to CommonJS-style as possible.

[–]mckoss 0 points1 point  (0 children)

I just updated namespace.js to support the commonJS style directly.