Skip to content

Commit

Permalink
refactor: next
Browse files Browse the repository at this point in the history
BREAKING CHANGE: minimum supported webpack version is `5`
  • Loading branch information
alexander-akait committed Dec 22, 2020
1 parent c944973 commit a6c7825
Show file tree
Hide file tree
Showing 24 changed files with 2,270 additions and 3,158 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
root: true,
extends: ['@webpack-contrib/eslint-config-webpack', 'prettier'],
extends: ["@webpack-contrib/eslint-config-webpack", "prettier"],
};
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [10.x, 12.x, 13.x]
webpack-version: [4, latest]
webpack-version: [latest]

runs-on: ${{ matrix.os }}

Expand Down
1 change: 0 additions & 1 deletion .prettierrc.js

This file was deleted.

60 changes: 30 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Then add the loader to your `webpack` config. For example:

```js
module.exports = (options, loaderContext) => {
return { code: 'module.exports = 42;' };
return { code: "module.exports = 42;" };
};
```

Expand All @@ -66,7 +66,7 @@ module.exports = {
**src/entry.js**

```js
const answer = require('target-file');
const answer = require("target-file");
```

And run `webpack` via your preferred method.
Expand Down Expand Up @@ -147,7 +147,7 @@ module.exports = function yearsInMs({ years }) {
// NOTE: this return value will replace the module in the bundle
return {
cacheable: true,
code: 'module.exports = ' + value,
code: "module.exports = " + value,
};
};
```
Expand All @@ -159,10 +159,10 @@ module.exports = {
module: {
rules: [
{
test: require.resolve('src/years-in-ms.js'),
test: require.resolve("src/years-in-ms.js"),
use: [
{
loader: 'val-loader',
loader: "val-loader",
options: {
years: 10,
},
Expand All @@ -177,7 +177,7 @@ module.exports = {
In the bundle, requiring the module then returns:

```js
import tenYearsMs from 'years-in-ms';
import tenYearsMs from "years-in-ms";

console.log(tenYearsMs); // 315360000000
```
Expand All @@ -189,13 +189,13 @@ Example shows how to build [`modernizr`](https://www.npmjs.com/package/modernizr
**entry.js**

```js
import modenizr from './modernizr.js';
import modenizr from "./modernizr.js";
```

**modernizr.js**

```js
const modernizr = require('modernizr');
const modernizr = require("modernizr");

module.exports = function (options) {
return new Promise(function (resolve) {
Expand All @@ -213,22 +213,22 @@ module.exports = function (options) {
**webpack.config.js**

```js
const path = require('path');
const path = require("path");
module.exports = {
module: {
rules: [
{
test: path.resolve(__dirname, 'src', 'modernizr.js'),
test: path.resolve(__dirname, "src", "modernizr.js"),
use: [
{
loader: 'val-loader',
loader: "val-loader",
options: {
minify: false,
options: ['setClasses'],
'feature-detects': [
'test/css/flexbox',
'test/es6/promises',
'test/serviceworker',
options: ["setClasses"],
"feature-detects": [
"test/css/flexbox",
"test/es6/promises",
"test/serviceworker",
],
},
},
Expand All @@ -246,24 +246,24 @@ Example shows how to build [`figlet`](https://www.npmjs.com/package/figlet).
**entry.js**

```js
import { default as figlet } from './figlet.js';
import { default as figlet } from "./figlet.js";

console.log(figlet);
```

**figlet.js**

```js
const figlet = require('figlet');
const figlet = require("figlet");

function wrapOutput(output, config) {
let figletOutput = '';
let figletOutput = "";

if (config.textBefore) {
figletOutput += encodeURI(`${config.textBefore}\n`);
}

output.split('\n').forEach((line) => {
output.split("\n").forEach((line) => {
figletOutput += encodeURI(`${line}\n`);
});

Expand All @@ -277,12 +277,12 @@ function wrapOutput(output, config) {
module.exports = function (options) {
const defaultConfig = {
fontOptions: {
font: 'ANSI Shadow',
horizontalLayout: 'default',
kerning: 'default',
verticalLayout: 'default',
font: "ANSI Shadow",
horizontalLayout: "default",
kerning: "default",
verticalLayout: "default",
},
text: 'FIGLET-LOADER',
text: "FIGLET-LOADER",
textAfter: null,
textBefore: null,
};
Expand All @@ -297,7 +297,7 @@ module.exports = function (options) {

resolve({
cacheable: true,
code: 'module.exports = ' + wrapOutput(output, config),
code: "module.exports = " + wrapOutput(output, config),
});
});
});
Expand All @@ -307,17 +307,17 @@ module.exports = function (options) {
**webpack.config.js**

```js
const path = require('path');
const path = require("path");
module.exports = {
module: {
rules: [
{
test: path.resolve(__dirname, 'src', 'figlet.js'),
test: path.resolve(__dirname, "src", "figlet.js"),
use: [
{
loader: 'val-loader',
loader: "val-loader",
options: {
text: 'FIGLET',
text: "FIGLET",
},
},
],
Expand Down
4 changes: 2 additions & 2 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ module.exports = (api) => {
return {
presets: [
[
'@babel/preset-env',
"@babel/preset-env",
{
targets: {
node: '10.13.0',
node: "10.13.0",
},
},
],
Expand Down
2 changes: 1 addition & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
extends: ['@commitlint/config-conventional'],
extends: ["@commitlint/config-conventional"],
};
4 changes: 2 additions & 2 deletions husky.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
hooks: {
'pre-commit': 'lint-staged',
'commit-msg': 'commitlint -E HUSKY_GIT_PARAMS',
"pre-commit": "lint-staged",
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
},
};
4 changes: 2 additions & 2 deletions lint-staged.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = {
'*.js': ['prettier --write', 'eslint --fix'],
'*.{json,md,yml,css,ts}': ['prettier --write'],
"*.js": ["eslint --fix", "prettier --write"],
"*.{json,md,yml,css,ts}": ["prettier --write"],
};
Loading

0 comments on commit a6c7825

Please sign in to comment.