Skip to content

Commit 062085a

Browse files
committed
Update deps and fix tests
1 parent 4899613 commit 062085a

File tree

10 files changed

+6984
-3390
lines changed

10 files changed

+6984
-3390
lines changed

.babelrc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
{
22
"presets": [
3-
"latest",
4-
"stage-0"
3+
[
4+
"@babel/preset-env",
5+
{
6+
"targets": {
7+
"esmodules": true,
8+
"node": "current"
9+
}
10+
}
11+
]
512
],
6-
"plugins": [
7-
"transform-runtime",
8-
"add-module-exports"
9-
]
13+
"plugins": []
1014
}

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
language: node_js
22
node_js:
3-
- "8"
4-
- "6"
3+
- "12"
4+
- "13"
55
cache: npm
66
install:
77
- npm install

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@
1313
<img src="https://img.shields.io/github/issues/Coobaha/postcss-variables-loader.svg" alt="Github Issues">
1414
</a>
1515

16-
16+
1717
<a href="https://travis-ci.org/Coobaha/postcss-variables-loader">
1818
<img src="https://img.shields.io/travis/Coobaha/postcss-variables-loader.svg" alt="Travis Status">
1919
</a>
20-
2120

22-
21+
22+
2323
<a href="https://coveralls.io/github/Coobaha/postcss-variables-loader">
2424
<img src="https://img.shields.io/coveralls/Coobaha/postcss-variables-loader.svg" alt="Coveralls">
2525
</a>
26-
27-
26+
27+
2828
</p>
2929

3030
<p align="center"><big>
@@ -105,27 +105,27 @@ npm install --save-dev postcss-variables-loader
105105
and imports inside css (eg via [postcss-import](https://github.com/postcss/postcss-import))
106106

107107

108-
**Recommended webpack configuration**:
108+
**Recommended webpack configuration**:
109109
`webpack.config.js` with babel-loader
110110
```
111-
loaders: [
111+
rules: [
112112
{
113113
test: /\.config.css$/,
114114
loader: 'babel-loader!postcss-variables-loader'
115115
},
116-
116+
117117
// dont forget to exclude *.config.css from other css loaders
118118
{
119119
test: /\.css$/,
120-
exclude: /\.config.css$/,
120+
exclude: /\.config.css$/,
121121
loader: 'css-loader!postcss-loader'
122122
}
123123
]
124124
```
125125

126126
## Options
127127

128-
if `production.env.NODE_ENV === 'development'` it will try to wrap config inside `Proxy` in runtime.
128+
if `production.env.NODE_ENV === 'development'` it will try to wrap config inside `Proxy` in runtime.
129129
It is used to guard from accidental mutations or accessing missing keys.
130130
If you dont want this behaviour: pass `es5=1`:
131131

lib/index.js

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,32 @@
1-
'use strict';
1+
"use strict";
22

33
Object.defineProperty(exports, "__esModule", {
44
value: true
55
});
6+
exports.default = PostcssVariablesLoader;
67

7-
exports.default = function (source) {
8-
var _this = this;
8+
var _loaderUtils = _interopRequireDefault(require("loader-utils"));
99

10+
var utils = _interopRequireWildcard(require("./utils"));
11+
12+
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
13+
14+
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15+
16+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17+
18+
function PostcssVariablesLoader(source) {
1019
if (this.cacheable) {
1120
this.cacheable();
1221
}
1322

14-
var options = _loaderUtils2.default.parseQuery(this.query);
23+
var options = _loaderUtils.default.getOptions(this) || {};
24+
1525
var _done = this.async();
1626

1727
var transformToConfig = options.es5 ? utils.toES5Config : utils.toConfig;
1828

19-
var end = function end(err, result, path, map) {
29+
var end = (err, result, path, map) => {
2030
if (err) {
2131
_done(err);
2232
}
@@ -30,37 +40,21 @@ exports.default = function (source) {
3040
return _done(null, obj, map);
3141
};
3242

33-
var emitWarnings = function emitWarnings(result) {
34-
result.warnings().forEach(function (msg) {
35-
return _this.emitWarning(new Error(msg.toString()));
36-
});
43+
var emitWarnings = result => {
44+
result.warnings().forEach(msg => this.emitWarning(new Error(msg.toString())));
3745
return result;
3846
};
3947

40-
var onError = function onError(error) {
48+
var onError = error => {
4149
if (error.name === 'CssSyntaxError') {
42-
_this.emitError(error.message + error.showSourceCode());
50+
this.emitError(error.message + error.showSourceCode());
4351
end();
4452
} else {
4553
end(error);
4654
}
4755
};
4856

49-
utils.getPostcss(true).process(source, { from: this.resourcePath }).then(function (result) {
50-
return end(null, result, _this.resourcePath, result.map);
51-
}).catch(onError);
52-
};
53-
54-
var _loaderUtils = require('loader-utils');
55-
56-
var _loaderUtils2 = _interopRequireDefault(_loaderUtils);
57-
58-
var _utils = require('./utils');
59-
60-
var utils = _interopRequireWildcard(_utils);
61-
62-
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
63-
64-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
65-
66-
module.exports = exports['default'];
57+
utils.getPostcss(true).process(source, {
58+
from: this.resourcePath
59+
}).then(result => end(null, result, this.resourcePath, result.map)).catch(onError);
60+
}

0 commit comments

Comments
 (0)