farm-fe / farm

Extremely fast Vite-compatible web build tool written in Rust
https://farmfe.org
MIT License
4.97k stars 165 forks source link

[Bug Report]: farm打包vite-plugin-sentry报错 #1889

Open hyk5245 opened 2 days ago

hyk5245 commented 2 days ago

Steps to reproduce

npm run build:farm

"build:farm": "cross-env farm build",

Reproduce link

No response

What is actually happening?

使用vite打包正常,换成farm后,打包报下面的错误,不知道是否是插件不兼容:

file:///Users/xxx/Documents/code/txz-oss-web/node_modules/.pnpm/vite-plugin-sentry@1.4.0_vite@4.4.0_@types+node@20.4.0_less@4.1.3_lightningcss@1.27.0_sass@1.63.6_terser@5.18.0_/node_modules/vite-plugin-sentry/dist/index.mjs:218
                const reportSentryError = legacyErrorHandlingMode ? this.warn : this.error;
TypeError: Cannot read properties of undefined (reading 'error')
    at file:///Users/Zhuanz/Documents/code/txz-oss-web/node_modules/.pnpm/vite-plugin-sentry@1.4.0_vite@4.4.0_@types+node@20.4.0_less@4.1.3_lightningcss@1.27.0_sass@1.63.6_terser@5.18.0_/node_modules/vite-plugin-sentry/dist/index.mjs:218:86
    at Generator.next (<anonymous>)
    at file:///Users/Zhuanz/Documents/code/txz-oss-web/node_modules/.pnpm/vite-plugin-sentry@1.4.0_vite@4.4.0_@types+node@20.4.0_less@4.1.3_lightningcss@1.27.0_sass@1.63.6_terser@5.18.0_/node_modules/vite-plugin-sentry/dist/index.mjs:29:71
    at new Promise (<anonymous>)
    at __awaiter (file:///Users/Zhuanz/Documents/code/txz-oss-web/node_modules/.pnpm/vite-plugin-sentry@1.4.0_vite@4.4.0_@types+node@20.4.0_less@4.1.3_lightningcss@1.27.0_sass@1.63.6_terser@5.18.0_/node_modules/vite-plugin-sentry/dist/index.mjs:25:12)
    at closeBundle (file:///Users/Zhuanz/Documents/code/txz-oss-web/node_modules/.pnpm/vite-plugin-sentry@1.4.0_vite@4.4.0_@types+node@20.4.0_less@4.1.3_lightningcss@1.27.0_sass@1.63.6_terser@5.18.0_/node_modules/vite-plugin-sentry/dist/index.mjs:216:20)
    at file:///Users/Zhuanz/Documents/code/txz-oss-web/node_modules/.pnpm/@farmfe+core@1.3.29_bufferutil@4.0.8/node_modules/@farmfe/core/dist/plugin/js/vite-plugin-adapter.js:499:37
    at Object.executor (file:///Users/Zhuanz/Documents/code/txz-oss-web/node_modules/.pnpm/@farmfe+core@1.3.29_bufferutil@4.0.8/node_modules/@farmfe/core/dist/plugin/js/vite-plugin-adapter.js:151:30)
    at Compiler.callWriteResourcesHook (file:///Users/Zhuanz/Documents/code/txz-oss-web/node_modules/.pnpm/@farmfe+core@1.3.29_bufferutil@4.0.8/node_modules/@farmfe/core/dist/compiler/index.js:116:48)
    at Compiler.writeResourcesToDisk (file:///Users/Zhuanz/Documents/code/txz-oss-web/node_modules/.pnpm/@farmfe+core@1.3.29_bufferutil@4.0.8/node_modules/@farmfe/core/dist/compiler/index.js:112:14)
    at file:///Users/Zhuanz/Documents/code/txz-oss-web/node_modules/.pnpm/@farmfe+core@1.3.29_bufferutil@4.0.8/node_modules/@farmfe/core/dist/index.js:189:18
    at async compilerHandler (file:///Users/Zhuanz/Documents/code/txz-oss-web/node_modules/.pnpm/@farmfe+core@1.3.29_bufferutil@4.0.8/node_modules/@farmfe/core/dist/utils/build.js:11:9)
    at async createBundleHandler (file:///Users/Zhuanz/Documents/code/txz-oss-web/node_modules/.pnpm/@farmfe+core@1.3.29_bufferutil@4.0.8/node_modules/@farmfe/core/dist/index.js:179:5)
    at async build (file:///Users/Zhuanz/Documents/code/txz-oss-web/node_modules/.pnpm/@farmfe+core@1.3.29_bufferutil@4.0.8/node_modules/@farmfe/core/dist/index.js:47:9)
    at async handleAsyncOperationErrors (file:///Users/Zhuanz/Documents/code/txz-oss-web/node_modules/.pnpm/@farmfe+cli@1.0.4/node_modules/@farmfe/cli/dist/utils.js:111:9)

System Info

System:
    OS: macOS 14.5
    CPU: (8) arm64 Apple M1
    Memory: 467.89 MB / 8.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.20.0 - ~/.nvm/versions/node/v18.20.0/bin/node
    npm: 10.5.0 - ~/.nvm/versions/node/v18.20.0/bin/npm
    pnpm: 9.12.2 - ~/.nvm/versions/node/v18.20.0/bin/pnpm
  Browsers:
    Safari: 17.5
  npmPackages:
    @farmfe/core: ^1.3.29 => 1.3.29
shulandmimi commented 1 day ago

closeBundle 中 this 暂时不兼容,可以考虑使用 @sentry/vite-plugin

参考 https://github.com/farm-fe/farm/issues/1496#issuecomment-2267364905

hyk5245 commented 1 day ago

@shulandmimi 我换成了@sentry/vite-plugin,但是打包之后会报两个错:

shulandmimi commented 1 day ago

未复现,麻烦提供一个最小复现 demo 或者 提供一下 app.config 以及报错内容的打包前后的内容(可以关闭 minify 以及将 mode 设置为 development 获得未压缩的内容)

export default defineConfig({
    // ...
  compilation: {
    mode: 'development',
    minify: false,
  }
    // ...
});