Skip to content

Commit 6d50a9d

Browse files
authored
Fixture: Legacy JSX Runtimes (facebook#20012)
* Fixture: Legacy JSX Runtimes * Add more comments
1 parent f75f8b4 commit 6d50a9d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+15740
-1
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Legacy JSX Runtimes
2+
3+
This is an internal testing fixture for the special JSX runtime versions released for 0.14, 15, and 16.
4+
5+
They are checked into the corresponding `react-*/cjs/*` folders.
6+
7+
Run the full regression suite:
8+
9+
```
10+
yarn
11+
yarn test
12+
```
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = {
2+
presets: [
3+
[
4+
'@babel/react',
5+
{
6+
runtime: 'automatic',
7+
development: process.env.BABEL_ENV === 'development',
8+
},
9+
],
10+
],
11+
plugins: ['@babel/plugin-transform-modules-commonjs'],
12+
};
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/**
2+
* Copyright (c) Facebook, Inc. and its affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @emails react-core
8+
*/
9+
10+
'use strict';
11+
12+
const path = require('path');
13+
14+
const {ESLint} = require('eslint');
15+
16+
function getESLintInstance(format) {
17+
return new ESLint({
18+
useEslintrc: false,
19+
overrideConfigFile:
20+
__dirname + `../../../scripts/rollup/validate/eslintrc.${format}.js`,
21+
ignore: false,
22+
});
23+
}
24+
25+
const esLints = {
26+
cjs: getESLintInstance('cjs'),
27+
};
28+
29+
// Performs sanity checks on bundles *built* by Rollup.
30+
// Helps catch Rollup regressions.
31+
async function lint(folder) {
32+
console.log(`Linting ` + folder);
33+
const eslint = esLints.cjs;
34+
35+
const results = await eslint.lintFiles([
36+
__dirname + '/' + folder + '/cjs/react-jsx-dev-runtime.development.js',
37+
__dirname + '/' + folder + '/cjs/react-jsx-dev-runtime.production.min.js',
38+
__dirname + '/' + folder + '/cjs/react-jsx-runtime.development.js',
39+
__dirname + '/' + folder + '/cjs/react-jsx-runtime.production.min.js',
40+
]);
41+
if (
42+
results.some(result => result.errorCount > 0 || result.warningCount > 0)
43+
) {
44+
process.exitCode = 1;
45+
console.log(`Failed`);
46+
const formatter = await eslint.loadFormatter('stylish');
47+
const resultText = formatter.format(results);
48+
console.log(resultText);
49+
}
50+
}
51+
52+
async function lintEverything() {
53+
console.log(`Linting known bundles...`);
54+
await lint('react-14');
55+
await lint('react-15');
56+
await lint('react-16');
57+
await lint('react-17');
58+
}
59+
60+
lintEverything().catch(error => {
61+
process.exitCode = 1;
62+
console.error(error);
63+
});
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"dependencies": {
3+
"@babel/plugin-transform-modules-commonjs": "^7.10.4",
4+
"@babel/preset-react": "^7.10.4",
5+
"jest": "^26.5.3"
6+
},
7+
"jest": {
8+
"setupFilesAfterEnv": ["./setupTests.js"]
9+
},
10+
"scripts": {
11+
"install-all": "cd react-14 && yarn && cd ../react-15 && yarn && cd ../react-16 && yarn && cd ../react-17 && yarn && cd ..",
12+
"lint": "node lint-runtimes.js",
13+
"pretest": "yarn install-all && yarn lint",
14+
"test-jsxdev-dev": "BABEL_ENV=development NODE_ENV=development jest",
15+
"test-jsx-dev": "BABEL_ENV=production NODE_ENV=development jest",
16+
"test-jsx-prod": "BABEL_ENV=production NODE_ENV=production jest",
17+
"test": "yarn test-jsxdev-dev && yarn test-jsx-dev && yarn test-jsx-prod"
18+
}
19+
}

0 commit comments

Comments
 (0)