hash-wasm icon indicating copy to clipboard operation
hash-wasm copied to clipboard

export ESM code

Open dynst opened this issue 4 months ago • 2 comments

"module" is a non-standard field that Node.js doesn't read. It uses "exports".

ESM code also needs the .mjs file extension.

https://nodejs.org/api/packages.html#determining-module-system

dynst avatar Aug 13 '25 20:08 dynst

Do you know if this syntax is supported by FE tooling like Webpack 4/5, Rollup, esbuild, parcel etc?

Daninet avatar Aug 13 '25 20:08 Daninet

It's from Node v12 https://nodejs.org/en/blog/release/v12.7.0 so almost everything should support it by now.

Webpack 5 added support in 2020. https://webpack.js.org/blog/2020-10-10-webpack-5-release/ so version 4 didn't have it.

Rollup definitely has it. https://github.com/rollup/plugins/issues/208#issuecomment-1162367570 Since at least node-resolve v11. https://github.com/rollup/plugins/pull/540

dynst avatar Aug 13 '25 23:08 dynst