chrome-extension-tools icon indicating copy to clipboard operation
chrome-extension-tools copied to clipboard

Build Error: [crx:manifest-post] Unexpected token s in JSON at position 0

Open xneworlds opened this issue 1 year ago • 5 comments

Build tool

Vite

Where do you see the problem?

  • [ ] In the browser
  • [X] In the terminal

Describe the bug

When using both @sentry/vite-plugin and @crxjs/vite-plugin at the same time, the error occurs during build. If @sentry/vite-plugin is disabled, there will be no error.

Reproduction

Because the sentry configuration involves sensitive information, reproduction cannot be provided.

Logs

[crx:manifest-post] Unexpected token s in JSON at position 0
error during build:
SyntaxError: Unexpected token s in JSON at position 0
    at JSON.parse (<anonymous>)
at Object.decodeManifest (file:///Users/.../node_modules/.pnpm/@[email protected]/node_modules/@crxjs/vite-plugin/dist/index.mjs:91:21)
    at Object.generateBundle (file:///Users/.../node_modules/.pnpm/@[email protected]/node_modules/@crxjs/vite-plugin/dist/index.mjs:1595:40)
    at file:///Users/.../node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/rollup.js:22748:40
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
 ELIFECYCLE  Command failed with exit code 1.

System Info

System:
    OS: macOS 13.4.1
    CPU: (20) x64 Intel(R) Core(TM) i9-10900K CPU @ 3.70GHz
    Memory: 4.85 GB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.14.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.3.1 - /usr/local/bin/npm
    pnpm: 8.6.10 - ~/Library/pnpm/pnpm
  Browsers:
    Chrome: 115.0.5790.102
    Safari: 16.5.1
  npmPackages:
    @crxjs/vite-plugin: 2.0.0-beta.18 => 2.0.0-beta.18 
    @sentry/vite-plugin: ^2.5.0 => 2.5.0
    vite: ^3.2.5 => 3.2.6

Severity

blocking all usage of RPCE

xneworlds avatar Jul 25 '23 13:07 xneworlds

Also seeing this when including @sentry/vite-plugin.

chronicIntrovert avatar Aug 07 '23 19:08 chronicIntrovert

Ended up same with trying to publish source maps to Sentry. @xneworlds have you had success with this?

flexchar avatar Sep 17 '23 21:09 flexchar

Ended up same with trying to publish source maps to Sentry. @xneworlds have you had success with this?

I was unable to solve the problem through the plugin, but I achieved my goal by manually uploading source maps using sentry-cli.

xneworlds avatar Sep 18 '23 02:09 xneworlds

I'm also getting this error while setting this in my Vite config:

build: {
    rollupOptions: {
           output: {
                inlineDynamicImports: true,
          },
    }
  },
vite v2.9.15 building for production...
✓ 383 modules transformed.
[crx:manifest-post] Unexpected token o in JSON at position 0
error during build:
SyntaxError: Unexpected token o in JSON at position 0
    at JSON.parse (<anonymous>)
    at Object.decodeManifest (file:///<project>/node_modules/.pnpm/@[email protected][email protected]/node_modules/@crxjs/vite-plugin/dist/index.mjs:93:21)
    at Object.generateBundle (file:///<project>/node_modules/.pnpm/@[email protected][email protected]/node_modules/@crxjs/vite-plugin/dist/index.mjs:2909:40)
    at /<project>/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/shared/rollup.js:22834:37

fbjorn avatar Oct 06 '23 11:10 fbjorn