You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So I've flipped on "DRY everything; just use a build script" to now "just use -node and -default suffixes for everything so you don't have to deal with a build script"
Also recently I've embraced the Node.js convention of using "lib" as a folder name even though it's ignored in Python's default .gitignore. The solution is just don't use lib in py projects and it's OK to use it in Node.js projects.
Thus, I've started using src/lib/* where all the internal magic goes instead of src/internal/*. See how that goes. 🤷♀️
Also switched opinion on using primordials in everything vs not. The size gains of just using the implicit globals are so good that I don't think it makes sense to use primordial unless you target 100% spec compliance. The tradeoff of smaller bundles in exchange for less "correct" is something that I think is OK to do.
Also now using universal file-default.ts or file-node.ts suffix on export-conditioned or import-conditioned files that way the base file.ts can be used to route to file-node.ts, but file-default.ts can still be imported explicitly
importhellofrom"./file.ts"// On Node.js => ./file-node.tsimporthelloShimfrom"./file-default.ts"// EXPLICIT and worksimporthelloNativefrom"./file-node.ts"// EXPLICIT works only on Node.js
importhellofrom"./file.ts"// On Node.js => ./file-node.ts// no way to actually import the shim implementation explicitly 😭// BUT you can still import the non-default export-condition'ed fileimporthelloNativefrom"./file-node.ts"
one style vs the other isn't inheritly better, but I think being explicit with the suffixes helps really make it clear that these are export alternatives. 🤷♀️
btw this only works if you do "./*.js": "./dist/*.js" in your package.json file
also now using vitest since it has out-of-the-box support for most things typescript instead of needing a manual tsx --test test/index.test.ts test/myTest.test.ts for each file. 👈 no node --test doesn't support globs (yet) and test/*.test.ts shell-globs arent Windows compatible
Activity
jcbhmr commentedon Aug 2, 2023
So I've flipped on "DRY everything; just use a build script" to now "just use -node and -default suffixes for everything so you don't have to deal with a build script"
jcbhmr commentedon Aug 2, 2023
Also recently I've embraced the Node.js convention of using "lib" as a folder name even though it's ignored in Python's default .gitignore. The solution is just don't use lib in py projects and it's OK to use it in Node.js projects.
Thus, I've started using src/lib/* where all the internal magic goes instead of src/internal/*. See how that goes. 🤷♀️
jcbhmr commentedon Aug 2, 2023
Also switched opinion on using primordials in everything vs not. The size gains of just using the implicit globals are so good that I don't think it makes sense to use primordial unless you target 100% spec compliance. The tradeoff of smaller bundles in exchange for less "correct" is something that I think is OK to do.
jcbhmr commentedon Aug 3, 2023
Also now using universal file-default.ts or file-node.ts suffix on export-conditioned or import-conditioned files that way the base file.ts can be used to route to file-node.ts, but file-default.ts can still be imported explicitly
compare that to:
one style vs the other isn't inheritly better, but I think being explicit with the suffixes helps really make it clear that these are export alternatives. 🤷♀️
btw this only works if you do
"./*.js": "./dist/*.js"in your package.json filejcbhmr commentedon Aug 3, 2023
also now using vitest since it has out-of-the-box support for most things typescript instead of needing a manual
tsx --test test/index.test.ts test/myTest.test.tsfor each file. 👈 nonode --testdoesn't support globs (yet) andtest/*.test.tsshell-globs arent Windows compatible