Skip to content

Commit 9b2cf71

Browse files
fix: do not crash with 'false' aliases
1 parent 2388439 commit 9b2cf71

11 files changed

+222
-73
lines changed

package-lock.json

Lines changed: 65 additions & 65 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/plugins/postcss-import-parser.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,10 @@ const plugin = (options = {}) => {
166166
const needKeep = await options.filter(url, media);
167167

168168
if (!needKeep) {
169-
return null;
169+
return;
170170
}
171171
}
172172

173-
atRule.remove();
174-
175173
if (isRequestable) {
176174
const request = requestify(url, options.rootContext);
177175

@@ -180,9 +178,19 @@ const plugin = (options = {}) => {
180178
...new Set([request, url]),
181179
]);
182180

181+
if (!resolvedUrl) {
182+
return;
183+
}
184+
185+
atRule.remove();
186+
187+
// eslint-disable-next-line consistent-return
183188
return { url: resolvedUrl, media, prefix, isRequestable };
184189
}
185190

191+
atRule.remove();
192+
193+
// eslint-disable-next-line consistent-return
186194
return { url, media, prefix, isRequestable };
187195
})
188196
);

src/plugins/postcss-url-parser.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ const plugin = (options = {}) => {
292292
const needKeep = await options.filter(url);
293293

294294
if (!needKeep) {
295-
return null;
295+
return;
296296
}
297297
}
298298

@@ -309,19 +309,26 @@ const plugin = (options = {}) => {
309309
...new Set([request, url]),
310310
]);
311311

312+
if (!resolvedUrl) {
313+
return;
314+
}
315+
316+
// eslint-disable-next-line consistent-return
312317
return { ...parsedDeclaration, url: resolvedUrl, hash };
313318
})
314319
);
315320

316-
const results = await Promise.all(resolvedDeclarations);
317-
318321
const urlToNameMap = new Map();
319322
const urlToReplacementMap = new Map();
320323

321324
let hasUrlImportHelper = false;
322325

323-
for (let index = 0; index <= results.length - 1; index++) {
324-
const item = results[index];
326+
for (
327+
let index = 0;
328+
index <= resolvedDeclarations.length - 1;
329+
index++
330+
) {
331+
const item = resolvedDeclarations[index];
325332

326333
if (!item) {
327334
// eslint-disable-next-line no-continue

0 commit comments

Comments
 (0)