Skip to content
This repository was archived by the owner on Dec 22, 2020. It is now read-only.

Commit ff841bd

Browse files
chore: update
BREAKING CHANGE: minimum required nodejs version is `10.13.0`
1 parent 4fff4c3 commit ff841bd

34 files changed

+6590
-3578
lines changed

.editorconfig

-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,4 @@ insert_final_newline = true
99
trim_trailing_whitespace = true
1010

1111
[*.md]
12-
insert_final_newline = true
1312
trim_trailing_whitespace = false

.github/CONTRIBUTING.md

+8
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,14 @@ module. Thankfully, Github provides a means to do this. Add a dependency to the
147147

148148
Where `{id}` is the # ID of your Pull Request.
149149

150+
## Contributor License Agreement
151+
152+
When submitting your contribution, a CLA (Contributor License Agreement) bot will come by to verify that you signed the [CLA](https://cla.js.foundation/webpack-contrib/json5-loader).
153+
If it is your first time, it will link you to the right place to sign it.
154+
However, if you have committed your contributions using an email that is not the same as your email used on GitHub, the CLA bot can't accept your contribution.
155+
156+
Run `git config user.email` to see your Git email, and verify it with [your GitHub email](https://github.com/settings/emails).
157+
150158
## Thanks
151159

152160
For your interest, time, understanding, and for following this simple guide.

.github/workflows/nodejs.yml

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: json5-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

+1-5
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

+50-22
Original file line numberDiff line numberDiff line change
@@ -37,51 +37,79 @@ Suppose we have the following `json5` file:
3737
**file.json5**
3838

3939
```json5
40-
// file.json5
4140
{
4241
env: 'production',
4342
passwordStrength: 'strong',
4443
}
4544
```
4645

47-
### Usage with preconfigured rule
48-
4946
**webpack.config.js**
5047

5148
```js
52-
// webpack.config.js
5349
module.exports = {
54-
entry: './index.js',
55-
output: {
56-
/* ... */
57-
},
5850
module: {
5951
rules: [
6052
{
61-
// make all files ending in .json5 use the `json5-loader`
62-
test: /\.json5$/,
63-
use: 'json5-loader',
64-
type: 'javascript/auto'
53+
test: /\.json5$/i,
54+
loader: 'json5-loader',
55+
type: 'javascript/auto',
6556
},
6657
],
6758
},
6859
};
6960
```
7061

71-
```js
72-
// index.js
73-
var appConfig = require('./appData.json5');
74-
// or, in ES6
75-
// import appConfig from './appData.json5'
62+
## Options
7663

77-
console.log(appConfig.env); // 'production'
64+
| Name | Type | Default | Description |
65+
| :-------------------------: | :---------: | :-----: | :--------------------- |
66+
| **[`esModule`](#esmodule)** | `{Boolean}` | `true` | Uses ES modules syntax |
67+
68+
### `esModule`
69+
70+
Type: `Boolean`
71+
Default: `true`
72+
73+
There are some cases in which using ES modules is beneficial, like in the case of [module concatenation](https://webpack.js.org/plugins/module-concatenation-plugin/) and [tree shaking](https://webpack.js.org/guides/tree-shaking/).
74+
75+
You can enable a ES module syntax using:
76+
77+
**webpack.config.js**
78+
79+
```js
80+
module.exports = {
81+
module: {
82+
rules: [
83+
{
84+
test: /\.json5$/i,
85+
loader: 'json5-loader',
86+
options: {
87+
esModule: false,
88+
},
89+
type: 'javascript/auto',
90+
},
91+
],
92+
},
93+
};
7894
```
7995

96+
## Examples
97+
8098
### Usage with require statement loader prefix
8199

100+
**file.json5**
101+
102+
```json5
103+
{
104+
env: 'production',
105+
passwordStrength: 'strong',
106+
}
107+
```
108+
109+
**index.js**
110+
82111
```js
83-
var appConfig = require('json5-loader!./appData.json5');
84-
// returns the content as json parsed object
112+
import appConfig from 'json5-loader!./file.json5';
85113

86114
console.log(appConfig.env); // 'production'
87115
```
@@ -104,8 +132,8 @@ Please take a moment to read our contributing guidelines if you haven't yet done
104132
[node-url]: https://nodejs.org
105133
[deps]: https://david-dm.org/webpack-contrib/json5-loader.svg
106134
[deps-url]: https://david-dm.org/webpack-contrib/json5-loader
107-
[tests]: https://dev.azure.com/webpack-contrib/json5-loader/_apis/build/status/webpack-contrib.json5-loader?branchName=master
108-
[tests-url]: https://dev.azure.com/webpack-contrib/json5-loader/_build/latest?definitionId=2&branchName=master
135+
[tests]: https://github.com/webpack-contrib/json5-loader/workflows/json5-loader/badge.svg
136+
[tests-url]: https://github.com/webpack-contrib/json5-loader/actions
109137
[cover]: https://codecov.io/gh/webpack-contrib/json5-loader/branch/master/graph/badge.svg
110138
[cover-url]: https://codecov.io/gh/webpack-contrib/json5-loader
111139
[chat]: https://img.shields.io/badge/gitter-webpack%2Fwebpack-brightgreen.svg

0 commit comments

Comments
 (0)