Skip to content

Commit f15642b

Browse files
authored
postcss-bundler : fix parser (#1137)
1 parent ca5f3c6 commit f15642b

File tree

8 files changed

+18
-3
lines changed

8 files changed

+18
-3
lines changed

plugin-packs/postcss-bundler/.tape.mjs

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ const testCases = {
1919
message: "throws on files that don't exist",
2020
exception: /Failed to find 'imports\/does-not-exist.css'/,
2121
},
22+
'ignore': {
23+
message: "ignores incorrect syntax",
24+
warnings: 2,
25+
},
2226
'examples/example': {
2327
message: 'minimal example',
2428
},

plugin-packs/postcss-bundler/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changes to PostCSS Bundler
22

3+
### Unreleased (patch)
4+
5+
- Ignore `@import` statements where `supports` or `layer` conditions precede the `url` value.
6+
37
### 1.0.4
48

59
_September 24, 2023_

plugin-packs/postcss-bundler/dist/index.cjs

+1-1
Large diffs are not rendered by default.

plugin-packs/postcss-bundler/dist/index.mjs

+1-1
Large diffs are not rendered by default.

plugin-packs/postcss-bundler/src/postcss-import/lib/apply-conditions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export function applyConditions(bundle: Array<Statement>, atRule: (defaults?: At
1919
stmt.conditions[0].media,
2020
stmt.conditions[0].supports,
2121
)}`;
22-
} else if (stmt.conditions.length > 1) {
22+
} else {
2323
const reverseConditions = stmt.conditions.slice().reverse();
2424
const first = reverseConditions.pop()!;
2525
let params = `${stmt.fullUri} ${formatImportPrelude(

plugin-packs/postcss-bundler/src/postcss-import/lib/parse-at-import.ts

+4
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ export function parseAtImport(params: string) {
6363
}
6464
}
6565

66+
if (!uri) {
67+
return false;
68+
}
69+
6670
if (
6771
isTokenNode(componentValue) &&
6872
componentValue.value[0] === TokenType.Ident &&
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@import layer(foo) "imports/basic.css";
2+
@import supports(foo) "imports/basic.css";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

0 commit comments

Comments
 (0)