Open
Description
Version
System:
OS: macOS 15.5
CPU: (10) arm64 Apple M1 Pro
Memory: 100.14 MB / 32.00 GB
Shell: 5.9 - /opt/homebrew/bin/zsh
Browsers:
Chrome: 137.0.7151.120
Edge: 137.0.3296.93
Safari: 18.5
npmPackages:
@rsdoctor/rspack-plugin: 1.1.0 => 1.1.0
Binaries:
Node: 20.15.1 - ~/.nvm/versions/node/v20.15.1/bin/node
pnpm: 8.14.0 - ~/.nvm/versions/node/v20.15.1/bin/pnpm
Details
In my Rspack config, I have configured Rsdoctor in the plugins
field as something like this:
import { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';
...
{
...
plugins: [
....,
process.env.RSDOCTOR && new RsdoctorRspackPlugin()
]
}
On version 1.1.0 of @rsdoctor/rspack-plugin
, when running a Rspack build, Rsdoctor works as expected (opens a UI with bundle analysis). However when changing it to v1.1.1 (or latest, 1.1.4), I encounter this error in the terminal on trying to build:
/Users/user/project/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected]_@swc+core_cbc4660d53021a296d716d034470cb0c/node_modules/@rsdoctor/utils/dist/cjs/common/global-config.js:71
mcpJson = JSON.parse(import_fs.default.readFileSync(mcpPortFilePath, "utf8"));
^
SyntaxError: Unexpected non-whitespace character after JSON at position 73
at JSON.parse (<anonymous>)
at Object.writeMcpPort (/Users/user/project/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected]_@swc+core_cbc4660d53021a296d716d034470cb0c/node_modules/@rsdoctor/utils/dist/cjs/common/global-config.js:71:20)
at RsdoctorServer.bootstrap (/Users/user/project/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected]_@swc+core@1_ae512a4388d0ed3c95be1642c2f22d7f/node_modules/@rsdoctor/sdk/dist/cjs/sdk/server/index.js:115:32)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async RsdoctorSDK.bootstrap (/Users/user/project/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected][email protected]_@swc+core@1_ae512a4388d0ed3c95be1642c2f22d7f/node_modules/@rsdoctor/sdk/dist/cjs/sdk/sdk/index.js:73:20)
Warning: command "rspack --env stage=staging" exited with non-zero status code
Reproduce link
https://github.com/giavinh79/rsdoctor-build-error
Reproduce Steps
The reproduction example linked above isn't identical to my project, but the error is still quite similar when built and run in my environment.
So in the reproduction link above:
pnpm i
pnpm run build
- I get back the error:
> @examples/[email protected] build /Users/giavinh.lam/dev/projects/rspack-minimal
> npm run build:s && npm run build:m
> @examples/[email protected] build:s
> ENABLE_CLIENT_SERVER=false NODE_ENV=production rspack build -c ./rspack.config.js
undefined:7
}
^
SyntaxError: Unexpected non-whitespace character after JSON at position 73
at JSON.parse (<anonymous>)
at Object.writeMcpPort (/Users/giavinh.lam/dev/projects/rspack-minimal/node_modules/.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@rsdoctor/utils/dist/cjs/common/global-config.js:71:20)
at RsdoctorServer.bootstrap (/Users/giavinh.lam/dev/projects/rspack-minimal/node_modules/.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@rsdoctor/sdk/dist/cjs/sdk/server/index.js:115:32)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async RsdoctorSDK.bootstrap (/Users/giavinh.lam/dev/projects/rspack-minimal/node_modules/.pnpm/@[email protected]_@[email protected][email protected]/node_modules/@rsdoctor/sdk/dist/cjs/sdk/sdk/index.js:73:20)
- If I change the version back to 1.1.0, the build runs fine.