Skip to content

Commit 66c1863

Browse files
committed
fix(webpack): webpack comments without quote
1 parent a32d242 commit 66c1863

13 files changed

+2745
-2374
lines changed

compare/output_babel.js

Lines changed: 133 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,41 @@
44
*/
55
import loadable from '@loadable/component';
66
export const LazyFoo = loadable({
7+
resolved: {},
8+
79
chunkName() {
810
return 'input-AsyncDefaultComponent';
911
},
1012

1113
isReady(props) {
14+
const key = this.resolve(props);
15+
16+
if (this.resolved[key] !== true) {
17+
return false;
18+
}
19+
1220
if (typeof __webpack_modules__ !== 'undefined') {
13-
return !!__webpack_modules__[this.resolve(props)];
21+
return !!__webpack_modules__[key];
1422
}
1523

1624
return false;
1725
},
1826

19-
requireAsync: () =>
27+
importAsync: () =>
2028
import(
2129
/* webpackChunkName: "input-AsyncDefaultComponent" */
2230
'./input/AsyncDefaultComponent'
2331
),
2432

33+
requireAsync(props) {
34+
const key = this.resolve(props);
35+
this.resolved[key] = false;
36+
return this.importAsync(props).then((resolved) => {
37+
this.resolved[key] = true;
38+
return resolved;
39+
});
40+
},
41+
2542
requireSync(props) {
2643
const id = this.resolve(props);
2744

@@ -41,24 +58,41 @@ export const LazyFoo = loadable({
4158
},
4259
});
4360
export const DefaultLib = loadable.lib({
61+
resolved: {},
62+
4463
chunkName() {
4564
return 'input-AsyncComponent';
4665
},
4766

4867
isReady(props) {
68+
const key = this.resolve(props);
69+
70+
if (this.resolved[key] !== true) {
71+
return false;
72+
}
73+
4974
if (typeof __webpack_modules__ !== 'undefined') {
50-
return !!__webpack_modules__[this.resolve(props)];
75+
return !!__webpack_modules__[key];
5176
}
5277

5378
return false;
5479
},
5580

56-
requireAsync: () =>
81+
importAsync: () =>
5782
import(
5883
/* webpackChunkName: "input-AsyncComponent" */
5984
'./input/AsyncComponent'
6085
),
6186

87+
requireAsync(props) {
88+
const key = this.resolve(props);
89+
this.resolved[key] = false;
90+
return this.importAsync(props).then((resolved) => {
91+
this.resolved[key] = true;
92+
return resolved;
93+
});
94+
},
95+
6296
requireSync(props) {
6397
const id = this.resolve(props);
6498

@@ -79,24 +113,41 @@ export const DefaultLib = loadable.lib({
79113
});
80114
export const WithOptionsLoadable = loadable(
81115
{
116+
resolved: {},
117+
82118
chunkName() {
83119
return 'input-AsyncDefaultComponent';
84120
},
85121

86122
isReady(props) {
123+
const key = this.resolve(props);
124+
125+
if (this.resolved[key] !== true) {
126+
return false;
127+
}
128+
87129
if (typeof __webpack_modules__ !== 'undefined') {
88-
return !!__webpack_modules__[this.resolve(props)];
130+
return !!__webpack_modules__[key];
89131
}
90132

91133
return false;
92134
},
93135

94-
requireAsync: () =>
136+
importAsync: () =>
95137
import(
96138
/* webpackChunkName: "input-AsyncDefaultComponent" */
97139
'./input/AsyncDefaultComponent'
98140
),
99141

142+
requireAsync(props) {
143+
const key = this.resolve(props);
144+
this.resolved[key] = false;
145+
return this.importAsync(props).then((resolved) => {
146+
this.resolved[key] = true;
147+
return resolved;
148+
});
149+
},
150+
100151
requireSync(props) {
101152
const id = this.resolve(props);
102153

@@ -121,24 +172,41 @@ export const WithOptionsLoadable = loadable(
121172
);
122173
export const WithOptionsLib = loadable.lib(
123174
{
175+
resolved: {},
176+
124177
chunkName() {
125178
return 'input-AsyncComponent';
126179
},
127180

128181
isReady(props) {
182+
const key = this.resolve(props);
183+
184+
if (this.resolved[key] !== true) {
185+
return false;
186+
}
187+
129188
if (typeof __webpack_modules__ !== 'undefined') {
130-
return !!__webpack_modules__[this.resolve(props)];
189+
return !!__webpack_modules__[key];
131190
}
132191

133192
return false;
134193
},
135194

136-
requireAsync: () =>
195+
importAsync: () =>
137196
import(
138197
/* webpackChunkName: "input-AsyncComponent" */
139198
'./input/AsyncComponent'
140199
),
141200

201+
requireAsync(props) {
202+
const key = this.resolve(props);
203+
this.resolved[key] = false;
204+
return this.importAsync(props).then((resolved) => {
205+
this.resolved[key] = true;
206+
return resolved;
207+
});
208+
},
209+
142210
requireSync(props) {
143211
const id = this.resolve(props);
144212

@@ -163,24 +231,41 @@ export const WithOptionsLib = loadable.lib(
163231
);
164232
export const NonSsrLoadable = loadable(
165233
{
234+
resolved: {},
235+
166236
chunkName() {
167237
return 'input-AsyncDefaultComponent';
168238
},
169239

170240
isReady(props) {
241+
const key = this.resolve(props);
242+
243+
if (this.resolved[key] !== true) {
244+
return false;
245+
}
246+
171247
if (typeof __webpack_modules__ !== 'undefined') {
172-
return !!__webpack_modules__[this.resolve(props)];
248+
return !!__webpack_modules__[key];
173249
}
174250

175251
return false;
176252
},
177253

178-
requireAsync: () =>
254+
importAsync: () =>
179255
import(
180256
/* webpackChunkName: "input-AsyncDefaultComponent" */
181257
'./input/AsyncDefaultComponent'
182258
),
183259

260+
requireAsync(props) {
261+
const key = this.resolve(props);
262+
this.resolved[key] = false;
263+
return this.importAsync(props).then((resolved) => {
264+
this.resolved[key] = true;
265+
return resolved;
266+
});
267+
},
268+
184269
requireSync(props) {
185270
const id = this.resolve(props);
186271

@@ -205,24 +290,41 @@ export const NonSsrLoadable = loadable(
205290
);
206291
export const DynamicLoadable = loadable(
207292
{
293+
resolved: {},
294+
208295
chunkName(props) {
209296
return `input-${props.page}`.replace(/[^a-zA-Z0-9_!§$()=\-^°]+/g, '-');
210297
},
211298

212299
isReady(props) {
300+
const key = this.resolve(props);
301+
302+
if (this.resolved[key] !== true) {
303+
return false;
304+
}
305+
213306
if (typeof __webpack_modules__ !== 'undefined') {
214-
return !!__webpack_modules__[this.resolve(props)];
307+
return !!__webpack_modules__[key];
215308
}
216309

217310
return false;
218311
},
219312

220-
requireAsync: (props) =>
313+
importAsync: (props) =>
221314
import(
222315
/* webpackChunkName: "input-[request]" */
223316
`./input/${props.page}`
224317
),
225318

319+
requireAsync(props) {
320+
const key = this.resolve(props);
321+
this.resolved[key] = false;
322+
return this.importAsync(props).then((resolved) => {
323+
this.resolved[key] = true;
324+
return resolved;
325+
});
326+
},
327+
226328
requireSync(props) {
227329
const id = this.resolve(props);
228330

@@ -247,24 +349,41 @@ export const DynamicLoadable = loadable(
247349
);
248350
export const DynamicLib = loadable.lib(
249351
{
352+
resolved: {},
353+
250354
chunkName(props) {
251355
return `input-${props.page}`.replace(/[^a-zA-Z0-9_!§$()=\-^°]+/g, '-');
252356
},
253357

254358
isReady(props) {
359+
const key = this.resolve(props);
360+
361+
if (this.resolved[key] !== true) {
362+
return false;
363+
}
364+
255365
if (typeof __webpack_modules__ !== 'undefined') {
256-
return !!__webpack_modules__[this.resolve(props)];
366+
return !!__webpack_modules__[key];
257367
}
258368

259369
return false;
260370
},
261371

262-
requireAsync: (props) =>
372+
importAsync: (props) =>
263373
import(
264374
/* webpackChunkName: "input-[request]" */
265375
`./input/${props.page}`
266376
),
267377

378+
requireAsync(props) {
379+
const key = this.resolve(props);
380+
this.resolved[key] = false;
381+
return this.importAsync(props).then((resolved) => {
382+
this.resolved[key] = true;
383+
return resolved;
384+
});
385+
},
386+
268387
requireSync(props) {
269388
const id = this.resolve(props);
270389

0 commit comments

Comments
 (0)