ITADN

@azure/storage-common 12.4.0 browser bundle (dist/browser/crc64.js) contains require('fs'), breaking esbuild-based bundlers

#38924Openpburgmer 创建于 2026-06-11
questioncustomer-reportedClientStorageneeds-team-triage
P
pburgmercommented
### Description `@azure/storage-common` 12.4.0 ships a browser bundle at `dist/browser/crc64.js` that contains a `require('fs')` call (line 120). This is an emscripten-compiled WASM wrapper that is a multi-environment build. The `require('fs')` is guarded by `if (ENVIRONMENT_IS_NODE)` at runtime, but esbuild (and similar bundlers) resolve `require()` calls **statically** regardless of surrounding conditionals. This breaks any Angular 17+ project (or other esbuild-based builds) that depends on `@azure/storage-blob`, which transitively depends on `@azure/storage-common`. ### Error ✘ [ERROR] Could not resolve "fs" node_modules/@azure/storage-common/dist/browser/crc64.js:120:23: 120 │ var fs = require('fs'); ╵ ~~~~ The package "fs" wasn't found on the file system but is built into node. Are you trying to bundle for node? You can use "platform: 'node'" to do that, which will remove this error. ### Affected versions - `@azure/storage-common` 12.4.0 (broken) - `@azure/storage-common` 12.3.0 (working) ### Root cause `dist/browser/crc64.js` in 12.4.0 is a multi-environment emscripten build that includes Node.js-specific code paths. The previous version (12.3.0) did not have this issue. ### Workaround Pin `@azure/storage-common` to `~12.3.0` via npm `overrides` in `package.json`: ```json "overrides": { "@azure/storage-common": "~12.3.0" } Expected behavior The browser bundle should not reference Node.js built-ins (fs, path) even inside conditionals, since static bundlers cannot tree-shake require() calls. ```
1 条评论