paulmillr / scure-base

Secure, audited & 0-deps implementation of bech32, base64, base32, base16 & base58
https://paulmillr.com/noble/#scure
MIT License
120 stars 13 forks source link

@rollup/plugin-commonjs freaks out over code comments #22

Closed cmdruid closed 1 year ago

cmdruid commented 1 year ago

Hello. This is not a critical bug, but I wanted to report it anyway since it started happening to me recently.

When trying to bundle my projects using rollup and @rollup/plugin-commonjs, I get the following warning:

[!] (plugin commonjs--resolver) Error: node_modules/@scure/base/lib/esm/index.js (343:27) A comment

"/* @__PURE__ */"

in "node_modules/@scure/base/lib/esm/index.js" contains an annotation that Rollup cannot interpret due to the position of the comment. The comment will be removed to avoid issues.
    at onwarn (file:///home/cscott/Projects/lib/crypto-tools/rollup.config-1697525011054.mjs:14:35)
    at /home/cscott/Projects/lib/crypto-tools/node_modules/rollup/dist/shared/rollup.js:649:13
    at /home/cscott/Projects/lib/crypto-tools/node_modules/rollup/dist/shared/rollup.js:635:32
    at Object.logger [as onLog] (/home/cscott/Projects/lib/crypto-tools/node_modules/rollup/dist/shared/rollup.js:1127:9)
    at Module.log (/home/cscott/Projects/lib/crypto-tools/node_modules/rollup/dist/shared/rollup.js:14343:22)
    at Program.parseNode (/home/cscott/Projects/lib/crypto-tools/node_modules/rollup/dist/shared/rollup.js:6141:48)
    at new NodeBase (/home/cscott/Projects/lib/crypto-tools/node_modules/rollup/dist/shared/rollup.js:6042:14)
    at new Program (/home/cscott/Projects/lib/crypto-tools/node_modules/rollup/dist/shared/rollup.js:12282:9)
    at Module.setSource (/home/cscott/Projects/lib/crypto-tools/node_modules/rollup/dist/shared/rollup.js:14422:20)
    at ModuleLoader.addModuleSource (/home/cscott/Projects/lib/crypto-tools/node_modules/rollup/dist/shared/rollup.js:18640:20)

error Command failed with exit code 1.

I can safely ignore the warning as it doesn't break the bundling process. But it is an issue so I thought I would bring it up.

paulmillr commented 1 year ago

pure annotations help bundlers such as esbuild, webpack, and likely rollup to not include unnecessary code, improving tree-shaking. The feature works great and is helpful. You need to report the issue to plugin's repo.