Skip to content

Commit 23308e1

Browse files
committed
fix: Remove some lingering traces of the async factory.
1 parent f3b11af commit 23308e1

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

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

+14-19
Original file line numberDiff line numberDiff line change
@@ -61,43 +61,39 @@ export class BlockFactorySync extends BlockFactoryBase {
6161
}
6262

6363
/**
64-
* Parse a `postcss.Root` into a Block object. Save the Block promise and
65-
* return it. Use parseRoot if we need to catch errors.
64+
* Parse a `postcss.Root` into a Block object. Use parseRoot if we need to
65+
* catch errors.
6666
*
6767
* This function is referenced only in tests.
6868
* @param root The postcss.Root to parse.
6969
* @param identifier A unique identifier for this Block file.
7070
* @param name Default name for the block.
7171
* @param isDfnFile Whether to treat this as a definition file.
72-
* @returns The Block object promise.
72+
* @returns The Block object.
7373
*/
7474
parseRootFaultTolerant(root: postcss.Root, identifier: string, name: string, isDfnFile = false, expectedGuid?: string): Block {
7575
return this.parser.parseSync(root, identifier, name, isDfnFile, expectedGuid);
7676
}
7777

7878
/**
79-
* Parse a `postcss.Root` into a Block object. Save the Block promise and return it.
80-
* Also assert that the block is valid so that we can catch any errors that
81-
* the block contains.
79+
* Parse a `postcss.Root` into a Block object. Also assert that the block is
80+
* valid so that we can catch any errors that the block contains.
8281
*
8382
* This function is only used in tests
8483
* @param root The postcss.Root to parse.
8584
* @param identifier A unique identifier for this Block file.
8685
* @param name Default name for the block.
8786
* @param isDfnFile Whether to treat this as a definition file.
88-
* @returns The Block object promise.
87+
* @returns The Block object.
8988
*/
90-
async parseRoot(root: postcss.Root, identifier: string, name: string, isDfnFile = false, expectedGuid?: string): Promise<Block> {
91-
const block = await this.parseRootFaultTolerant(root, identifier, name, isDfnFile, expectedGuid);
89+
parseRoot(root: postcss.Root, identifier: string, name: string, isDfnFile = false, expectedGuid?: string): Block {
90+
const block = this.parseRootFaultTolerant(root, identifier, name, isDfnFile, expectedGuid);
9291
return this._surfaceBlockErrors(block);
9392
}
9493

9594
/**
96-
* In some cases (like when using preprocessors with native bindings), it may
97-
* be necessary to wait until the block factory has completed current
98-
* asynchronous work before exiting. Calling this method stops new pending
99-
* work from being performed and returns a promise that resolves when it is
100-
* safe to exit.
95+
* This method doesn't do anything, but it's provided for parity with
96+
* `BlockFactory`.
10197
*/
10298
prepareForExit(): void {
10399
}
@@ -125,13 +121,12 @@ export class BlockFactorySync extends BlockFactoryBase {
125121
* into a CSS Block. In most cases, you'll likely want to use getBlockFromPath() instead.
126122
*
127123
* If the block for the given identifier has already been loaded and parsed,
128-
* the cached data will be returned instead. If loading and parsing is already in progress,
129-
* the existing promise for that identifier will be returned.
124+
* the cached block will be returned instead.
130125
*
131126
* @param identifier - An identifier that points at a data file or blob in persistent storage.
132127
* These identifiers are created by the Importer that you've configured
133128
* to use.
134-
* @returns A promise that resolves to the parsed block.
129+
* @returns The parsed block.
135130
*/
136131
getBlock(identifier: FileIdentifier): Block {
137132
if (this.blocks[identifier]) {
@@ -145,7 +140,7 @@ export class BlockFactorySync extends BlockFactoryBase {
145140
* the Importer, then defer to another method to actually parse the data file into a Block.
146141
*
147142
* @param identifier - An identifier that points at a data file or blob in persistent storage.
148-
* @returns A promise that resolves to the parsed block.
143+
* @returns The parsed block.
149144
*/
150145
private _getBlock(identifier: FileIdentifier): Block {
151146
let file = this.importer.importSync(identifier, this.configuration);
@@ -288,7 +283,7 @@ export class BlockFactorySync extends BlockFactoryBase {
288283
* @param fromIdentifier - The FileIdentifier that references the base location that the
289284
* import path is relative to.
290285
* @param importPath - The relative import path for the file to import.
291-
* @returns A promise that resolves to a parsed block.
286+
* @returns The parsed block.
292287
*/
293288
getBlockRelative(fromIdentifier: FileIdentifier, importPath: string): Block {
294289
let importer = this.importer;

0 commit comments

Comments
 (0)