Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 67ca776

Browse files
chore(deps): update
1 parent c0eecec commit 67ca776

File tree

10 files changed

+6093
-3266
lines changed

10 files changed

+6093
-3266
lines changed

.github/workflows/nodejs.yml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: val-loader
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
- next
8+
pull_request:
9+
branches:
10+
- master
11+
- next
12+
13+
jobs:
14+
lint:
15+
name: Lint - ${{ matrix.os }} - Node v${{ matrix.node-version }}
16+
17+
env:
18+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
20+
strategy:
21+
matrix:
22+
os: [ubuntu-latest]
23+
node-version: [12.x]
24+
25+
runs-on: ${{ matrix.os }}
26+
27+
steps:
28+
- uses: actions/checkout@v2
29+
with:
30+
fetch-depth: 0
31+
32+
- name: Use Node.js ${{ env.node-version }}
33+
uses: actions/setup-node@v1
34+
with:
35+
node-version: ${{ env.node-version }}
36+
37+
- name: Use latest NPM
38+
run: sudo npm i -g npm
39+
40+
- name: Install dependencies
41+
run: npm ci
42+
43+
- name: Lint
44+
run: npm run lint
45+
46+
- name: Security audit
47+
run: npm run security
48+
49+
- name: Check commit message
50+
uses: wagoid/commitlint-github-action@v1
51+
52+
test:
53+
name: Test - ${{ matrix.os }} - Node v${{ matrix.node-version }}, Webpack ${{ matrix.webpack-version }}
54+
55+
strategy:
56+
matrix:
57+
os: [ubuntu-latest, windows-latest, macos-latest]
58+
node-version: [10.x, 12.x, 13.x]
59+
webpack-version: [latest, next]
60+
61+
runs-on: ${{ matrix.os }}
62+
63+
steps:
64+
- uses: actions/checkout@v2
65+
66+
- name: Use Node.js ${{ matrix.node-version }}
67+
uses: actions/setup-node@v1
68+
with:
69+
node-version: ${{ matrix.node-version }}
70+
71+
- name: Use latest NPM on ubuntu/macos
72+
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
73+
run: sudo npm i -g npm
74+
75+
- name: Use latest NPM on windows
76+
if: matrix.os == 'windows-latest'
77+
run: npm i -g npm
78+
79+
- name: Install dependencies
80+
run: npm ci
81+
82+
- name: Install webpack ${{ matrix.webpack-version }}
83+
run: npm i webpack@${{ matrix.webpack-version }}
84+
85+
- name: Run tests for webpack version ${{ matrix.webpack-version }}
86+
run: npm run test:coverage -- --ci
87+
88+
- name: Submit coverage data to codecov
89+
uses: codecov/codecov-action@v1
90+
with:
91+
token: ${{ secrets.CODECOV_TOKEN }}

.prettierrc.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
module.exports = {
2-
singleQuote: true,
3-
trailingComma: 'es5',
4-
arrowParens: 'always',
5-
};
1+
module.exports = { singleQuote: true };

README.md

Lines changed: 75 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,12 @@ corresponds to the `years` parameter in the target module exported function:
143143
```js
144144
module.exports = function yearsInMs({ years }) {
145145
const value = years * 365 * 24 * 60 * 60 * 1000;
146+
146147
// NOTE: this return value will replace the module in the bundle
147-
return { code: 'module.exports = ' + value };
148+
return {
149+
cacheable: true,
150+
code: 'module.exports = ' + value,
151+
};
148152
};
149153
```
150154

