Skip to content

Commit 144efda

Browse files
Use Yarn 2 (#878)
1 parent 4e9c59f commit 144efda

File tree

12 files changed

+8232
-5699
lines changed

12 files changed

+8232
-5699
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ jobs:
3636
- name: Install dependencies
3737
run: yarn
3838
- name: Install webpack ${{ matrix.webpack-version }}
39-
run: yarn add webpack@${{ matrix.webpack-version }}
39+
run: yarn add -D webpack@${{ matrix.webpack-version }}
40+
- name: Build babel-loader
41+
run: yarn run build
42+
env:
43+
BABEL_ENV: test
4044
- name: Run tests for webpack version ${{ matrix.webpack-version }}
4145
run: yarn test-only
4246
- name: Submit coverage data to codecov

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ lib
44
node_modules
55
npm-debug.log
66
test/output
7+
.yarn/*
8+
!.yarn/releases
9+
.pnp.*
10+
.vscode

.yarn/releases/yarn-2.3.3.cjs

Lines changed: 55 additions & 0 deletions
Large diffs are not rendered by default.

.yarnrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
yarnPath: .yarn/releases/yarn-2.3.3.cjs
File renamed without changes.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"husky": "^4.3.0",
3939
"lint-staged": "^10.5.1",
4040
"nyc": "^15.1.0",
41+
"pnp-webpack-plugin": "^1.6.4",
4142
"prettier": "^2.1.2",
4243
"react": "^17.0.1",
4344
"react-intl": "^5.9.4",

test/cache.test.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ test.cb("should output files to cache directory", t => {
7070

7171
webpack(config, (err, stats) => {
7272
t.is(err, null);
73-
t.is(stats.compilation.errors.length, 0);
74-
t.is(stats.compilation.warnings.length, 0);
73+
t.deepEqual(stats.compilation.errors, []);
74+
t.deepEqual(stats.compilation.warnings, []);
7575

7676
fs.readdir(t.context.cacheDirectory, (err, files) => {
7777
t.is(err, null);
@@ -105,8 +105,8 @@ test.serial.cb(
105105

106106
webpack(config, (err, stats) => {
107107
t.is(err, null);
108-
t.is(stats.compilation.errors.length, 0);
109-
t.is(stats.compilation.warnings.length, 0);
108+
t.deepEqual(stats.compilation.errors, []);
109+
t.deepEqual(stats.compilation.warnings, []);
110110

111111
fs.readdir(defaultCacheDir, (err, files) => {
112112
files = files.filter(file => /\b[0-9a-f]{5,40}\.json\.gz\b/.test(file));
@@ -176,8 +176,8 @@ test.serial.cb(
176176

177177
webpack(config, (err, stats) => {
178178
t.is(err, null);
179-
t.is(stats.compilation.errors.length, 0);
180-
t.is(stats.compilation.warnings.length, 0);
179+
t.deepEqual(stats.compilation.errors, []);
180+
t.deepEqual(stats.compilation.warnings, []);
181181

182182
fs.readdir(defaultCacheDir, (err, files) => {
183183
files = files.filter(file => /\b[0-9a-f]{5,40}\.json\.gz\b/.test(file));
@@ -215,8 +215,8 @@ test.cb("should read from cache directory if cached file exists", t => {
215215
// Istanbul for coverage.
216216
webpack(config, (err, stats) => {
217217
t.is(err, null);
218-
t.is(stats.compilation.errors.length, 0);
219-
t.is(stats.compilation.warnings.length, 0);
218+
t.deepEqual(stats.compilation.errors, []);
219+
t.deepEqual(stats.compilation.warnings, []);
220220

221221
webpack(config, err => {
222222
t.is(err, null);
@@ -251,8 +251,8 @@ test.cb("should have one file per module", t => {
251251

252252
webpack(config, (err, stats) => {
253253
t.is(err, null);
254-
t.is(stats.compilation.errors.length, 0);
255-
t.is(stats.compilation.warnings.length, 0);
254+
t.deepEqual(stats.compilation.errors, []);
255+
t.deepEqual(stats.compilation.warnings, []);
256256

257257
fs.readdir(t.context.cacheDirectory, (err, files) => {
258258
t.is(err, null);
@@ -308,8 +308,8 @@ test.cb("should generate a new file if the identifier changes", t => {
308308
configs.forEach(config => {
309309
webpack(config, (err, stats) => {
310310
t.is(err, null);
311-
t.is(stats.compilation.errors.length, 0);
312-
t.is(stats.compilation.warnings.length, 0);
311+
t.deepEqual(stats.compilation.errors, []);
312+
t.deepEqual(stats.compilation.warnings, []);
313313
counter -= 1;
314314

315315
if (!counter) {
@@ -369,10 +369,10 @@ test.cb("should allow to specify the .babelrc file", t => {
369369

370370
webpack(config, (err, multiStats) => {
371371
t.is(err, null);
372-
t.is(multiStats.stats[0].compilation.errors.length, 0);
373-
t.is(multiStats.stats[0].compilation.warnings.length, 0);
374-
t.is(multiStats.stats[1].compilation.errors.length, 0);
375-
t.is(multiStats.stats[1].compilation.warnings.length, 0);
372+
t.deepEqual(multiStats.stats[0].compilation.errors, []);
373+
t.deepEqual(multiStats.stats[0].compilation.warnings, []);
374+
t.deepEqual(multiStats.stats[1].compilation.errors, []);
375+
t.deepEqual(multiStats.stats[1].compilation.warnings, []);
376376

377377
fs.readdir(t.context.cacheDirectory, (err, files) => {
378378
t.is(err, null);

test/loader.test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ test.cb("should transpile the code snippet", t => {
4646

4747
webpack(config, (err, stats) => {
4848
t.is(err, null);
49-
t.is(stats.compilation.errors.length, 0);
50-
t.is(stats.compilation.warnings.length, 0);
49+
t.deepEqual(stats.compilation.errors, []);
50+
t.deepEqual(stats.compilation.warnings, []);
5151

5252
fs.readdir(t.context.directory, (err, files) => {
5353
t.is(err, null);
@@ -76,7 +76,7 @@ test.cb("should not throw error on syntax error", t => {
7676
webpack(config, (err, stats) => {
7777
t.true(stats.compilation.errors.length === 1);
7878
t.true(stats.compilation.errors[0] instanceof Error);
79-
t.is(stats.compilation.warnings.length, 0);
79+
t.deepEqual(stats.compilation.warnings, []);
8080

8181
t.end();
8282
});
@@ -102,8 +102,8 @@ test.cb("should not throw without config", t => {
102102

103103
webpack(config, (err, stats) => {
104104
t.is(err, null);
105-
t.is(stats.compilation.errors.length, 0);
106-
t.is(stats.compilation.warnings.length, 0);
105+
t.deepEqual(stats.compilation.errors, []);
106+
t.deepEqual(stats.compilation.warnings, []);
107107

108108
t.end();
109109
});
@@ -120,7 +120,7 @@ test.cb(
120120
});
121121
webpack(config, (err, stats) => {
122122
t.is(err, null);
123-
t.is(stats.compilation.warnings.length, 0);
123+
t.deepEqual(stats.compilation.warnings, []);
124124
const moduleBuildError = stats.compilation.errors[0];
125125
const babelLoaderError = moduleBuildError.error;
126126
t.regex(babelLoaderError.stack, /Unexpected token/);
@@ -177,7 +177,7 @@ test.cb("should load ESM config files", t => {
177177
// "modules aren't supported" or "modules not supported".
178178
t.regex(babelLoaderError.message, /supported/i);
179179
}
180-
t.is(stats.compilation.warnings.length, 0);
180+
t.deepEqual(stats.compilation.warnings, []);
181181
t.end();
182182
});
183183
});

test/metadata.test.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import fs from "fs";
33
import path from "path";
44
import rimraf from "rimraf";
55
import webpack from "webpack";
6+
import PnpWebpackPlugin from "pnp-webpack-plugin";
67
import createTestDirectory from "./helpers/createTestDirectory";
78

89
const ReactIntlPlugin = require("react-intl-webpack-plugin");
@@ -18,6 +19,9 @@ const globalConfig = {
1819
filename: "[id].metadata.js",
1920
},
2021
plugins: [new ReactIntlPlugin()],
22+
resolve: {
23+
plugins: [PnpWebpackPlugin],
24+
},
2125
module: {
2226
rules: [
2327
{
@@ -56,8 +60,8 @@ test.cb("should pass metadata code snippet", t => {
5660

5761
webpack(config, (err, stats) => {
5862
t.is(err, null);
59-
t.is(stats.compilation.errors.length, 0);
60-
t.is(stats.compilation.warnings.length, 0);
63+
t.deepEqual(stats.compilation.errors, []);
64+
t.deepEqual(stats.compilation.warnings, []);
6165

6266
fs.readdir(t.context.directory, (err, files) => {
6367
t.is(err, null);
@@ -88,8 +92,8 @@ test.cb("should not throw error", t => {
8892

8993
webpack(config, (err, stats) => {
9094
t.is(err, null);
91-
t.is(stats.compilation.errors.length, 0);
92-
t.is(stats.compilation.warnings.length, 0);
95+
t.deepEqual(stats.compilation.errors, []);
96+
t.deepEqual(stats.compilation.warnings, []);
9397
t.end();
9498
});
9599
});
@@ -106,7 +110,7 @@ test.cb("should throw error", t => {
106110
webpack(config, (err, stats) => {
107111
t.is(err, null);
108112
t.true(stats.compilation.errors.length > 0);
109-
t.is(stats.compilation.warnings.length, 0);
113+
t.deepEqual(stats.compilation.warnings, []);
110114
t.end();
111115
});
112116
});
@@ -136,8 +140,8 @@ test.cb("should pass metadata code snippet ( cache version )", t => {
136140

137141
webpack(config, (err, stats) => {
138142
t.is(err, null);
139-
t.is(stats.compilation.errors.length, 0);
140-
t.is(stats.compilation.warnings.length, 0);
143+
t.deepEqual(stats.compilation.errors, []);
144+
t.deepEqual(stats.compilation.warnings, []);
141145

142146
fs.readdir(t.context.directory, (err, files) => {
143147
t.is(err, null);

test/options.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ test.cb("should interpret options given to the loader", t => {
5151

5252
webpack(config, (err, stats) => {
5353
t.is(err, null);
54-
t.is(stats.compilation.errors.length, 0);
55-
t.is(stats.compilation.warnings.length, 0);
54+
t.deepEqual(stats.compilation.errors, []);
55+
t.deepEqual(stats.compilation.warnings, []);
5656

5757
fs.readdir(outputDir, (err, files) => {
5858
t.is(err, null);

0 commit comments

Comments
 (0)