Skip to content
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

fix(preset-vue): yarn mode webpack require hook is invalid #12653

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/bundler-vite/src/config/transformer/target.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default (function target(userConfig) {
return false;
}

const isLegacy = isLegacyBrowser(userConfig.targets);
const isLegacy = isLegacyBrowser(userConfig.targets || {});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

targets 为空时 Object.keys 有问题


// convert { ie: 11 } to ['ie11']
// 低版本浏览器需要使用 legacy 插件 同时设置会有 warning
Expand Down
5 changes: 3 additions & 2 deletions packages/preset-vue/src/features/config/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import Config from '@umijs/bundler-webpack/compiled/webpack-5-chain';
import { IApi } from 'umi';
import VueLoaderPlugin from 'vue-loader/dist/pluginWebpack5.js';
import { addAssetRules } from './assetRules';

export function getConfig(config: Config, api: IApi) {
Expand All @@ -23,7 +22,9 @@ export function getConfig(config: Config, api: IApi) {
babelParserPlugins: ['jsx', 'classProperties', 'decorators-legacy'],
});

config.plugin('vue-loader-plugin').use(VueLoaderPlugin);
const VueLoaderPlugin = require('vue-loader/dist/pluginWebpack5');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

修复移除 requireHook 导致的 vite 失败

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

失败的原因是因为 default 导出么


config.plugin('vue-loader-plugin').use(VueLoaderPlugin.default);

// https://github.com/vuejs/vue-loader/issues/1435#issuecomment-869074949
config.module
Expand Down
Loading