dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
34.51k stars 9.75k forks source link

removing pure comment #55496

Closed drewkill32 closed 1 week ago

drewkill32 commented 2 weeks ago

Remove Pure comment to prevent warning when building with rollup

Description

there is a warning that happens when you build a package with rollup or vite.

node_modules/@microsoft/signalr/dist/esm/Utils.js (189:0): A comment

"/*#__PURE__*/"

in "node_modules/@microsoft/signalr/dist/esm/Utils.js" contains an annotation that Rollup cannot interpret due to the position of the comment. The comment will be removed to avoid issues.
node_modules/@microsoft/signalr/dist/esm/Utils.js (207:0): A comment

"/*#__PURE__*/"

in "node_modules/@microsoft/signalr/dist/esm/Utils.js" contains an annotation that Rollup cannot interpret due to the position of the comment. The comment will be removed to avoid issues.

Rollup expects the "/*#__PURE__*/" annotations on function calls or constructor invocation, not on module function declaration.

Comments containing @PURE or #PURE mark a specific function call or constructor invocation as side effect free. That means that Rollup will tree-shake i.e. remove the call unless the return value is used in some code that is not tree-shaken. These annotations need to immediately precede the call invocation to take effect. The following code will be completely tree-shaken unless this option is set to false, in which case it will remain unchanged.

https://rollupjs.org/configuration-options/#pure

You can reproduce the issue with the Rollup REPL

Fixes #55286

BrennanConroy commented 2 weeks ago

Rollup expects the "/*#__PURE__*/" annotations on function calls or constructor invocation, not on module function declaration.

Ok, but /*#__PURE__*/ is a webpack concept which is what this repo uses currently: https://webpack.js.org/guides/tree-shaking/#mark-a-function-call-as-side-effect-free

We're probably going to move off of webpack in 9.0 so this comment will go away then.

drewkill32 commented 1 week ago

@BrennanConroy Thanks! I was reading up on that. It is a minor warning on the output in babel. It can be ignored until you move away from webpack