Skip to content

Commit b53a940

Browse files
author
Vladimir Kalmykov
committed
noCache
1 parent d0f0770 commit b53a940

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,10 @@ Short alias for the [postcss-modules-local-by-default](https://github.com/css-mo
268268

269269
Provides absolute path to the project directory. Providing this will result in better generated class names. It can be obligatory, if you run require hook and build tools (like [css-modulesify](https://github.com/css-modules/css-modulesify)) from different working directories.
270270

271+
### `noCache` boolean
272+
273+
Do not cache module. You may need this option if you want to watch files. But expect the performance degradation when you call require for same file multiple times.
274+
271275

272276
## Debugging
273277

src/index.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const debugSetup = require('debug')('css-modules:setup');
2323
module.exports = function setupHook({
2424
camelCase,
2525
devMode,
26-
disableCache,
26+
noCache,
2727
extensions = '.css',
2828
ignore,
2929
preprocessCss = identity,
@@ -38,6 +38,7 @@ module.exports = function setupHook({
3838
use,
3939
rootDir: context = process.cwd(),
4040
}) {
41+
console.log('noCache', noCache);
4142
debugSetup(arguments[0]);
4243
validate(arguments[0]);
4344

@@ -88,8 +89,8 @@ module.exports = function setupHook({
8889
: resolve(dirname(from), _to);
8990

9091
// checking cache
91-
let tokens
92-
if (!disableCache) {
92+
let tokens;
93+
if (!noCache) {
9394
tokens = tokensByFile[filename];
9495
if (tokens) {
9596
debugFetch(`${filename} → cache`);
@@ -107,11 +108,11 @@ module.exports = function setupHook({
107108

108109
tokens = lazyResult.root.exports || {};
109110

110-
if (!debugMode && !disableCache)
111+
if (!debugMode && !noCache)
111112
// updating cache
112113
tokensByFile[filename] = tokens;
113114
else
114-
// clearing cache in development mode or with disableCache option
115+
// clearing cache in development mode or with noCache option
115116
delete require.cache[filename];
116117

117118
if (processCss)

src/validate.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const rules = {
3030
hashPrefix: 'string',
3131
mode: 'string',
3232
rootDir: 'string',
33+
noCache: 'boolean',
3334
};
3435

3536
const tests = {

0 commit comments

Comments
 (0)