[Bug]: github工作流中yarnbuild 会完成打包但是无法自动退出命令行
Version
System:
OS: macOS 13.6.4
CPU: (8) arm64 Apple M2
Memory: 118.34 MB / 8.00 GB
Shell: 5.9 - /bin/zsh
Browsers:
Chrome: 128.0.6613.114
Safari: 16.6
npmPackages:
@modern-js/app-tools: 2.58.2 => 2.58.2
@modern-js/eslint-config: 2.58.2 => 2.58.2
@modern-js/runtime: 2.58.2 => 2.58.2
@modern-js/tsconfig: 2.58.2 => 2.58.2
Details
本地打包似乎是每次modern.config.ts更改过后进行yarnbuild,就会出现日志已经说明打包完成但是不退出命令行的情况;生产环境的workflow会永远无法退出命令行导致工作流卡住
Reproduce link
https://gist.github.com/katocrane/059c64273aa175407b9d99bc01a144ee
Reproduce Steps
执行yarn build
I had the same issue with with pnpm build.
I switched to to using rspack as the bundler and it fixed this hanging problem.
Seems like it's an issue with the Webpack integration?
In modern.config.js
appTools({
bundler: 'rspack',
}),
Try this package to find the root cause: https://www.npmjs.com/package/why-is-node-running
why-is-node-runningI tried to use this library but it didn't compile into modern.js successfully. Do you have any good code snippets for reference?
You can use it in the edenx.config.ts file
` tools: { styledComponents: false,
webpack: config => {
// 确保 config.plugins 已被定义
config.plugins = config.plugins || [];
// 添加自定义 DonePlugin 插件 在生产环境下保证打包后退出终端命令
if (process.env.NODE_ENV === 'production') {
config.plugins.push({
apply: compiler => {
compiler.hooks.done.tap('DonePlugin', () => {
setTimeout(() => {
console.log('✨ Build completed. Exiting process.');
whyIsNodeRunning();
// process.exit(0); // 构建完成后强制退出
});
});
},
});
}
},
},`
`> yarn build yarn run v1.22.22 warning package.json: No license field $ modern build Modern.js Framework v2.58.2
info Starting production build... info Type checker is enabled. It may take some time. ready Compiled in 18.7 s (web) ✨ Build completed. Exiting process. There are 62 handle(s) keeping the process running.
FILEHANDLE
(unknown stack trace)
FILEHANDLE
(unknown stack trace)
FILEHANDLE
(unknown stack trace)
FILEHANDLE
(unknown stack trace)
error TypeError: Cannot read properties of null (reading 'startsWith')
at /Users/mac/Documents/youjiaassessmanage/node_modules/.cache/bundle-require/modern.config.PENeOo51.cjs:66:77
at Array.filter (
As you can see, I have already integrated it, but it seems to have a problem. I have done a series of troubleshooting but it has not been solved.
这个 build 卡主问题现在应该得到了解决。你可以重新尝试一下。