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

next-swc: SVG <path> identified as usage of node:path import #45561

Closed
1 task done
karlhorky opened this issue Feb 3, 2023 · 6 comments
Closed
1 task done

next-swc: SVG <path> identified as usage of node:path import #45561

karlhorky opened this issue Feb 3, 2023 · 6 comments
Assignees
Labels
bug Issue was opened via the bug report template. SWC Related to minification/transpilation in Next.js.

Comments

@karlhorky
Copy link
Contributor

karlhorky commented Feb 3, 2023

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information


    Operating System:
      Platform: linux
      Arch: x64
      Version: Ubuntu 20.04.0 LTS Fri Feb 03 2023 18:38:16 GMT+0100 (Central European Standard Time)
    Binaries:
      Node: 16.14.2
      npm: 7.17.0
      Yarn: 1.22.19
      pnpm: 7.13.6
    Relevant packages:
      next: 13.1.7-canary.4
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0

Which area(s) of Next.js are affected? (leave empty if unsure)

SWC transpilation

Link to the code that reproduces this issue

https://stackblitz.com/edit/nextjs-npuob3?file=package.json

To Reproduce

  1. Open the StackBlitz above (start the dev server with yarn dev if it doesn't start on its own)
  2. See the UnhandledSchemeError error message about usage of node:path in the client, although it is not used there
  3. Remove the <path> from the JSX and observe the error message disappear

Screenshot 2023-02-03 at 18 34 30

Describe the Bug

The SVG <path> in the React component is incorrectly identified as a usage of node:path (which is actually an unused identifier), causing the UnhandledSchemeError: Reading from "node:path" is not handled by plugins (Unhandled scheme) error message (which normally occurs when the path import is used in a client-side component).

cc @kdy1 from #45149 (comment)

Expected Behavior

Any HTML or SVG tags which have the same name as unused identifiers should not be identified as usages of an identifier

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

@karlhorky karlhorky added the bug Issue was opened via the bug report template. label Feb 3, 2023
@github-actions github-actions bot added the SWC Related to minification/transpilation in Next.js. label Feb 3, 2023
@kdy1 kdy1 self-assigned this Feb 3, 2023
@kdy1
Copy link
Member

kdy1 commented Feb 6, 2023

Oh I think this can be an issue of swc core modules. I'll check it tomorrow.

@kdy1
Copy link
Member

kdy1 commented Feb 7, 2023

swc-project/swc#6911 will fix this

kdy1 added a commit to swc-project/swc that referenced this issue Feb 7, 2023
@karlhorky
Copy link
Contributor Author

karlhorky commented Feb 7, 2023

Ok great, thanks! I think this is still unreleased, but if the versioning will use semver I'm guessing it will be version 1.3.33 or 1.4.0.

We can leave this open until the Next.js version also includes this swc version.

@kdy1
Copy link
Member

kdy1 commented Feb 12, 2023

Fixed by #45776

@kdy1 kdy1 closed this as completed Feb 12, 2023
@karlhorky
Copy link
Contributor Author

Thanks! Confirmed that this was fixed in one of the latest canary versions!

https://stackblitz.com/edit/nextjs-kzstkn?file=pages%2Findex.tsx&file=yarn.lock

Screenshot 2023-02-14 at 10 43 42

@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. SWC Related to minification/transpilation in Next.js.
Projects
None yet
Development

No branches or pull requests

2 participants