Skip to content

Commit 6e68254

Browse files
committed
Update supported Node.js version and dependencies
1 parent 5e7279b commit 6e68254

20 files changed

+63
-77
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
node-version: [^10.18.0, ^12.14.0, ^13.5.0]
16+
node-version: [^12.22, ^14.16, ^16]
1717
os: [ubuntu-latest, windows-latest]
1818
steps:
1919
- uses: actions/checkout@v1

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
/.nyc_output
21
/coverage
32
/node_modules

index.js

+12-18
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
'use strict';
21
const fs = require('fs');
32
const path = require('path');
43
const installPrecompiler = require('@ava/require-precompiled');
@@ -9,7 +8,7 @@ const convertSourceMap = require('convert-source-map');
98
const dotProp = require('dot-prop');
109
const escapeStringRegexp = require('escape-string-regexp');
1110
const findUp = require('find-up');
12-
const isPlainObject = require('is-plain-object');
11+
const {isPlainObject} = require('is-plain-object');
1312
const md5Hex = require('md5-hex');
1413
const packageHash = require('package-hash');
1514
const pkgConf = require('pkg-conf');
@@ -37,8 +36,8 @@ function enableParserPlugins(api) {
3736

3837
return {
3938
name: 'ava-babel-pipeline-enable-parser-plugins',
40-
manipulateOptions(_, parserOpts) {
41-
parserOpts.plugins.push(
39+
manipulateOptions(_, parserOptions) {
40+
parserOptions.plugins.push(
4241
'bigInt',
4342
'classPrivateProperties',
4443
'classProperties',
@@ -77,13 +76,13 @@ function wantsStage4(babelOptions, projectDir) {
7776
return true;
7877
}
7978

80-
const stage4 = require('./stage-4');
81-
return babelOptions.presets.every(arr => {
82-
if (!Array.isArray(arr)) {
79+
const stage4 = require('./stage-4.js');
80+
return babelOptions.presets.every(array => {
81+
if (!Array.isArray(array)) {
8382
return true; // There aren't any preset options.
8483
}
8584

86-
const [ref, options] = arr;
85+
const [ref, options] = array;
8786
// Require the preset to handle any aliasing that may be taking place.
8887
const resolved = require(babel.resolvePreset(ref, projectDir));
8988
return resolved !== stage4 || options !== false;
@@ -119,12 +118,7 @@ function hashPartialConfig({babelrc, config, options: {plugins, presets}}, proje
119118
}
120119

121120
const [firstComponent] = path.relative(projectDir, filename).split(path.sep);
122-
let hash;
123-
if (firstComponent === 'node_modules') {
124-
hash = packageHash.sync(findUp.sync('package.json', {cwd: path.dirname(filename)}));
125-
} else {
126-
hash = md5Hex(stripBomBuf(fs.readFileSync(filename)));
127-
}
121+
const hash = firstComponent === 'node_modules' ? packageHash.sync(findUp.sync('package.json', {cwd: path.dirname(filename)})) : md5Hex(stripBomBuf(fs.readFileSync(filename)));
128122

129123
pluginAndPresetHashes.set(filename, hash);
130124
inputs.push(hash);
@@ -182,12 +176,12 @@ function createCompileFn({babelOptions, cacheDir, compileEnhancements, projectDi
182176
const {options: partialOptions} = partialConfig;
183177
partialOptions.plugins.push(enableParserPlugins);
184178

185-
if (ensureStage4 && !partialOptions.presets.some(containsStage4)) {
179+
if (ensureStage4 && !partialOptions.presets.some(preset => containsStage4(preset))) {
186180
// Apply last.
187181
partialOptions.presets.unshift(createConfigItem('./stage-4', 'preset'));
188182
}
189183

190-
if (compileEnhancements && !partialOptions.presets.some(containsTransformTestFiles)) {
184+
if (compileEnhancements && !partialOptions.presets.some(preset => containsTransformTestFiles(preset))) {
191185
// Apply first.
192186
partialOptions.presets.push(createConfigItem('./transform-test-files', 'preset', {powerAssert: true}));
193187
}
@@ -344,13 +338,13 @@ module.exports = ({negotiateProtocol}) => {
344338
}
345339

346340
return {
347-
extensions: extensions.slice(),
341+
extensions: [...extensions],
348342
lookup
349343
};
350344
},
351345

352346
get extensions() {
353-
return extensions.slice();
347+
return [...extensions];
354348
}
355349
};
356350
},

package.json

+22-22
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "1.0.1",
44
"description": "Babel provider for AVA",
55
"engines": {
6-
"node": ">=10.18.0 <11 || >=12.14.0 <13 || >=13.5.0"
6+
"node": ">=12.22 <13 || >=14.16 <15 || >=16"
77
},
88
"files": [
99
"espower-patterns.json",
@@ -21,46 +21,46 @@
2121
"babel"
2222
],
2323
"scripts": {
24-
"test": "xo && nyc ava"
24+
"test": "xo && c8 ava"
2525
},
2626
"dependencies": {
2727
"@ava/require-precompiled": "^1.0.0",
28-
"@babel/core": "^7.8.4",
29-
"@babel/generator": "^7.8.4",
30-
"@babel/plugin-proposal-dynamic-import": "^7.8.3",
31-
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.8.3",
32-
"@babel/plugin-proposal-optional-chaining": "^7.8.3",
33-
"@babel/plugin-transform-modules-commonjs": "^7.8.3",
28+
"@babel/core": "^7.14.6",
29+
"@babel/generator": "^7.14.5",
30+
"@babel/plugin-proposal-dynamic-import": "^7.14.5",
31+
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.14.5",
32+
"@babel/plugin-proposal-optional-chaining": "^7.14.5",
33+
"@babel/plugin-transform-modules-commonjs": "^7.14.5",
3434
"babel-plugin-espower": "^3.0.1",
35-
"concordance": "^4.0.0",
36-
"convert-source-map": "^1.7.0",
37-
"dot-prop": "^5.2.0",
35+
"concordance": "^5.0.4",
36+
"convert-source-map": "^1.8.0",
37+
"dot-prop": "^6.0.1",
3838
"empower-core": "^1.2.0",
39-
"escape-string-regexp": "^2.0.0",
40-
"find-up": "^4.1.0",
41-
"is-plain-object": "^3.0.0",
39+
"escape-string-regexp": "^4.0.0",
40+
"find-up": "^5.0.0",
41+
"is-plain-object": "^5.0.0",
4242
"md5-hex": "^3.0.1",
4343
"package-hash": "^4.0.0",
4444
"pkg-conf": "^3.1.0",
45-
"source-map-support": "^0.5.16",
45+
"source-map-support": "^0.5.19",
4646
"strip-bom-buf": "^2.0.0",
47-
"write-file-atomic": "^3.0.1"
47+
"write-file-atomic": "^3.0.3"
4848
},
4949
"devDependencies": {
50-
"ava": "^3.2.0",
51-
"execa": "^4.0.0",
52-
"nyc": "^15.0.0",
50+
"ava": "^3.15.0",
51+
"c8": "^7.7.3",
52+
"execa": "^5.1.1",
5353
"proxyquire": "^2.1.3",
54-
"tempy": "^0.3.0",
55-
"xo": "^0.25.3"
54+
"tempy": "^1.0.1",
55+
"xo": "^0.39.1"
5656
},
5757
"ava": {
5858
"files": [
5959
"test/**/*.js",
6060
"!test/fixtures/**/*.js"
6161
]
6262
},
63-
"nyc": {
63+
"c8": {
6464
"reporter": [
6565
"html",
6666
"lcov",

stage-4-plugins/best-match.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
'use strict';
21
const process = require('process'); // eslint-disable-line node/prefer-global/process
32

43
function getClosestVersion() {
@@ -7,7 +6,7 @@ function getClosestVersion() {
76
return 'v8-6.8';
87
}
98

10-
const v8 = parseFloat(process.versions.v8);
9+
const v8 = Number.parseFloat(process.versions.v8);
1110
if (v8 >= 6.8) {
1211
return 'v8-6.8';
1312
}

stage-4.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
'use strict';
21
module.exports = (api, options) => {
32
const transformModules = !options || options.modules !== false;
4-
const plugins = require('./stage-4-plugins/best-match')
3+
const plugins = require('./stage-4-plugins/best-match.js')
54
.filter(module => {
65
if (transformModules) {
76
return true;

test/fixtures/esm-export.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
export default 'value from esm-export.js';
1+
const value = 'value from esm-export.js';
2+
export default value;

test/fixtures/esm-import.cjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import value from './esm-export';
1+
import value from './esm-export.js';
22

33
console.log('logging in esm-import.cjs:', value);

test/fixtures/esm-import.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import value from './esm-export';
1+
import value from './esm-export.js';
22

33
console.log('logging in esm-import.js:', value);

test/fixtures/install-and-load.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const path = require('path');
2-
const makeProvider = require('../..');
2+
const makeProvider = require('../../index.js');
33

44
const provider = makeProvider({
55
negotiateProtocol() {

test/protocol-ava-3.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ test('worker(): load compiled files', withProvider, async (t, provider) => {
124124
t.log(stderr);
125125
}
126126

127-
t.snapshot(stdout, file);
127+
t.snapshot(stdout, `${file}`);
128128
}
129129
});
130130

test/snapshots/protocol-ava-3.js.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,31 @@
22

33
The actual snapshot is saved in `protocol-ava-3.js.snap`.
44

5-
Generated by [AVA](https://ava.li).
5+
Generated by [AVA](https://avajs.dev).
66

7-
## main() config validation: throw when babelConfig contains keys other than 'compileEnhancements', 'extensions' or 'testOptions'
7+
## main() config validation: throw when babelConfig is not true or a plain object
88

99
> Snapshot 1
1010
1111
Error {
1212
message: 'Unexpected Babel configuration for AVA. See https://github.com/avajs/babel/blob/v${pkg.version}/README.md for allowed values.',
1313
}
1414

15-
## main() config validation: throw when babelConfig is not true or a plain object
16-
17-
> Snapshot 1
15+
> Snapshot 2
1816
1917
Error {
2018
message: 'Unexpected Babel configuration for AVA. See https://github.com/avajs/babel/blob/v${pkg.version}/README.md for allowed values.',
2119
}
2220

23-
> Snapshot 2
21+
> Snapshot 3
2422
2523
Error {
2624
message: 'Unexpected Babel configuration for AVA. See https://github.com/avajs/babel/blob/v${pkg.version}/README.md for allowed values.',
2725
}
2826

29-
> Snapshot 3
27+
## main() config validation: throw when babelConfig contains keys other than 'compileEnhancements', 'extensions' or 'testOptions'
28+
29+
> Snapshot 1
3030
3131
Error {
3232
message: 'Unexpected Babel configuration for AVA. See https://github.com/avajs/babel/blob/v${pkg.version}/README.md for allowed values.',
@@ -40,23 +40,23 @@ Generated by [AVA](https://ava.li).
4040
message: 'Unexpected Babel configuration for AVA. See https://github.com/avajs/babel/blob/v${pkg.version}/README.md for allowed values.',
4141
}
4242

43-
## main() config validation: throw when babelConfig.extensions contains duplicates
43+
## main() config validation: throw when babelConfig.extensions contains empty strings
4444

4545
> Snapshot 1
4646
4747
Error {
4848
message: 'Unexpected Babel configuration for AVA. See https://github.com/avajs/babel/blob/v${pkg.version}/README.md for allowed values.',
4949
}
5050

51-
## main() config validation: throw when babelConfig.extensions contains empty strings
51+
## main() config validation: throw when babelConfig.extensions contains non-strings
5252

5353
> Snapshot 1
5454
5555
Error {
5656
message: 'Unexpected Babel configuration for AVA. See https://github.com/avajs/babel/blob/v${pkg.version}/README.md for allowed values.',
5757
}
5858

59-
## main() config validation: throw when babelConfig.extensions contains non-strings
59+
## main() config validation: throw when babelConfig.extensions contains duplicates
6060

6161
> Snapshot 1
6262

test/snapshots/protocol-ava-3.js.snap

4 Bytes
Binary file not shown.

test/snapshots/throws-helper.js.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The actual snapshot is saved in `throws-helper.js.snap`.
44

5-
Generated by [AVA](https://ava.li).
5+
Generated by [AVA](https://avajs.dev).
66

77
## creates a helper
88

test/snapshots/throws-helper.js.snap

0 Bytes
Binary file not shown.

test/stage-4.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ const buildPreset = (node, v8, options) => proxyquire('../stage-4', {
2525

2626
function buildsCorrectPreset(t, node, v8, mapping) {
2727
const {plugins} = buildPreset(node, v8);
28-
require(mapping).forEach((module, index) => {
28+
for (const [index, module] of require(mapping).entries()) {
2929
t.is(require(module).default, plugins[index], `${module} at index ${index}`);
30-
});
30+
}
3131
}
3232

3333
buildsCorrectPreset.title = (_, node) => `builds correct preset for Node.js ${node}`;

test/throws-helper.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const test = require('ava');
22
const babel = require('@babel/core');
3-
const fn = require('../throws-helper');
3+
const fn = require('../throws-helper.js');
44

55
function transform(input) {
66
return babel.transform(input, {

test/transform-test-files.js

+5-8
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ const {runInNewContext} = require('vm');
22
const test = require('ava');
33
const babel = require('@babel/core');
44
const empower = require('empower-core');
5-
const throwsHelper = require('../throws-helper');
6-
const buildPreset = require('../transform-test-files');
5+
const throwsHelper = require('../throws-helper.js');
6+
const buildPreset = require('../transform-test-files.js');
77

88
const ESPOWER_PATTERNS = require('../espower-patterns.json');
99

@@ -27,12 +27,9 @@ test('resulting preset transforms assertion patterns', t => {
2727

2828
const appliedPatterns = [];
2929
// Create a stub assertion object that can be enhanced using empower-core
30-
const assert = ESPOWER_PATTERNS
31-
.map(p => /^t\.(.+)\(/.exec(p)[1]) // eslint-disable-line prefer-named-capture-group
32-
.reduce((assert, name) => {
33-
assert[name] = () => {};
34-
return assert;
35-
}, {});
30+
const assert = Object.fromEntries(ESPOWER_PATTERNS
31+
.map(p => /^t\.(.+)\(/.exec(p)[1])
32+
.map(name => [name, () => {}]));
3633

3734
runInNewContext(code, {
3835
t: empower(assert, {

throws-helper.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
'use strict';
2-
31
module.exports = babelCore => {
42
const t = babelCore.types;
53
const wrapArg = babelCore.template('(START(t, ASSERTION, FILE, LINE), END(t, ARG))');

transform-test-files.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
'use strict';
21
const ESPOWER_PATTERNS = require('./espower-patterns.json');
32

43
module.exports = (context, options) => {
@@ -11,7 +10,7 @@ module.exports = (context, options) => {
1110
}]);
1211
}
1312

14-
plugins.push(require('./throws-helper'));
13+
plugins.push(require('./throws-helper.js'));
1514

1615
return {plugins};
1716
};

0 commit comments

Comments
 (0)