Skip to content

Commit 47f8920

Browse files
committed
take into account splitted modules in compat data result diff
1 parent efa5631 commit 47f8920

File tree

6 files changed

+18
-14
lines changed

6 files changed

+18
-14
lines changed

scripts/build-compat-data.mjs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* https://github.com/import-js/eslint-plugin-import/issues/2181 */
2-
import { data, modules } from 'core-js-compat/src/data.mjs';
2+
import { dataWithIgnored as data, ignored, modules } from 'core-js-compat/src/data.mjs';
33
import external from 'core-js-compat/src/external.mjs';
44
import mappings from 'core-js-compat/src/mapping.mjs';
55
import helpers from 'core-js-compat/helpers.js';
@@ -63,10 +63,18 @@ function write(filename, content) {
6363
return fs.writeJson(`packages/core-js-compat/${ filename }.json`, content, { spaces: ' ' });
6464
}
6565

66+
const dataWithoutIgnored = { ...data };
67+
68+
for (const ignore of ignored) delete dataWithoutIgnored[ignore];
69+
6670
await Promise.all([
67-
write('data', data),
71+
write('data', dataWithoutIgnored),
6872
write('modules', modules),
6973
write('external', external),
74+
// version for compat data tests
75+
fs.writeFile('tests/compat/compat-data.js', `;(typeof global != 'undefined' ? global : Function('return this')()).data = ${
76+
JSON.stringify(data, null, ' ')
77+
}`),
7078
]);
7179

7280
console.log(chalk.green('compat data rebuilt'));

tests/compat/common-runner.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var GLOBAL = typeof global != 'undefined' ? global : Function('return this')();
22
var results = GLOBAL.results = Object.create(null);
3+
var data = GLOBAL.data;
34
var tests = GLOBAL.tests;
45

56
for (var testName in tests) {
@@ -13,7 +14,7 @@ for (var testName in tests) {
1314
}
1415
}
1516

16-
GLOBAL.showResults = function (data, engine, logger) {
17+
GLOBAL.showResults = function (engine, logger) {
1718
var difference = false;
1819

1920
function logResults(showDifference) {

tests/compat/deno-runner.mjs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
/* global Deno -- it's Deno */
22
import './tests.js';
3+
import './compat-data.js';
34
import './common-runner.js';
45

56
if (Deno.args.includes('--mode=JSON')) {
67
console.log(JSON.stringify(globalThis.results, null, ' '));
7-
} else {
8-
const data = JSON.parse(await Deno.readTextFile('packages/core-js-compat/data.json'));
9-
globalThis.showResults(data, 'deno', console.log);
10-
}
8+
} else globalThis.showResults('deno', console.log);

tests/compat/node-runner.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/* eslint-disable no-console -- output */
22
require('./tests');
3+
require('./compat-data');
34
require('./common-runner');
4-
var data = require('../../packages/core-js-compat/data');
55

66
if (process.argv.indexOf('--mode=JSON') !== -1) {
77
console.log(JSON.stringify(global.results, null, ' '));
8-
} else global.showResults(data, 'node', console.log);
8+
} else global.showResults('node', console.log);

tests/compat/rhino-prepare.mjs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,3 @@ const rhino = await fetch(
55
);
66

77
await fs.writeFile('tests/compat/rhino.jar', Buffer.from(await rhino.arrayBuffer()));
8-
9-
await fs.writeFile('tests/compat/compat-data.js', `module.exports = ${ await fs.readFile('packages/core-js-compat/data.json') }`);

tests/compat/rhino-runner.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
require('./tests');
2+
require('./compat-data');
23
require('./common-runner');
3-
// eslint-disable-next-line import/no-unresolved -- can be created after linting
4-
var data = require('./compat-data');
54

65
/* eslint-disable no-restricted-globals -- output */
7-
global.showResults(data, 'rhino', print);
6+
global.showResults('rhino', print);

0 commit comments

Comments
 (0)