Skip to content

Commit 9fe5e72

Browse files
authored
fix: replace chain methods with expressions (#6)
1 parent 7065098 commit 9fe5e72

File tree

5 files changed

+18
-40
lines changed

5 files changed

+18
-40
lines changed

src/createLoadableComponentsTransformer.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,7 @@ function visitLoadableComponents(state: State, node: ts.Node) {
5353
properties.map((fn) => fn(state, importList[0], loader)),
5454
true,
5555
);
56-
return ts.factory.createCallChain(
57-
node.expression,
58-
void 0,
59-
node.typeArguments,
60-
args,
61-
);
56+
return ts.factory.createCallExpression(node.expression, void 0, args);
6257
}
6358

6459
export function createLoadableComponentsTransformer(

src/properties/createChunkName.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export function createChunkName(
115115
webpackChunkName = requestNode.head.text
116116
.replace(WEBPACK_PATH_NAME_NORMALIZE_REPLACE_REGEX, '-')
117117
.replace(MATCH_LEFT_HYPHENS_REPLACE_REGEX, '');
118-
chunkNameNode = ts.factory.createCallChain(
118+
chunkNameNode = ts.factory.createCallExpression(
119119
ts.factory.createPropertyAccessChain(
120120
ts.factory.createTemplateExpression(
121121
ts.factory.createTemplateHead(webpackChunkName),
@@ -136,7 +136,6 @@ export function createChunkName(
136136
'replace',
137137
),
138138
void 0,
139-
void 0,
140139
[
141140
ts.factory.createRegularExpressionLiteral(
142141
`/${WEBPACK_PATH_NAME_NORMALIZE_REPLACE_REGEX.source}/g`,

src/properties/createIsReady.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,18 @@ const IS_READY_BODY = ts.factory.createReturnStatement(
1515
ts.factory.createStringLiteral('undefined'),
1616
),
1717
ts.SyntaxKind.AmpersandAmpersandToken,
18-
ts.factory.createCallChain(
18+
ts.factory.createCallExpression(
1919
ts.factory.createIdentifier('Boolean'),
2020
void 0,
21-
void 0,
2221
[
23-
ts.factory.createElementAccessChain(
22+
ts.factory.createElementAccessExpression(
2423
ts.factory.createIdentifier('__webpack_modules__'),
25-
void 0,
26-
ts.factory.createCallChain(
27-
ts.factory.createPropertyAccessChain(
24+
ts.factory.createCallExpression(
25+
ts.factory.createPropertyAccessExpression(
2826
ts.factory.createThis(),
29-
void 0,
3027
ts.factory.createIdentifier('resolve'),
3128
),
3229
void 0,
33-
void 0,
3430
[ts.factory.createIdentifier('props')],
3531
),
3632
),

src/properties/createRequireSync.ts

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,42 +15,35 @@ const REQUIRE_SYNC_BODY = ts.factory.createReturnStatement(
1515
ts.factory.createStringLiteral('undefined'),
1616
),
1717
ts.factory.createToken(ts.SyntaxKind.QuestionToken),
18-
ts.factory.createCallChain(
18+
ts.factory.createCallExpression(
1919
ts.factory.createIdentifier('__webpack_require__'),
2020
void 0,
21-
void 0,
2221
[
23-
ts.factory.createCallChain(
24-
ts.factory.createPropertyAccessChain(
22+
ts.factory.createCallExpression(
23+
ts.factory.createPropertyAccessExpression(
2524
ts.factory.createThis(),
26-
void 0,
2725
'resolve',
2826
),
2927
void 0,
30-
void 0,
3128
[ts.factory.createIdentifier('props')],
3229
),
3330
],
3431
),
3532
ts.factory.createToken(ts.SyntaxKind.ColonToken),
36-
ts.factory.createCallChain(
37-
ts.factory.createCallChain(
33+
ts.factory.createCallExpression(
34+
ts.factory.createCallExpression(
3835
ts.factory.createIdentifier('eval'),
3936
void 0,
40-
void 0,
4137
[ts.factory.createStringLiteral('module.require')],
4238
),
4339
void 0,
44-
void 0,
4540
[
46-
ts.factory.createCallChain(
47-
ts.factory.createPropertyAccessChain(
41+
ts.factory.createCallExpression(
42+
ts.factory.createPropertyAccessExpression(
4843
ts.factory.createThis(),
49-
void 0,
5044
'resolve',
5145
),
5246
void 0,
53-
void 0,
5447
[ts.factory.createIdentifier('props')],
5548
),
5649
],

src/properties/createResolve.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,28 @@ export function createResolve(
2323
void 0,
2424
ts.factory.createBlock([
2525
ts.factory.createIfStatement(
26-
ts.factory.createPropertyAccessChain(
26+
ts.factory.createPropertyAccessExpression(
2727
ts.factory.createIdentifier('require'),
28-
void 0,
2928
'resolveWeak',
3029
),
3130
ts.factory.createReturnStatement(
32-
ts.factory.createCallChain(
33-
ts.factory.createPropertyAccessChain(
31+
ts.factory.createCallExpression(
32+
ts.factory.createPropertyAccessExpression(
3433
ts.factory.createIdentifier('require'),
35-
void 0,
3634
'resolveWeak',
3735
),
3836
void 0,
39-
void 0,
4037
[requestNode],
4138
),
4239
),
4340
ts.factory.createReturnStatement(
44-
ts.factory.createCallChain(
45-
ts.factory.createCallChain(
41+
ts.factory.createCallExpression(
42+
ts.factory.createCallExpression(
4643
ts.factory.createIdentifier('eval'),
4744
void 0,
48-
void 0,
4945
[ts.factory.createStringLiteral('require.resolve')],
5046
),
5147
void 0,
52-
void 0,
5348
[requestNode],
5449
),
5550
),

0 commit comments

Comments
 (0)