CommonJS vs. es modules #2927
Unanswered
waldekmastykarz
asked this question in
Q&A
Replies: 1 comment 1 reply
-
I'm not sure what the answer is here, its been a while since I've needed to look into modules differences to this level but maybe this could this help https://github.com/getify/moduloze ? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Recently, two of our dependencies (chalk and strip-json-comments) have been upgraded to a new major version that exports es modules (esm). It seems that we can't use them at the moment, because we transpile CLI with TypeScript to CommonJS (cjs). During transpilation TypeScript converts all
import
statements torequire
. Because es modules must be loaded using import, we get either TS or runtime errors (depending on the exact syntax we use to load the dependency). Unless there's a way for us to load es modules in cjs, we might need to do some refactoring in order to be able to keep our dependencies current.@pnp/cli-for-microsoft-365-maintainers, @patrick-rodgers any tips you'd have that could help us move forward? Any caveats that we should consider before considering moving from cjs to esm?
Beta Was this translation helpful? Give feedback.
All reactions