npm source maps can expose your full codebase if shipped in the package tarball
A JavaScript source map (.map file) can contain the complete original source of every file bundled into a package, via its sourcesContent field. Anyone who runs npm pack on a published package can access these files, so they effectively reveal the codebase. A scan of 500 popular npm packages found 284 (57%) publish .map files and 195 (39%) inline sourcesContent. The article explains that this is harmless for open-source projects but exposes proprietary code in closed-source SDKs, CLIs, or paid libraries. It recommends checking tarballs before publishing and configuring build tools like tsc, esbuild, Rollup, Vite, and webpack to exclude sources or maps from the package.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in