Skip to content

Astro build with Sentry causes build error when using pnpm  #7279

@Lms24

Description

@Lms24

Verify latest release

  • I verified that the issue exists in the latest pnpm release

pnpm version

8.10.2

Which area(s) of pnpm are affected? (leave empty if unsure)

No response

Link to the code that reproduces this issue or a replay of the bug

https://github.com/Lms24/astro-sdk-pnpm-bug

Reproduction steps

  1. clone repo linked above and stay on the main branch
  2. run pnpm install && pnpm build
  3. build throws an error (see logs below)

This error only occurs when using pnpm. When installing and building with npm everything works. To test this yourself, checkout the npm branch:

  1. run git checkout npm && rm -rf node_modules
  2. run npm install && npm run build
  3. project builds correctly

Describe the Bug

Hi, Sentry SDK maintainer here 👋 Currently working on a Sentry SDK for Astro and I encountered a problem when using our SDK in combination with pnpm in an Astro project.

First of all, I'm not sure if this is actually a pnpm bug. However, so far I can only reproduce the following build error in the linked reproduction when I use pnpm:

pnpm build
> astro-spotlight-sdk-bug-investigation@0.0.1 build 
> astro check && astro build

05:49:19 PM [build] Building static entrypoints...
[commonjs--resolver] Unexpected character '�' (Note that you need plugins to import files that are not JavaScript)
file: /<project-root>/node_modules/.pnpm/chokidar@3.5.3/node_modules/chokidar/index.js:1:0
1: ����@<�
          ��*...
   ^
4* 
  h���/System/Library/Frameworks/CoreFoundation.framework/Versions...
3: ���H��1�H���L���L���H�����L�E�L��H��1�����uH�E�H�[A^A_]��}f.�UH��AWAVSPI��H��I��H�H...
 error   Unexpected character '�' (Note that you need plugins to import files that are not JavaScript)
  File:
    /<project-root>/node_modules/.pnpm/chokidar@3.5.3/node_modules/chokidar/index.js
  Code:
    1: ����@<�
              ��*...
       ^
4*  2: 
  h���/System/Library/Frameworks/CoreFoundation.framework/Versions...
    3: ���H��1�H���L���L���H�����L�E�L��H��1�����uH�E�H�[A^A_]��}f.�UH��AWAVSPI��H��I��H�H...
  Stacktrace:
RollupError: Unexpected character '�' (Note that you need plugins to import files that are not JavaScript)
    at error (file:///<project-root>/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:2287:30)
    at Module.error (file:///<project-root>/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:13745:16)
    at Module.tryParse (file:///<project-root>/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:14476:25)
    at Module.setSource (file:///<project-root>/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:14077:39)
    at ModuleLoader.addModuleSource (file:///<project-root>/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:24649:20)

  Cause:
SyntaxError: Unexpected character '�' (1:0)
    at pp$4.raise (file:///<project-root>/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:21621:13)
    at pp.getTokenFromCode (file:///<project-root>/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:23556:8)
    at pp.readToken (file:///<project-root>/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:23243:15)
    at Parser.readToken (file:///<project-root>/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:25991:24)
    at pp.nextToken (file:///<project-root>/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:23234:15)
    at Parser.parse (file:///<project-root>/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:18657:8)
    at Function.parse (file:///<project-root>/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:18708:35)
    at Graph.contextParse (file:///<project-root>/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:25754:38)
    at Module.tryParse (file:///<project-root>/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:14473:31)
    at Module.setSource (file:///<project-root>/node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:14077:39)

Using yarn or npm in the same project does not throw any error.

Expected Behavior

Running pnpm build should not cause a build error :P

As already said, it might very well be a problem on our end. But I can't find any clues as to what might be causing this. So I'd appreciate any hints. Cheers!

UPDATE: Please take a look at my first reply below for further details

Which Node.js version are you using?

v18.17.1

Which operating systems have you used?

  • macOS
  • Windows
  • Linux

If your OS is a Linux based, which one it is? (Include the version if relevant)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions