Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Yarn 2 #878

Merged
merged 4 commits into from
Nov 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ jobs:
- name: Install dependencies
run: yarn
- name: Install webpack ${{ matrix.webpack-version }}
run: yarn add webpack@${{ matrix.webpack-version }}
run: yarn add -D webpack@${{ matrix.webpack-version }}
- name: Build babel-loader
run: yarn run build
env:
BABEL_ENV: test
- name: Run tests for webpack version ${{ matrix.webpack-version }}
run: yarn test-only
- name: Submit coverage data to codecov
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ lib
node_modules
npm-debug.log
test/output
.yarn/*
!.yarn/releases
.pnp.*
.vscode
55 changes: 55 additions & 0 deletions .yarn/releases/yarn-2.3.3.cjs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarnPath: .yarn/releases/yarn-2.3.3.cjs
File renamed without changes.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"husky": "^4.3.0",
"lint-staged": "^10.5.1",
"nyc": "^15.1.0",
"pnp-webpack-plugin": "^1.6.4",
"prettier": "^2.1.2",
"react": "^17.0.1",
"react-intl": "^5.9.4",
Expand Down
32 changes: 16 additions & 16 deletions test/cache.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ test.cb("should output files to cache directory", t => {

webpack(config, (err, stats) => {
t.is(err, null);
t.is(stats.compilation.errors.length, 0);
t.is(stats.compilation.warnings.length, 0);
t.deepEqual(stats.compilation.errors, []);
t.deepEqual(stats.compilation.warnings, []);

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

webpack(config, (err, stats) => {
t.is(err, null);
t.is(stats.compilation.errors.length, 0);
t.is(stats.compilation.warnings.length, 0);
t.deepEqual(stats.compilation.errors, []);
t.deepEqual(stats.compilation.warnings, []);

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

webpack(config, (err, stats) => {
t.is(err, null);
t.is(stats.compilation.errors.length, 0);
t.is(stats.compilation.warnings.length, 0);
t.deepEqual(stats.compilation.errors, []);
t.deepEqual(stats.compilation.warnings, []);

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

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

webpack(config, (err, stats) => {
t.is(err, null);
t.is(stats.compilation.errors.length, 0);
t.is(stats.compilation.warnings.length, 0);
t.deepEqual(stats.compilation.errors, []);
t.deepEqual(stats.compilation.warnings, []);

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

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

webpack(config, (err, multiStats) => {
t.is(err, null);
t.is(multiStats.stats[0].compilation.errors.length, 0);
t.is(multiStats.stats[0].compilation.warnings.length, 0);
t.is(multiStats.stats[1].compilation.errors.length, 0);
t.is(multiStats.stats[1].compilation.warnings.length, 0);
t.deepEqual(multiStats.stats[0].compilation.errors, []);
t.deepEqual(multiStats.stats[0].compilation.warnings, []);
t.deepEqual(multiStats.stats[1].compilation.errors, []);
t.deepEqual(multiStats.stats[1].compilation.warnings, []);

fs.readdir(t.context.cacheDirectory, (err, files) => {
t.is(err, null);
Expand Down
14 changes: 7 additions & 7 deletions test/loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ test.cb("should transpile the code snippet", t => {

webpack(config, (err, stats) => {
t.is(err, null);
t.is(stats.compilation.errors.length, 0);
t.is(stats.compilation.warnings.length, 0);
t.deepEqual(stats.compilation.errors, []);
t.deepEqual(stats.compilation.warnings, []);

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

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

webpack(config, (err, stats) => {
t.is(err, null);
t.is(stats.compilation.errors.length, 0);
t.is(stats.compilation.warnings.length, 0);
t.deepEqual(stats.compilation.errors, []);
t.deepEqual(stats.compilation.warnings, []);

t.end();
});
Expand All @@ -120,7 +120,7 @@ test.cb(
});
webpack(config, (err, stats) => {
t.is(err, null);
t.is(stats.compilation.warnings.length, 0);
t.deepEqual(stats.compilation.warnings, []);
const moduleBuildError = stats.compilation.errors[0];
const babelLoaderError = moduleBuildError.error;
t.regex(babelLoaderError.stack, /Unexpected token/);
Expand Down Expand Up @@ -177,7 +177,7 @@ test.cb("should load ESM config files", t => {
// "modules aren't supported" or "modules not supported".
t.regex(babelLoaderError.message, /supported/i);
}
t.is(stats.compilation.warnings.length, 0);
t.deepEqual(stats.compilation.warnings, []);
t.end();
});
});
18 changes: 11 additions & 7 deletions test/metadata.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import fs from "fs";
import path from "path";
import rimraf from "rimraf";
import webpack from "webpack";
import PnpWebpackPlugin from "pnp-webpack-plugin";
import createTestDirectory from "./helpers/createTestDirectory";

const ReactIntlPlugin = require("react-intl-webpack-plugin");
Expand All @@ -18,6 +19,9 @@ const globalConfig = {
filename: "[id].metadata.js",
},
plugins: [new ReactIntlPlugin()],
resolve: {
plugins: [PnpWebpackPlugin],
},
module: {
rules: [
{
Expand Down Expand Up @@ -56,8 +60,8 @@ test.cb("should pass metadata code snippet", t => {

webpack(config, (err, stats) => {
t.is(err, null);
t.is(stats.compilation.errors.length, 0);
t.is(stats.compilation.warnings.length, 0);
t.deepEqual(stats.compilation.errors, []);
t.deepEqual(stats.compilation.warnings, []);

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

webpack(config, (err, stats) => {
t.is(err, null);
t.is(stats.compilation.errors.length, 0);
t.is(stats.compilation.warnings.length, 0);
t.deepEqual(stats.compilation.errors, []);
t.deepEqual(stats.compilation.warnings, []);
t.end();
});
});
Expand All @@ -106,7 +110,7 @@ test.cb("should throw error", t => {
webpack(config, (err, stats) => {
t.is(err, null);
t.true(stats.compilation.errors.length > 0);
t.is(stats.compilation.warnings.length, 0);
t.deepEqual(stats.compilation.warnings, []);
t.end();
});
});
Expand Down Expand Up @@ -136,8 +140,8 @@ test.cb("should pass metadata code snippet ( cache version )", t => {

webpack(config, (err, stats) => {
t.is(err, null);
t.is(stats.compilation.errors.length, 0);
t.is(stats.compilation.warnings.length, 0);
t.deepEqual(stats.compilation.errors, []);
t.deepEqual(stats.compilation.warnings, []);

fs.readdir(t.context.directory, (err, files) => {
t.is(err, null);
Expand Down
4 changes: 2 additions & 2 deletions test/options.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ test.cb("should interpret options given to the loader", t => {

webpack(config, (err, stats) => {
t.is(err, null);
t.is(stats.compilation.errors.length, 0);
t.is(stats.compilation.warnings.length, 0);
t.deepEqual(stats.compilation.errors, []);
t.deepEqual(stats.compilation.warnings, []);

fs.readdir(outputDir, (err, files) => {
t.is(err, null);
Expand Down
20 changes: 10 additions & 10 deletions test/sourcemaps.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ test.cb("should output webpack's sourcemap", t => {

webpack(config, (err, stats) => {
t.is(err, null);
t.is(stats.compilation.errors.length, 0);
t.is(stats.compilation.warnings.length, 0);
t.deepEqual(stats.compilation.errors, []);
t.deepEqual(stats.compilation.warnings, []);

fs.readdir(t.context.directory, (err, files) => {
t.is(err, null);
Expand Down Expand Up @@ -99,8 +99,8 @@ test.cb("should output webpack's sourcemap properly when set 'inline'", t => {

webpack(config, (err, stats) => {
t.is(err, null);
t.is(stats.compilation.errors.length, 0);
t.is(stats.compilation.warnings.length, 0);
t.deepEqual(stats.compilation.errors, []);
t.deepEqual(stats.compilation.warnings, []);

fs.readdir(t.context.directory, (err, files) => {
t.is(err, null);
Expand Down Expand Up @@ -156,8 +156,8 @@ test.cb("should output webpack's devtoolModuleFilename option", t => {

webpack(config, (err, stats) => {
t.is(err, null);
t.is(stats.compilation.errors.length, 0);
t.is(stats.compilation.warnings.length, 0);
t.deepEqual(stats.compilation.errors, []);
t.deepEqual(stats.compilation.warnings, []);

fs.readdir(t.context.directory, (err, files) => {
t.is(err, null);
Expand Down Expand Up @@ -214,8 +214,8 @@ test.cb("should disable sourcemap output with 'sourceMaps:false'", t => {

webpack(config, (err, stats) => {
t.is(err, null);
t.is(stats.compilation.errors.length, 0);
t.is(stats.compilation.warnings.length, 0);
t.deepEqual(stats.compilation.errors, []);
t.deepEqual(stats.compilation.warnings, []);

fs.readdir(t.context.directory, (err, files) => {
t.is(err, null);
Expand Down Expand Up @@ -277,8 +277,8 @@ test.cb("should disable sourcemap output with 'sourceMap:false'", t => {

webpack(config, (err, stats) => {
t.is(err, null);
t.is(stats.compilation.errors.length, 0);
t.is(stats.compilation.warnings.length, 0);
t.deepEqual(stats.compilation.errors, []);
t.deepEqual(stats.compilation.warnings, []);

fs.readdir(t.context.directory, (err, files) => {
t.is(err, null);
Expand Down
Loading