Skip to content

Commit ed51d58

Browse files
author
davidmarkclements
committed
doc sync api
1 parent 6ed9951 commit ed51d58

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

README.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
44
[![Build Status](https://travis-ci.org/css-modules/css-modules-loader-core.svg?branch=master)](https://travis-ci.org/css-modules/css-modules-loader-core)
55

6-
## API
6+
## Async API
7+
8+
The async API is default, simply load `css-modules-loader-core`
79

810
```js
911
import Core from 'css-modules-loader-core'
@@ -12,13 +14,33 @@ let core = new Core()
1214

1315
### core.load( sourceString , sourcePath , pathFetcher ) =><br>&nbsp;&nbsp;Promise({ injectableSource, exportTokens })
1416

15-
Processes the input CSS `sourceString`, looking for dependencies such as `@import` or `:import`. Any localisation will happen by prefixing a sanitised version of `sourcePath` When dependencies are found, it will ask the `pathFetcher` for each dependency, resolve & inline any imports, and return the following object:
17+
Processes the input CSS `sourceString`, looking for dependencies such as `@import` or `:import`. Any localisation will happen by prefixing a sanitised version of `sourcePath` When dependencies are found, it will ask the `pathFetcher` for each dependency, asynchronously resolve & inline any imports, and return the following object:
18+
19+
- `injectableSource`: the final, merged CSS file without `@import` or `:import` statements
20+
- `exportTokens`: the mapping from local name to scoped name, as described in the file's `:export` block
21+
22+
These should map nicely to what your build-tool-specific loader needs to do its job.
23+
24+
25+
## Sync API
26+
27+
The sync API is available at `css-modules-loader-core/sync`
28+
29+
```js
30+
import Core from 'css-modules-loader-core/sync'
31+
let core = new Core()
32+
```
33+
34+
### core.load( sourceString , sourcePath , pathFetcher ) =><br>&nbsp;&nbsp;{ injectableSource, exportTokens }
35+
36+
Processes the input CSS `sourceString`, looking for dependencies such as `@import` or `:import`. Any localisation will happen by prefixing a sanitised version of `sourcePath` When dependencies are found, it will ask the `pathFetcher` for each dependency, synchronously resolve & inline any imports, and return the following object:
1637

1738
- `injectableSource`: the final, merged CSS file without `@import` or `:import` statements
1839
- `exportTokens`: the mapping from local name to scoped name, as described in the file's `:export` block
1940

2041
These should map nicely to what your build-tool-specific loader needs to do its job.
2142

43+
2244
### new Core([plugins])
2345

2446
The default set of plugins is [[postcss-modules-local-by-default](https://github.com/css-modules/postcss-modules-local-by-default), [postcss-modules-extract-imports](https://github.com/css-modules/postcss-modules-extract-imports), [postcss-modules-scope](https://github.com/css-modules/postcss-modules-scope)] (i.e. the CSS Modules specification). This can override which PostCSS plugins you wish to execute, e.g.

0 commit comments

Comments
 (0)