Nathan Lamont

Notes to Self

WebGPU

https://cohost.org/mcc/post/1406157-i-want-to-talk-about-webgpu via https://news.ycombinator.com/item?id=35800988

See https://alain.xyz/blog/raw-webgpu

From tweet https://twitter.com/mcclure111/status/1437890963272261634:

1a. require() and "import" are subtly semantically different. "require" is synchronous & can happen anytime. "import" is synchronous at the toplevel, and asynchronous other times (import()).

1b. Node.js freaked out about this difference hard. Most web packers decided not to care

2a. If you are targeting a web packer, or cispiler like babel, usually you can use both import and require interchangeably and not think about it. What this semantically does exactly will be documented by your packer, and is unpredictable.

2b. If you are targeting node, each file in your project MUST use EITHER require OR import, no mixing. You have two choices: Make your ENTIRE project (everything covered not counting dependencies) use import, no exceptions; or use require in ".js" files and import in ".mjs" files

2c. The ".mjs" solution is fiddly and poorly documented, and I recommend against it.

3/TLDR: If you want to support both Node.js and a reasonable range of packers, my recommendation is: - Use only import in your project, never require - Put "type": "module" in your package.json This is future-proof, and the only solution that avoids frustrating fiddly edge cases.