Import is slowly becoming the standard, but working with typescript professionally modules has easily been the most annoying part of the Node experience.
It works pretty well, and then you need to use something like Azure Functions and then suddenly it doesn’t. For various reasons.
My most recent example was using lodash, which works perfectly fine with import with typescript targeting esnext in node16, but then needs to be setup with require when you target an azure function and commonjs. I mean, maaaybe you could avoid it by using mjs, which is currently sort of needed to move into the node16 functionality in azure functions, even though they sort of run node16 just fine in part of them without it, and you sort of don’t want to use mjs files and so on.
I’m sure it’ll get there in a few years, but it is no doubt annoying to have to fight the toolset ever so often. Over something that feels like it should just be working.
That last part isn’t really exclusive to node these days though, is it?
I had the same problem so for serverless functions I am using standalone webpack config which transpires functions into the supported by the cloud format
It works pretty well, and then you need to use something like Azure Functions and then suddenly it doesn’t. For various reasons.
My most recent example was using lodash, which works perfectly fine with import with typescript targeting esnext in node16, but then needs to be setup with require when you target an azure function and commonjs. I mean, maaaybe you could avoid it by using mjs, which is currently sort of needed to move into the node16 functionality in azure functions, even though they sort of run node16 just fine in part of them without it, and you sort of don’t want to use mjs files and so on.
I’m sure it’ll get there in a few years, but it is no doubt annoying to have to fight the toolset ever so often. Over something that feels like it should just be working.
That last part isn’t really exclusive to node these days though, is it?