-
Notifications
You must be signed in to change notification settings - Fork 9
fix: 解决node23版本不兼容+webpack持久缓存修复 #115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
643a141
1ecf516
f7d0b0b
6d9f5c3
6ff5233
739c4da
904acf7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,8 +7,11 @@ const { | |
| exit, | ||
| error, | ||
| log, | ||
| stopSpinner | ||
| stopSpinner, | ||
| hasYarn, | ||
| hasPnpm3OrLater | ||
| } = require('@vue/cli-shared-utils') | ||
| const { loadOptions } = require('@vue/cli/lib/options') | ||
| const Creator = require('@vue/cli/lib/Creator') | ||
| const loadRemotePreset = require('@vue/cli/lib/util/loadRemotePreset') | ||
| const loadLocalPreset = require('@vue/cli/lib/util/loadLocalPreset') | ||
|
|
@@ -176,6 +179,35 @@ async function create (projectName, options, preset = null) { | |
|
|
||
| const creator = new Creator(name, targetDir, getPromptModules()) | ||
|
|
||
| const packageManager = | ||
| options.packageManager || | ||
| loadOptions().packageManager || | ||
| (hasYarn() ? 'yarn' : null) || | ||
| (hasPnpm3OrLater() ? 'pnpm' : 'npm') | ||
|
|
||
| // @achrinza/node-ipc与node23不兼容,需要映射到修复包node-ipc-compat@1.0.0 | ||
| creator.on('creation', ({ event }) => { | ||
| if (event === 'plugins-install' || event === 'deps-install') { | ||
| try { | ||
| const pkgPath = path.resolve(targetDir, 'package.json') | ||
| const pkg = fs.readJsonSync(pkgPath) | ||
| // 根据包管理器类型写入对应的 overrides 配置,yarn无需处理 | ||
| if (packageManager === 'pnpm') { | ||
| pkg.pnpm = { | ||
| overrides: { | ||
| '@achrinza/node-ipc': 'npm:node-ipc-compat@1.0.0' | ||
| } | ||
| } | ||
| } else if (packageManager === 'npm') { | ||
| pkg.overrides = { | ||
| '@achrinza/node-ipc': 'npm:node-ipc-compat@1.0.0' | ||
| } | ||
| } | ||
| fs.writeJsonSync(pkgPath, pkg, { spaces: 2 }) | ||
| } catch (e) {} | ||
| } | ||
| }) | ||
|
Comment on lines
+189
to
+209
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Risk of overwriting existing pnpm/npm configurations. The code completely replaces 🔎 Proposed fix to merge instead of replace // 根据包管理器类型写入对应的 overrides 配置,yarn无需处理
if (packageManager === 'pnpm') {
- pkg.pnpm = {
- overrides: {
- '@achrinza/node-ipc': 'npm:node-ipc-compat@1.0.0'
- }
- }
+ pkg.pnpm = pkg.pnpm || {}
+ pkg.pnpm.overrides = pkg.pnpm.overrides || {}
+ pkg.pnpm.overrides['@achrinza/node-ipc'] = 'npm:node-ipc-compat@1.0.0'
} else if (packageManager === 'npm') {
- pkg.overrides = {
- '@achrinza/node-ipc': 'npm:node-ipc-compat@1.0.0'
- }
+ pkg.overrides = pkg.overrides || {}
+ pkg.overrides['@achrinza/node-ipc'] = 'npm:node-ipc-compat@1.0.0'
}🤖 Prompt for AI Agents |
||
|
|
||
| if (process.env.VUE_CLI_TEST || process.env.VUE_CLI_DEBUG) { | ||
| // 单测下,link bin文件到源码 | ||
| const { linkBin } = require('@vue/cli/lib/util/linkBin') | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,8 +1,7 @@ | ||||||||
| const { normalizeCommandArgs } = require('@mpxjs/cli-shared-utils') | ||||||||
| const { normalizeCommandArgs, getCurrentTarget } = require('@mpxjs/cli-shared-utils') | ||||||||
| const { addBaseWebpackConfig } = require('../../config/base.config') | ||||||||
| const { addBuildWebpackConfig } = require('../../config/build.config') | ||||||||
| const { resolveBuildWebpackConfigByTarget } = require('@mpxjs/vue-cli-plugin-mpx/config') | ||||||||
| const { getCurrentTarget } = require('@mpxjs/cli-shared-utils') | ||||||||
| const { handleWebpackDone } = require('@mpxjs/vue-cli-plugin-mpx/utils/webpack') | ||||||||
| const webpack = require('webpack') | ||||||||
| const fs = require('fs-extra') | ||||||||
|
|
@@ -42,7 +41,8 @@ module.exports.registerBuildCommand = function (api, options) { | |||||||
| const { webpackConfig, target } = await getBaseConfig(ssrMode) | ||||||||
| return new Promise((resolve, reject) => { | ||||||||
| webpack(webpackConfig, (err, stats) => { | ||||||||
| handleWebpackDone(err, stats, target, api) | ||||||||
| // todo:此处target应该是一个布尔值,判断是否watch, 直接把target和api替换掉有问题嘛,当前只将api换为了options | ||||||||
| handleWebpackDone(err, stats, target, options) | ||||||||
|
Comment on lines
+44
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: Incorrect parameter type passed to handleWebpackDone. The third parameter of For build commands, the watch parameter should typically be:
🔎 Proposed fix- // todo:此处target应该是一个布尔值,判断是否watch, 直接把target和api替换掉有问题嘛,当前只将api换为了options
- handleWebpackDone(err, stats, target, options)
+ handleWebpackDone(err, stats, false, options)Or if watch mode should be supported: - // todo:此处target应该是一个布尔值,判断是否watch, 直接把target和api替换掉有问题嘛,当前只将api换为了options
- handleWebpackDone(err, stats, target, options)
+ handleWebpackDone(err, stats, args.watch || false, options)📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||
| .then((...res) => { | ||||||||
| resolve(...res) | ||||||||
| }) | ||||||||
|
|
||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,11 @@ | ||
| const autoprefixer = require('autoprefixer') | ||
| const RN = ['android', 'ios', 'harmony'] | ||
| const isRN = RN.includes( | ||
| process.env.MPX_CURRENT_TARGET_MODE | ||
| ) | ||
| // RN环境下去除postcss的autoprefix插件 | ||
| module.exports = { | ||
| plugins: [ | ||
| require('autoprefixer')({ remove: false }) | ||
| ] | ||
| } | ||
| !isRN && autoprefixer({ remove: false }) | ||
| ].filter(Boolean) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: mpx-ecology/mpx-cli
Length of output: 351
The package
node-ipc-compat@1.0.0does not exist on the NPM registry and will cause installation to fail.The hardcoded alias to
npm:node-ipc-compat@1.0.0cannot be resolved. Web searches show no published package by this name or version. Similar alternatives like@node-ipc/compat(version 9.2.5) exist but not the referenced package. This dependency must be corrected before the code can be used in production, as any package installation will fail with a resolution error.🤖 Prompt for AI Agents