crxjs / chrome-extension-tools

Bundling Chrome Extensions can be pretty complex. It doesn't have to be.
https://crxjs.dev/vite-plugin
2.71k stars 181 forks source link

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

Open xneworlds opened 1 year ago

xneworlds commented 1 year ago

Build tool

Vite

Where do you see the problem?

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/@crxjs+vite-plugin@2.0.0-beta.18/node_modules/@crxjs/vite-plugin/dist/index.mjs:91:21)
    at Object.generateBundle (file:///Users/.../node_modules/.pnpm/@crxjs+vite-plugin@2.0.0-beta.18/node_modules/@crxjs/vite-plugin/dist/index.mjs:1595:40)
    at file:///Users/.../node_modules/.pnpm/rollup@2.79.1/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

chronicIntrovert commented 1 year ago

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

flexchar commented 11 months ago

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

xneworlds commented 11 months ago

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.

fbjorn commented 10 months ago

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/@crxjs+vite-plugin@1.0.14_vite@2.9.15/node_modules/@crxjs/vite-plugin/dist/index.mjs:93:21)
    at Object.generateBundle (file:///<project>/node_modules/.pnpm/@crxjs+vite-plugin@1.0.14_vite@2.9.15/node_modules/@crxjs/vite-plugin/dist/index.mjs:2909:40)
    at /<project>/node_modules/.pnpm/rollup@2.72.1/node_modules/rollup/dist/shared/rollup.js:22834:37