Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Commit

Permalink
fix: bundling with Angular CLI and Webpack (#159)
Browse files Browse the repository at this point in the history
`postcss-media-query-parser` is a CommonJS (CJS) module, and its default export differs from the ECMAScript Module (ESM) format. This variance causes `critters` to encounter issues when bundled with webpack.

Co-authored-by: Janicklas Ralph <[email protected]>
  • Loading branch information
alan-agius4 and janicklas-ralph authored Mar 4, 2024
1 parent 01eeab4 commit 03ca6b5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/critters/src/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ function validateMediaType(node) {
* is HTML safe and does not cause any injection issue
*/
export function validateMediaQuery(query) {
const mediaTree = mediaParser(query);
// The below is needed for consumption with webpack.
const mediaParserFn = 'default' in mediaParser ? mediaParser.default : mediaParser;
const mediaTree = mediaParserFn(query);
const nodeTypes = new Set(['media-type', 'keyword', 'media-feature']);

const stack = [mediaTree];
Expand Down

0 comments on commit 03ca6b5

Please sign in to comment.