Open the HBuilderX.4.15.2024050802\HBuilderX\plugins\uniapp-cli path in hbuilderx.
Find the HBuilderX.4.15.2024050802\HBuilderX\plugins\uniapp-cli\bin\uniapp-cli.js folder 📂. Everything starts from here.
Find the file above and log it.
Find that our print is there, indicating that we didn't find the wrong place.
Then follow the code and find that service.run uni-build is executed. Let's see how run uni-build is done. This is the main line.
// @vue/cli-service/lib/Service.js
const service = new Service(process.env.VUE_CLI_CONTEXT || process.cwd())
service.run((process.env.NODE_ENV === 'development' && platform === 'h5') ? 'uni-serve' : 'uni-build',
args).catch(err => {
error(err)
process.exit(1)
})
When new Service is called, the package node_modules@vue\cli-service is referenced, and this package exports
which is the file @vue/cli-service/lib/Service.js.
Find the run in it.
The init initializes the uni-build command.
Print to see which packages are used
Except for the ones with built-in, the others are referenced from the corresponding packages, so these packages are referenced.
It is found that the new version cannot run on the hbuilder software due to the different configurations of the package @dcloudio/vue-cli-plugin-hbuilderx.
Replace two packages, vue-cli-plugin-hbuilderx and vue-cli-plugin-uni.
Then handle this error and find that it cannot detect file updates, indicating that there is a problem with the configuration in these two packages.
let time = uniStatisticsConfig.reportInterval;
Find this line of code, which may affect type checking.
// Restore ts checking for vue-loader
tsLoaderOptions.transpileOnly = false
Configure uni's shared methods
updateTsLoader did not match any files
Compare the configurations and find that the logic for writing configurations for ts loader in updateTsLoader is different in the two versions. Try modifying it.
Try to overwrite the entire configure-webpack file, test it, and the compilation still does not pass.
It may be this file
vue-cli-plugin-builders
vue-cli-plugin-uni
Both of these packages are overwritten, and they can be compiled normally, but there will be an error in the end.
The error is here, I don't know why.
return reject(Build failed with errors.
)
The principle is not to change the project, only change hbuilderx.
Test whether replacing only vue-cli-plugin-uni can run normally.
Test again
webpack.nvue.conf.js file reports an error, try copying the configuration of 3216.
vue-cli-plugin-hbuilderx/build/webpack.nvue.conf.js
Finally, the compilation failed and cannot be hot updated.
ERROR Build failed with errors.
Replace the two packages without changing other content.
vue-cli-plugin-hbuilderx
vue-cli-plugin-uni
Try to view the compilation result.
Compilation error, open the error message and you can see
Comment out here
Then modify the error of uni statistics
It can run normally, this solution is feasible, the problem of not being able to run the new version is caused by these two packages, plus the uni statistics and webpack hasError exceptions.