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

Commit 6bf1e89

Browse files
joshwiensshellscape
authored andcommitted
refactor: webpack 4.x compatibility (#30)
* refactor: apply webpack-defaults (#23) * refactor: apply webpack defautls BREAKING CHANGE: Enforces engines & webpack peerDependencies * chore: Set peerDeps to 4.x & drop Node 4 BREAKING CHANGE: Drops support for NodeJS 4.x * ci: Setup to test webpack 4.x * ci(travis): Allow `next` branch builds * ci(travis): Trying to wake up Travis * chore: Set engines to initial LTS release version * ci(circle): prefer circle, remove travis/appveyor * ci(jest): disable env-specific test * ci(jest): fix loader test
1 parent e3002cf commit 6bf1e89

29 files changed

+9964
-149
lines changed

.babelrc

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"presets": [
3+
[
4+
"env",
5+
{
6+
"useBuiltIns": true,
7+
"targets": {
8+
"node": "6.9.0"
9+
},
10+
"exclude": [
11+
"transform-async-to-generator",
12+
"transform-regenerator"
13+
]
14+
}
15+
]
16+
],
17+
"plugins": [
18+
[
19+
"transform-object-rest-spread",
20+
{
21+
"useBuiltIns": true
22+
}
23+
]
24+
],
25+
"env": {
26+
"test": {
27+
"presets": [
28+
"env"
29+
],
30+
"plugins": [
31+
"transform-object-rest-spread"
32+
]
33+
}
34+
}
35+
}

.circleci/config.yml

+161
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
unit_tests: &unit_tests
2+
steps:
3+
- checkout
4+
- setup_remote_docker
5+
- restore_cache:
6+
key: dependency-cache-{{ checksum "package-lock.json" }}
7+
- run:
8+
name: NPM Rebuild
9+
command: npm install
10+
- run:
11+
name: Run unit tests.
12+
command: npm run ci:test
13+
# canary_tests: &canary_tests
14+
# steps:
15+
# - checkout
16+
# - setup_remote_docker
17+
# - restore_cache:
18+
# key: dependency-cache-{{ checksum "package-lock.json" }}
19+
# - run:
20+
# name: NPM Rebuild
21+
# command: npm install
22+
# - run:
23+
# name: Install Webpack Canary
24+
# command: npm i --no-save webpack@next
25+
# - run:
26+
# name: Run unit tests.
27+
# command: npm run ci:test
28+
29+
version: 2
30+
jobs:
31+
dependency_cache:
32+
docker:
33+
- image: webpackcontrib/circleci-node-base:latest
34+
steps:
35+
- checkout
36+
- setup_remote_docker
37+
- restore_cache:
38+
key: dependency-cache-{{ checksum "package-lock.json" }}
39+
- run:
40+
name: Install Dependencies
41+
command: npm install
42+
- save_cache:
43+
key: dependency-cache-{{ checksum "package-lock.json" }}
44+
paths:
45+
- ./node_modules
46+
47+
node8-latest:
48+
docker:
49+
- image: webpackcontrib/circleci-node8:latest
50+
steps:
51+
- checkout
52+
- setup_remote_docker
53+
- restore_cache:
54+
key: dependency-cache-{{ checksum "package-lock.json" }}
55+
- run:
56+
name: NPM Rebuild
57+
command: npm install
58+
- run:
59+
name: Run unit tests.
60+
command: npm run ci:coverage
61+
- run:
62+
name: Submit coverage data to codecov.
63+
command: bash <(curl -s https://codecov.io/bash)
64+
when: on_success
65+
node6-latest:
66+
docker:
67+
- image: webpackcontrib/circleci-node6:latest
68+
<<: *unit_tests
69+
node9-latest:
70+
docker:
71+
- image: webpackcontrib/circleci-node9:latest
72+
<<: *unit_tests
73+
# node8-canary:
74+
# docker:
75+
# - image: webpackcontrib/circleci-node8:latest
76+
# <<: *canary_tests
77+
analysis:
78+
docker:
79+
- image: webpackcontrib/circleci-node-base:latest
80+
steps:
81+
- checkout
82+
- setup_remote_docker
83+
- restore_cache:
84+
key: dependency-cache-{{ checksum "package-lock.json" }}
85+
- run:
86+
name: NPM Rebuild
87+
command: npm install
88+
- run:
89+
name: Run linting.
90+
command: npm run lint
91+
- run:
92+
name: Run NSP Security Check.
93+
command: npm run security
94+
# - run:
95+
# name: Validate Commit Messages
96+
# command: npm run ci:lint:commits
97+
# publish:
98+
# docker:
99+
# - image: webpackcontrib/circleci-node-base:latest
100+
# steps:
101+
# - checkout
102+
# - setup_remote_docker
103+
# - restore_cache:
104+
# key: dependency-cache-{{ checksum "package-lock.json" }}
105+
# - run:
106+
# name: NPM Rebuild
107+
# command: npm install
108+
# - run:
109+
# name: Validate Commit Messages
110+
# command: npm run release:validate
111+
# - run:
112+
# name: Publish to NPM
113+
# command: printf "noop running conventional-github-releaser"
114+
115+
version: 2.0
116+
workflows:
117+
version: 2
118+
validate-publish:
119+
jobs:
120+
- dependency_cache
121+
- node6-latest:
122+
requires:
123+
- dependency_cache
124+
filters:
125+
tags:
126+
only: /.*/
127+
- analysis:
128+
requires:
129+
- dependency_cache
130+
filters:
131+
tags:
132+
only: /.*/
133+
- node8-latest:
134+
requires:
135+
- analysis
136+
- node6-latest
137+
filters:
138+
tags:
139+
only: /.*/
140+
- node9-latest:
141+
requires:
142+
- analysis
143+
- node6-latest
144+
filters:
145+
tags:
146+
only: /.*/
147+
# - node8-canary:
148+
# requires:
149+
# - analysis
150+
# - node6-latest
151+
filters:
152+
tags:
153+
only: /.*/
154+
- publish:
155+
requires:
156+
- node8-latest
157+
- node9-latest
158+
filters:
159+
branches:
160+
only:
161+
- master

.editorconfig

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# editorconfig.org
2+
3+
[*]
4+
charset = utf-8
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[.md]
12+
insert_final_newline = false
13+
trim_trailing_whitespace = false

.eslintignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/node_modules
2+
/dist

.eslintrc

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "webpack",
3+
"rules": {
4+
"line-comment-position": 0,
5+
"consistent-return": 0,
6+
"prefer-destructuring": 1,
7+
"import/no-dynamic-require": 1,
8+
"global-require": 1
9+
}
10+
}

.gitattributes

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
yarn.lock -diff
2+
* text=auto
3+
bin/* eol=lf
4+
package-lock.json -diff

.github/ISSUE_TEMPLATE.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!--
2+
1. Check the version of package you are using. If it's not the newest version, update and try again (see changelog while updating!).
3+
2. If the issue is still there, write a minimal project showing the problem and expected output.
4+
3. Link to the project and mention Node version and OS in your report.
5+
6+
**IMPORTANT! You should use [Stack Overflow](https://stackoverflow.com/) for support related questions.**
7+
-->

.github/PULL_REQUEST_TEMPLATE.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<!--
2+
1. [Read and sign the CLA](https://cla.js.foundation/webpack/webpack.js.org). This needs to be done only once. PRs that haven't signed it won't be accepted.
3+
2. Check out the [development guide](https://webpack.js.org/development/) for the API and development guidelines.
4+
3. Read through the PR diff carefully as sometimes this can reveal issues. The work will be reviewed, but this can save some effort.
5+
-->

.gitignore

+17-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,17 @@
1-
node_modules
1+
node_modules
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
.eslintcache
7+
/coverage
8+
/dist
9+
/local
10+
/reports
11+
/node_modules
12+
.DS_Store
13+
Thumbs.db
14+
.idea
15+
.vscode
16+
*.sublime-project
17+
*.sublime-workspace

CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Change Log
2+
3+
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4+
5+
x.x.x / <year>-<month>-<day>
6+
==================
7+
8+
* Bug fix -
9+
* Feature -
10+
* Chore -
11+
* Docs -

LICENSE

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
Copyright JS Foundation and other contributors
32

43
Permission is hereby granted, free of charge, to any person obtaining

README.md

+1-52
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ Pass the module name as query parameter.
2424

2525
``` javascript
2626
var x = require("!transform-loader?brfs!./file.js");
27-
var x = require("!transform-loader/cacheable?brfs!./file.js"); // cacheable version
2827
```
2928

3029
If you pass a number instead it will take the function from `this.options.transforms[number]`.
@@ -52,23 +51,6 @@ module.exports = {
5251
}
5352
},
5453

55-
{
56-
test: /\.coffee$/,
57-
loader: "transform-loader/cacheable?coffeeify",
58-
options: {
59-
transforms: [
60-
function (/*file*/) {
61-
return through((buffer) => {
62-
return this.queue(
63-
buffer.split('')
64-
.map((chunk) => String.fromCharCode(127-chunk.charCodeAt(0))))
65-
.join('')
66-
}, () => this.queue(null))
67-
}
68-
]
69-
}
70-
},
71-
7254
{
7355
test: /\.weirdjs$/,
7456
loader: "transform-loader?0",
@@ -90,39 +72,6 @@ module.exports = {
9072
};
9173
```
9274

93-
<h2 align="center">webpack 1 config example</h2>
94-
95-
``` javascript
96-
module.exports = {
97-
module: {
98-
postLoaders: [
99-
{
100-
loader: "transform-loader?brfs"
101-
}
102-
]
103-
loaders: [
104-
{
105-
test: /\.coffee$/,
106-
loader: "transform-loader/cacheable?coffeeify"
107-
},
108-
{
109-
test: /\.weirdjs$/,
110-
loader: "transform-loader?0"
111-
}
112-
]
113-
},
114-
transforms: [
115-
function(file) {
116-
return through(function(buf) {
117-
this.queue(buf.split("").map(function(s) {
118-
return String.fromCharCode(127-s.charCodeAt(0));
119-
}).join(""));
120-
}, function() { this.queue(null); });
121-
}
122-
]
123-
};
124-
```
125-
12675
<h2 align="center">Typical brfs Example</h2>
12776

12877
Say you have the following Node source:
@@ -148,7 +97,7 @@ module.exports = {
14897
}
14998
```
15099

151-
The loader is applied to all JS files, which can incur a performance hit with watch tasks. So you may want to use `transform-loader/cacheable?brfs` instead.
100+
The loader is applied to all JS files, which can incur a performance hit with watch tasks. So you may want to use `transform-loader/cacheable?brfs` instead.
152101

153102
<h2 align="center">Maintainers</h2>
154103

cacheable.js

-9
This file was deleted.

0 commit comments

Comments
 (0)