Skip to content

removing pure comment - #55496

Closed
drewkill32 wants to merge 1 commit into
dotnet:mainfrom
drewkill32:rollup-pure-function-fix
Closed

drewkill32 wants to merge 1 commit into
dotnet:mainfrom
drewkill32:rollup-pure-function-fix

Conversation

@drewkill32

Copy link
Copy Markdown

Remove Pure comment to prevent warning when building with rollup

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

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

@ghost ghost added the area-signalr Includes: SignalR clients and servers label May 2, 2024
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label May 2, 2024
@BrennanConroy

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Author

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-signalr Includes: SignalR clients and servers community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/*#__PURE__*/ annotations dont work well with Vite / Rollup

3 participants