Skip to content

Commit adb7d68

Browse files
committed
fix: Silence postcss warning message.
1 parent 272556d commit adb7d68

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

packages/@css-blocks/core/src/BlockParser/BlockFactory.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -145,25 +145,25 @@ export class BlockFactory {
145145
})
146146

147147
// Run through PostCSS.
148-
.then(async (preprocessResult): Promise<[ProcessedFile, postcss.Result]> => {
148+
.then(async (preprocessResult): Promise<[ProcessedFile, postcss.Root]> => {
149149
debug(`Generating PostCSS AST for "${filename}"`);
150150
let sourceMap = sourceMapFromProcessedFile(preprocessResult);
151151
let content = preprocessResult.content;
152152
if (sourceMap) {
153153
content = annotateCssContentWithSourceMap(content, sourceMap);
154154
}
155-
let result = await this.postcssImpl().process(content, { from: filename });
156-
return [preprocessResult, result];
155+
let root = await this.postcssImpl.parse(content, { from: filename });
156+
return [preprocessResult, root];
157157
})
158158

159-
.then(([preprocessedResult, result]) => {
159+
.then(([preprocessedResult, root]) => {
160160
debug(`Parsing Block object for "${filename}"`);
161161
// Skip parsing if we can.
162162
if (this.blocks[file.identifier]) { return this.blocks[file.identifier]; }
163163
let source: ParsedSource = {
164164
identifier: file.identifier,
165165
defaultName: file.defaultName,
166-
parseResult: result,
166+
parseResult: root,
167167
originalSource: file.contents,
168168
originalSyntax: file.syntax,
169169
dependencies: preprocessedResult.dependencies || [],

packages/@css-blocks/core/src/BlockParser/BlockParser.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { postcss } from "opticss";
33

44
import { Block } from "../BlockTree";
55
import { Options, ResolvedConfiguration, resolveConfiguration } from "../configuration";
6-
import * as errors from "../errors";
76
import { FileIdentifier } from "../importing";
87

98
import { assertForeignGlobalAttribute } from "./features/assert-foreign-global-attribute";
@@ -27,7 +26,7 @@ export interface ParsedSource {
2726
defaultName: string;
2827
originalSource: string;
2928
originalSyntax: Syntax;
30-
parseResult: postcss.Result;
29+
parseResult: postcss.Root;
3130
dependencies: string[];
3231
}
3332

@@ -45,10 +44,7 @@ export class BlockParser {
4544
}
4645

4746
public parseSource(source: ParsedSource): Promise<Block> {
48-
let root = source.parseResult.root;
49-
50-
// This should never happen but it makes the typechecker happy.
51-
if (!root) { throw new errors.CssBlockError("No postcss root found."); }
47+
let root = source.parseResult;
5248

5349
return this.parse(root, source.identifier, source.defaultName).then(block => {
5450
source.dependencies.forEach(block.addDependency);

0 commit comments

Comments
 (0)