@@ -173,22 +177,81 @@ module.exports = {
173177
In the bundle, requiring the module then returns:
174178

175179
```js
176-
// ... bundle code ...
180+
import tenYearsMs from 'years-in-ms';
177181

178-
const tenYearsMs = require('years-in-ms'); // 315360000000
182+
console.log(tenYearsMs); // 315360000000
179183
```
180184

185+
### Modernizr
186+
187+
Example shows how to build [`modernizr`](https://www.npmjs.com/package/modernizr).
188+
189+
**entry.js**
190+
181191
```js
182-
// ... bundle code ...
192+
import modenizr from './modernizr.js';
193+
```
183194

184-
require('val-loader!tenyearsinms') == 315360000000;
195+
**modernizr.js**
196+
197+
```js
198+
const modernizr = require('modernizr');
199+
200+
module.exports = function (options) {
201+
return new Promise(function (resolve) {
202+
// It is impossible to throw an error because modernizr causes the process.exit(1)
203+
modernizr.build(options, function (output) {
204+
resolve({
205+
cacheable: true,
206+
code: `var modernizr; var hadGlobal = 'Modernizr' in window; var oldGlobal = window.Modernizr; ${output} modernizr = window.Modernizr; if (hadGlobal) { window.Modernizr = oldGlobal; } else { delete window.Modernizr; } export default modernizr;`,
207+
});
208+
});
209+
});
210+
};
211+
```
212+
213+
**webpack.config.js**
214+
215+
```js
216+
const path = require('path');
217+
module.exports = {
218+
module: {
219+
rules: [
220+
{
221+
test: path.resolve(__dirname, 'src', 'modernizr.js'),
222+
use: [
223+
{
224+
loader: 'val-loader',
225+
options: {
226+
minify: false,
227+
options: ['setClasses'],
228+
'feature-detects': [
229+
'test/css/flexbox',
230+
'test/es6/promises',
231+
'test/serviceworker',
232+
],
233+
},
234+
},
235+
],
236+
},
237+
],
238+
},
239+
};
185240
```
186241

187242
### Figlet
188243

189-
Example shows how to build [`figlet`](https://www.npmjs.com/package/figlet)
244+
Example shows how to build [`figlet`](https://www.npmjs.com/package/figlet).
245+
246+
**entry.js**
247+
248+
```js
249+
import { default as figlet } from './figlet.js';
190250

191-
**src/figlet.js**
251+
console.log(figlet);
252+
```
253+
254+
**figlet.js**
192255

193256
```js
194257
const figlet = require('figlet');
@@ -211,7 +274,7 @@ function wrapOutput(output, config) {
211274
return `module.exports = decodeURI("${figletOutput}");`;
212275
}
213276

214-
module.exports = function(options) {
277+
module.exports = function (options) {
215278
const defaultConfig = {
216279
fontOptions: {
217280
font: 'ANSI Shadow',
@@ -226,13 +289,14 @@ module.exports = function(options) {
226289

227290
const config = Object.assign({}, defaultConfig, options);
228291

229-
return new Promise(function(resolve, reject) {
292+
return new Promise(function (resolve, reject) {
230293
figlet.text(config.text, config.fontOptions, (error, output) => {
231294
if (error) {
232295
return reject(error);
233296
}
234297

235298
resolve({
299+
cacheable: true,
236300
code: 'module.exports = ' + wrapOutput(output, config),
237301
});
238302
});
@@ -263,70 +327,6 @@ module.exports = {
263327
};
264328
```
265329

266-
**src/entry.js**
267-
268-
```js
269-
import { default as figlet } from './figlet.js';
270-
console.log(figlet);
271-
```
272-
273-
### Modernizr
274-
275-
Example shows how to build [`modernizr`](https://www.npmjs.com/package/modernizr)
276-
277-
**src/modernizr.js**
278-
279-
```js
280-
const modernizr = require('modernizr');
281-
282-
module.exports = function(options) {
283-
return new Promise(function(resolve) {
284-
// It is impossible to throw an error because modernizr causes the process.exit(1)
285-
modernizr.build(options, function(output) {
286-
resolve({
287-
cacheable: true,
288-
code: `var modernizr; var hadGlobal = 'Modernizr' in window; var oldGlobal = window.Modernizr; ${output} modernizr = window.Modernizr; if (hadGlobal) { window.Modernizr = oldGlobal; } else { delete window.Modernizr; } export default modernizr;`,
289-
});
290-
});
291-
});
292-
};
293-
```
294-
295-
**webpack.config.js**
296-
297-
```js
298-
const path = require('path');
299-
module.exports = {
300-
module: {
301-
rules: [
302-
{
303-
test: path.resolve(__dirname, 'src', 'modernizr.js'),
304-
use: [
305-
{
306-
loader: 'val-loader',
307-
options: {
308-
minify: false,
309-
options: ['setClasses'],
310-
'feature-detects': [
311-
'test/css/flexbox',
312-
'test/es6/promises',
313-
'test/serviceworker',
314-
],
315-
},
316-
},
317-
],
318-
},
319-
],
320-
},
321-
};
322-
```
323-
324-
**src/entry.js**
325-
326-
```js
327-
import modenizr from './modernizr.js';
328-
```
329-
330330
## Contributing
331331

332332
Please take a moment to read our contributing guidelines if you haven't yet done so.
@@ -343,8 +343,8 @@ Please take a moment to read our contributing guidelines if you haven't yet done
343343
[node-url]: https://nodejs.org
344344
[deps]: https://david-dm.org/webpack-contrib/val-loader.svg
345345
[deps-url]: https://david-dm.org/webpack-contrib/val-loader
346-
[tests]: https://dev.azure.com/webpack-contrib/val-loader/_apis/build/status/webpack-contrib.val-loader?branchName=master
347-
[tests-url]: https://dev.azure.com/webpack-contrib/val-loader/_build/latest?definitionId=2&branchName=master
346+
[tests]: https://github.com/webpack-contrib/val-loader/workflows/val-loader/badge.svg
347+
[tests-url]: https://github.com/webpack-contrib/val-loader/actions
348348
[cover]: https://codecov.io/gh/webpack-contrib/val-loader/branch/master/graph/badge.svg
349349
[cover-url]: https://codecov.io/gh/webpack-contrib/val-loader
350350
[chat]: https://img.shields.io/badge/gitter-webpack%2Fwebpack-brightgreen.svg

0 commit comments

Comments
 (0)