Skip to content

Commit

Permalink
Caching issue #36
Browse files Browse the repository at this point in the history
  • Loading branch information
istarkov committed Feb 23, 2016
1 parent 271fc3b commit b1c1e4b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Take a look at this [minimal-example](https://github.com/istarkov/minimal-exampl
console.log('css-modules result:', css);
```

with the command `NODE_ENV=EXAMPLE ./node_modules/.bin/babel-node ./example.js` and you'll get the following console output:
with the command `BABEL_DISABLE_CACHE=1 NODE_ENV=EXAMPLE ./node_modules/.bin/babel-node ./example.js` and you'll get the following console output:

```javascript
css-modules result: { main: 'example__main--zYOjd', item: 'example__item--W9XoN' }
Expand Down Expand Up @@ -103,10 +103,12 @@ The plugin tests all `require` paths with [test regexps](https://github.com/ista

3. [replaces](https://github.com/istarkov/babel-plugin-webpack-loaders/blob/master/src/plugin.js#L104) the required ast with the parsed ast output

# Verbose mode in config
# Caching issues

By default Babel caches compiled files, if you need to view webpack stdout output, run commands with a
`BABEL_DISABLE_CACHE=1` prefix.
By default Babel caches compiled files, so any changes in files processed with loaders will not be visible at subsequent builds,
you need to run all commands with a `BABEL_DISABLE_CACHE=1` prefix.

(_More information: [#T1186](https://phabricator.babeljs.io/T1186), [#36](https://github.com/istarkov/babel-plugin-webpack-loaders/issues/36)_)

# Thanks to

Expand Down
28 changes: 23 additions & 5 deletions src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,21 @@ const isRelativePath = (fileAbsPath) => {
return fileAbsPath.indexOf('.') === 0;
};

const warn = memoize( // memoize to just show first warn
(message) => console.error( // eslint-disable-line
colors.yellow(message)
)
);
const warn = (() => {
const msgs = {};

return (message) => {
if (message in msgs) {
return;
}

msgs[message] = true;

console.error( // eslint-disable-line
colors.yellow(message)
);
};
})();

export default function ({ types: t }) {
return {
Expand Down Expand Up @@ -177,6 +187,14 @@ export default function ({ types: t }) {
return;
}

if (process.env.BABEL_DISABLE_CACHE !== '1') {
warn(
`babel-plugin-webpack-loader:
To avoid caching errors you need to set BABEL_DISABLE_CACHE=1 environment variable.
More information at issue #36`
);
}

const [{ value: filePath }] = args;

// to support babel builds (babel-node works fine)
Expand Down

0 comments on commit b1c1e4b

Please sign in to comment.