Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 5, 2025. It is now read-only.

Commit 11930ea

Browse files
committed
fix
1 parent 0846a4c commit 11930ea

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
lines changed

‎packages/plugin-webpack5-react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@alicloud/console-toolkit-plugin-webpack5-react",
3-
"version": "1.3.1",
3+
"version": "1.3.2",
44
"description": "console toolkit plugin for base react app",
55
"main": "lib/index.js",
66
"scripts": {

‎packages/plugin-webpack5-react/src/webpack/rules/jsx/index.ts

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,28 @@ import { createRules } from '../../../utils';
66
import { BreezrReactBabelOption } from '../../../types';
77
import { getPkgPath, shouldTransform } from './es5ImcompatibleVersions';
88

9-
const addEs5ImcompatibleVersions = (config: Chain, babelConfig: any) => {
10-
const extraBabelIncludes = [
11-
(a: string) => {
12-
if (!a.includes('node_modules')) {
9+
const addEs5IncompatibleVersions = (config: Chain, babelConfig: any, es5: boolean, extraInclude?: Webpack.RuleSetCondition) => {
10+
const extraBabelIncludes: Webpack.RuleSetCondition = [];
11+
12+
if (es5) {
13+
extraBabelIncludes.push((path: string) => {
14+
if (!path.includes('node_modules')) {
1315
return false;
1416
}
15-
const pkgPath = getPkgPath(a);
17+
const pkgPath = getPkgPath(path);
1618
return shouldTransform(pkgPath);
19+
})
20+
}
21+
22+
if (extraInclude) {
23+
if (typeof extraInclude === 'string' && !extraInclude.startsWith('/')) {
24+
extraBabelIncludes.push(require.resolve(extraInclude, { paths: [process.cwd()] }));
25+
} else {
26+
extraBabelIncludes.push(extraInclude);
1727
}
18-
];
28+
}
1929

20-
extraBabelIncludes.forEach((include: Webpack.RuleSetConditionAbsolute, index: number) => {
30+
extraBabelIncludes.forEach((include: Webpack.RuleSetCondition, index: number) => {
2131
const rule = `extraBabelInclude_${index}`;
2232
config.module
2333
.rule(rule)
@@ -61,12 +71,12 @@ export const jsx = (config: Chain, options: BreezrReactBabelOption) => {
6171
test: /\.jsx?$/
6272
});
6373

64-
if (include) {
65-
rule
66-
.include
67-
.add(include)
68-
.end();
69-
}
74+
// if (include) {
75+
// rule
76+
// .include
77+
// .add(include)
78+
// .end();
79+
// }
7080

7181
let babelConfig = options.babelOption ? options.babelOption : {
7282
presets: [
@@ -99,7 +109,5 @@ export const jsx = (config: Chain, options: BreezrReactBabelOption) => {
99109
.loader(require.resolve('babel-loader'))
100110
.options(babelConfig);
101111

102-
if (es5ImcompatibleVersions) {
103-
addEs5ImcompatibleVersions(config, babelConfig);
104-
}
112+
addEs5IncompatibleVersions(config, babelConfig, !!es5ImcompatibleVersions, include);
105113
};

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /