Skip to content

Commit

Permalink
🤗 Make it webpack 5-friendly (#1)
Browse files Browse the repository at this point in the history
* BREAKING CHANGE: upgrade to webpack 5

* chore: trying to get rid of long-accidentally committed .DS_Store

* chore: bring semantic-release back (try!)

* chore(travis): well sh*t, Travis needs exactly .travis.yml 🤷🏻‍♂️

* chore(travis): remove deprecated key sudo and specific yarn version

* docs(README): update the README so it sparks more joy ✨🧘🏻‍♀️✨
  • Loading branch information
dwiyatci authored Nov 4, 2020
1 parent 56bcd73 commit 9782a2d
Show file tree
Hide file tree
Showing 17 changed files with 4,839 additions and 3,535 deletions.
Binary file removed .DS_Store
Binary file not shown.
29 changes: 0 additions & 29 deletions .babelrc

This file was deleted.

4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore these files

**/dist
coverage
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Created by .ignore support plugin (hsz.mobi)

.DS_Store
.idea
.vscode
node_modules
coverage
demo/dist
.eslintcache
3 changes: 0 additions & 3 deletions .prettierrc

This file was deleted.

2 changes: 2 additions & 0 deletions .prettierrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
singleQuote: true
printWidth: 100
26 changes: 13 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
sudo: required
before_install: # if "install" is overridden
# Repo for Yarn
- sudo apt-key adv --fetch-keys http://dl.yarnpkg.com/debian/pubkey.gpg
- echo "deb http://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
- sudo apt-get update -qq
- sudo apt-get install -y -qq yarn=1.10.1-1
# Repo for Yarn
- sudo apt-key adv --fetch-keys http://dl.yarnpkg.com/debian/pubkey.gpg
- echo "deb http://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
- sudo apt-get update -qq
- sudo apt-get install -y -qq yarn
cache:
yarn: true
directories:
- node_modules
- node_modules
language: node_js
node_js:
- '10'
- '10'
script:
- yarn test
- yarn test:nyan
- yarn cov
- yarn test
- yarn test:nyan
- yarn cov
after_success:
- yarn cov:report
- yarn cov:report
- yarn semantic-release
branches:
except:
- /^v\d+\.\d+\.\d+$/
- /^v\d+\.\d+\.\d+$/
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004

Copyright (C) 2019 Glenn Dwiyatcita <[email protected]>
Copyright (C) 2020 Glenn Dwiyatcita <[email protected]>

Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
Expand Down
42 changes: 25 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# hodor-loader

```
_| | |_ _ _ _ _ _ _
|_ . _|| |_ ___ | | __| | | |_ | |_ ___ __| | ___ ___ _ _
|_ _|| ' \ / _ \ | | / _` | | _| | ' \ / -_) / _` | / _ \ / _ \ | '_|
|_|_| |_||_| \___/ _|_|_ \__,_| _\__| |_||_| \___| \__,_| \___/ \___/ _|_|_
_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|
"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'
_| | |_ _ _ _ _ _ _
|_ . _|| |_ ___ | | __| | | |_ | |_ ___ __| | ___ ___ _ _
|_ _|| ' \ / _ \ | | / _` | | _| | ' \ / -_) / _` | / _ \ / _ \ | '_|
|_|_| |_||_| \___/ _|_|_ \__,_| _\__| |_||_| \___| \__,_| \___/ \___/ _|_|_
_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|
"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'"`-0-0-'
```

[![travis build](https://img.shields.io/travis/dwiyatci/hodor-loader.svg)](https://travis-ci.org/dwiyatci/hodor-loader)
Expand All @@ -14,7 +15,7 @@ _|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|_|"""""|
[![downloads](https://img.shields.io/npm/dt/hodor-loader.svg)](http://npm-stat.com/charts.html?package=hodor-loader)
[![WTFPL License](https://img.shields.io/badge/license-WTFPL-red.svg)](https://raw.githubusercontent.com/dwiyatci/hodor-loader/master/LICENSE.txt)

This [webpack](https://github.com/webpack/webpack) loader allows statically replacing string literal and literal template syntax in JavaScript source code with [Hodor](http://awoiaf.westeros.org/index.php/Hodor) before it gets bundled and interpreted.
This [webpack](https://webpack.js.org) loader allows statically replacing string literal and literal template syntax in JavaScript source code with [Hodor](http://awoiaf.westeros.org/index.php/Hodor) before it gets bundled and interpreted.

Smells like an experimental manipulative Lexer, huh?!

Expand All @@ -25,23 +26,27 @@ Smells like an experimental manipulative Lexer, huh?!
> Hold the door! Holddoor! Hodor! https://youtu.be/5DoBY8M_bCg
### Why?

- HODOR IS ~~**NOT**~~ DEAD.
- [You can’t beat Tape :question:](https://medium.com/javascript-scene/why-i-use-tape-instead-of-mocha-so-should-you-6aa105d8eaf4)
- [You can’t beat Tape ⁉️](https://medium.com/javascript-scene/why-i-use-tape-instead-of-mocha-so-should-you-6aa105d8eaf4)

## Installation
```sh

```bash
npm isntall hodor-loader --save-dev
```

## Usage

[Documentation: Using loaders](https://webpack.js.org/concepts/#loaders)

## Example

Given this webpack config:

```javascript
{
...,
// ...,
module: {
rules: [
{
Expand All @@ -50,7 +55,7 @@ Given this webpack config:
}
]
},
...
// ...
}
```

Expand All @@ -61,9 +66,9 @@ console.log('hello, world');

document.querySelector('#app').textContent = 'the quick brown fox jumps over a lazy dog';

//alert("hold the door");
// alert("hold the door");

document.writeln("hold, the; door!");
document.writeln('hold, the; door!');

const x = 42;
console.log(`the answer is ${x}`);
Expand All @@ -74,22 +79,25 @@ console.log(`the answer is ${x}`);
```javascript
console.log('HODOR, HODOR');

document.querySelector('#HODOR').textContent = 'HODOR HODOR HODOR HODOR HODOR HODOR HODOR HODOR HODOR';
document.querySelector('#HODOR').textContent =
'HODOR HODOR HODOR HODOR HODOR HODOR HODOR HODOR HODOR';

//alert("hold the door");
// alert("hold the door");

document.writeln("HODOR, HODOR; HODOR!");
document.writeln('HODOR, HODOR; HODOR!');

const x = 42;
console.log(`HODOR HODOR HODOR HODOR`);
```

## Author

Glenn Dwiyatcita ([@dwiyatci](http://tiny.cc/dwiyatci))

## License

WTFPL – Do What the Fuck You Want to Public License.

See [LICENSE.txt](LICENSE.txt).
See [LICENSE.txt](LICENSE.txt).

![WTFPL](http://www.wtfpl.net/wp-content/uploads/2012/12/wtfpl-badge-1.png)
35 changes: 35 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module.exports = (api) => {
api.cache(true);

const presets = [
[
'@babel/preset-env',
{
targets: 'last 2 versions',
useBuiltIns: 'entry',
corejs: 3,
modules: false,
debug: false,
},
],
];

const plugins = [
[
'@babel/plugin-transform-runtime',
{
absoluteRuntime: false,
corejs: 3,
helpers: true,
regenerator: true,
useESModules: true,
},
],
'@babel/plugin-proposal-object-rest-spread',
];

return {
presets,
plugins,
};
};
4 changes: 2 additions & 2 deletions demo/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ console.log('hello, world');

document.querySelector('#app').textContent = 'the quick brown fox jumps over a lazy dog';

//alert("hold the door");
// alert("hold the door");

document.writeln("hold, the; door!");
document.writeln('hold, the; door!');

const x = 42;
console.log(`the answer is ${x}`);
1 change: 1 addition & 0 deletions hello-world-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/

class HelloWorldPlugin {
// eslint-disable-next-line class-methods-use-this
apply(compiler) {
compiler.hooks.done.tap('Hello World Plugin', (
stats /* stats is passed as argument when done hook is tapped. */
Expand Down
58 changes: 29 additions & 29 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@
"scripts": {
"install:clean": "yarn upgrade || yarn install",
"update": "yarn upgrade-interactive --latest",
"start": "webpack-dev-server --hot",
"build": "yarn webpack --env.production --progress",
"watch": "yarn webpack -w",
"webpack": "yarn clean && webpack",
"clean": "rimraf demo/dist",
"lint": "eslint --cache src",
"start": "webpack serve",
"build": "webpack --env production",
"watch": "webpack --watch",
"lint": "eslint --cache .",
"test:nyan": "yarn test | tnyan",
"test": "node test/loader.test.js",
"cov": "yarn cov:clean && yarn cov:generate",
Expand All @@ -40,35 +38,37 @@
"semantic-release": "semantic-release"
},
"dependencies": {
"falafel": "2.1.0",
"loader-utils": "1.2.3",
"schema-utils": "1.0.0"
"falafel": "2.2.4",
"loader-utils": "2.0.0",
"schema-utils": "3.0.0"
},
"devDependencies": {
"@babel/core": "7.2.2",
"@babel/plugin-proposal-object-rest-spread": "7.2.0",
"@babel/plugin-transform-runtime": "7.2.0",
"@babel/preset-env": "7.2.3",
"babel-loader": "8.0.5",
"@babel/core": "7.12.3",
"@babel/plugin-proposal-object-rest-spread": "7.12.1",
"@babel/plugin-transform-runtime": "7.12.1",
"@babel/preset-env": "7.12.1",
"babel-loader": "8.1.0",
"clean-webpack-plugin": "3.0.0",
"codecov.io": "0.1.6",
"commitizen": "3.0.5",
"cz-conventional-changelog": "2.1.0",
"eslint": "5.12.0",
"eslint-config-airbnb-base": "13.1.0",
"eslint-config-prettier": "3.3.0",
"eslint-plugin-import": "2.14.0",
"commitizen": "4.2.2",
"cz-conventional-changelog": "3.3.0",
"eslint": "7.12.1",
"eslint-config-airbnb-base": "14.2.0",
"eslint-config-prettier": "6.15.0",
"eslint-plugin-import": "2.22.1",
"ghooks": "2.0.4",
"html-loader": "0.5.5",
"html-webpack-plugin": "4.0.0-beta.5",
"html-loader": "1.3.2",
"html-webpack-plugin": "4.5.0",
"istanbul": "0.4.5",
"memory-fs": "0.4.1",
"rimraf": "2.6.3",
"semantic-release": "15.13.2",
"memory-fs": "0.5.0",
"prettier": "2.1.2",
"rimraf": "3.0.2",
"semantic-release": "17.2.2",
"tap-nyan": "1.1.0",
"tape": "4.9.2",
"webpack": "4.28.1",
"webpack-cli": "3.2.1",
"webpack-dev-server": "3.1.14"
"tape": "5.0.1",
"webpack": "5.4.0",
"webpack-cli": "4.1.0",
"webpack-dev-server": "3.11.0"
},
"config": {
"commitizen": {
Expand Down
14 changes: 7 additions & 7 deletions test/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

const path = require('path');
const webpack = require('webpack');
const memoryfs = require('memory-fs');
const Memoryfs = require('memory-fs');

module.exports = (fixture, options = {}) => {
const compiler = webpack({
Expand All @@ -19,14 +19,14 @@ module.exports = (fixture, options = {}) => {
{
test: /\.js$/,
use: {
loader: path.resolve(__dirname, '../')
}
}
]
}
loader: path.resolve(__dirname, '../'),
},
},
],
},
});

compiler.outputFileSystem = new memoryfs();
compiler.outputFileSystem = new Memoryfs();

return new Promise((resolve, reject) => {
compiler.run((err, stats) => {
Expand Down
8 changes: 2 additions & 6 deletions test/loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

const test = require('tape');
const loader = require('../');
const loader = require('../index');
// const compiler = require('./compiler');
//
// test('hodor-loader test', async (t) => {
Expand Down Expand Up @@ -41,11 +41,7 @@ test('hodor-loader test', (t) => {
'should handle string concatenation correctly'
);

t.equal(
loader('let x = 42;'),
'let x = 42;',
'should not pick up number literal'
);
t.equal(loader('let x = 42;'), 'let x = 42;', 'should not pick up number literal');

t.equal(
loader('/* Created by glenn on 01.06.16. */ // const x = "tough and competent";'),
Expand Down
Loading

0 comments on commit 9782a2d

Please sign in to comment.