Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removing pure comment #55496

Closed
wants to merge 1 commit into from

Conversation

drewkill32
Copy link

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

@dotnet-issue-labeler dotnet-issue-labeler bot 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
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
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

@drewkill32 drewkill32 closed this May 6, 2024
@dotnet-policy-service dotnet-policy-service bot added this to the 9.0-preview5 milestone May 6, 2024
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