Skip to content

Commit

Permalink
Enable automatic jsx runtime transform
Browse files Browse the repository at this point in the history
Enable automatic jsx runtime transform via @babel/preset-react. See: https://reactjs.org/blog/2020/09/22/introducing-the-new-jsx-transform.html

Also fix tests that had NODE_ENV override that's not compatible w/ the dev server.
  • Loading branch information
shYkiSto authored and fusionjs-sync-bot[bot] committed Apr 4, 2022
1 parent 172262f commit 50f3263
Show file tree
Hide file tree
Showing 19 changed files with 33 additions and 50 deletions.
7 changes: 2 additions & 5 deletions fusion-cli-tests/test/e2e/duplicate-translations/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@ const {cmd, start} = require('../utils.js');
const dir = path.resolve(__dirname, './fixture');

test('promise instrumentation deduplicates translations', async () => {
var env = Object.create(process.env);
env.NODE_ENV = 'production';
await cmd(`build --dir=${dir}`);

await cmd(`build --dir=${dir}`, {env});

const {proc, port} = await start(`--dir=${dir}`, {env, cwd: dir});
const {proc, port} = await start(`--dir=${dir}`, {cwd: dir});
const browser = await puppeteer.launch({
args: ['--no-sandbox', '--disable-setuid-sandbox'],
});
Expand Down
7 changes: 1 addition & 6 deletions fusion-cli-tests/test/e2e/split/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,12 +196,7 @@ describe('split chunk ids kept in sync on both client and server', () => {
test('`fusion build` CHUNK_IDS stay in sync on both server and client after change', async () => {
async function buildAndStartServer() {
await cmd(`build --dir=${dir} --modernBuildOnly`);
const {proc, port} = await start(`--dir=${dir}`, {
env: {
...process.env,
NODE_ENV: 'production',
},
});
const {proc, port} = await start(`--dir=${dir}`);

return {
stop() {
Expand Down
3 changes: 2 additions & 1 deletion fusion-cli/build/get-babel-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,10 @@ module.exports = function getBabelConfig(opts /*: BabelConfigOpts */) {
config.presets.push([
require.resolve('@babel/preset-react'),
{
development: dev,
pragma: jsx.pragma,
pragmaFrag: jsx.pragmaFrag,
development: dev,
runtime: jsx.pragma || jsx.pragmaFrag ? 'classic' : 'automatic',
},
]);
if (fusionTransforms) {
Expand Down
4 changes: 2 additions & 2 deletions fusion-plugin-apollo/.babelrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"presets": ["@babel/preset-react"],
"presets": [["@babel/preset-react", { "runtime": "automatic" }]],
"plugins": ["@babel/plugin-transform-flow-strip-types"],
"env": {
"test": {
"plugins": ["@babel/plugin-transform-flow-strip-types"],
"presets": [
"@babel/preset-react",
["@babel/preset-react", { "runtime": "automatic" }],
["@babel/preset-env", { "targets": { "node": "current" } }]
]
}
Expand Down
4 changes: 2 additions & 2 deletions fusion-plugin-connected-react-router/.babelrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"presets": ["@babel/preset-react"],
"presets": [["@babel/preset-react", { "runtime": "automatic" }]],
"plugins": ["@babel/plugin-transform-flow-strip-types"],
"env": {
"test": {
"plugins": ["@babel/plugin-transform-flow-strip-types"],
"presets": [
"@babel/preset-react",
["@babel/preset-react", { "runtime": "automatic" }],
["@babel/preset-env", { "targets": { "node": "current" } }]
]
}
Expand Down
4 changes: 1 addition & 3 deletions fusion-plugin-connected-react-router/test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,17 @@ module.exports.Runtime = class Runtime {
}
async start() {
const cwd = this.fixturePath;
const env = Object.assign({}, process.env, {NODE_ENV: 'production'});

const [port] = await Promise.all([
getPort(),
execFile('fusion', ['build'], {cwd, env}),
execFile('fusion', ['build'], {cwd}),
]);
this.port = port;
this.url = `http://localhost:${this.port}`;

this.server = spawn('fusion', ['start', `--port=${port}`], {
stdio: 'inherit',
cwd,
env,
});

this.browser = await puppeteer.launch({
Expand Down
4 changes: 2 additions & 2 deletions fusion-plugin-csrf-protection/.babelrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"presets": ["@babel/preset-react"],
"presets": [["@babel/preset-react", { "runtime": "automatic" }]],
"plugins": ["@babel/plugin-transform-flow-strip-types"],
"env": {
"test": {
"plugins": ["@babel/plugin-transform-flow-strip-types"],
"presets": [
"@babel/preset-react",
["@babel/preset-react", { "runtime": "automatic" }],
["@babel/preset-env", { "targets": { "node": "current" } }]
]
}
Expand Down
4 changes: 2 additions & 2 deletions fusion-plugin-font-loader-react/.babelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"presets": ["@babel/preset-react"],
"presets": [["@babel/preset-react", { "runtime": "automatic" }]],
"plugins": [
"@babel/plugin-transform-flow-strip-types",
"@babel/plugin-proposal-class-properties"
Expand All @@ -11,7 +11,7 @@
"@babel/plugin-proposal-class-properties"
],
"presets": [
"@babel/preset-react",
["@babel/preset-react", { "runtime": "automatic" }],
["@babel/preset-env", { "targets": { "node": "current" } }]
]
}
Expand Down
4 changes: 2 additions & 2 deletions fusion-plugin-i18n-react/.babelrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"presets": ["@babel/preset-react"],
"presets": [["@babel/preset-react", { "runtime": "automatic" }]],
"plugins": ["@babel/plugin-transform-flow-strip-types"],
"env": {
"test": {
"plugins": ["@babel/plugin-transform-flow-strip-types"],
"presets": [
"@babel/preset-react",
["@babel/preset-react", { "runtime": "automatic" }],
["@babel/preset-env", { "targets": { "node": "current" } }]
]
}
Expand Down
4 changes: 2 additions & 2 deletions fusion-plugin-introspect/.babelrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"presets": ["@babel/preset-react"],
"presets": [["@babel/preset-react", { "runtime": "automatic" }]],
"plugins": ["@babel/plugin-transform-flow-strip-types"],
"env": {
"test": {
"plugins": ["@babel/plugin-transform-flow-strip-types"],
"presets": [
"@babel/preset-react",
["@babel/preset-react", { "runtime": "automatic" }],
["@babel/preset-env", { "targets": { "node": "current" } }]
]
}
Expand Down
4 changes: 2 additions & 2 deletions fusion-plugin-react-helmet-async/.babelrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"presets": ["@babel/preset-react"],
"presets": [["@babel/preset-react", { "runtime": "automatic" }]],
"plugins": ["@babel/plugin-transform-flow-strip-types"],
"env": {
"test": {
"plugins": ["@babel/plugin-transform-flow-strip-types"],
"presets": [
"@babel/preset-react",
["@babel/preset-react", { "runtime": "automatic" }],
["@babel/preset-env", { "targets": { "node": "current" } }]
]
}
Expand Down
4 changes: 2 additions & 2 deletions fusion-plugin-react-redux/.babelrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"presets": ["@babel/preset-react"],
"presets": [["@babel/preset-react", { "runtime": "automatic" }]],
"plugins": ["@babel/plugin-transform-flow-strip-types"],
"env": {
"test": {
"plugins": ["@babel/plugin-transform-flow-strip-types"],
"presets": [
"@babel/preset-react",
["@babel/preset-react", { "runtime": "automatic" }],
["@babel/preset-env", { "targets": { "node": "current" } }]
]
}
Expand Down
4 changes: 2 additions & 2 deletions fusion-plugin-react-router/.babelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"presets": ["@babel/preset-react"],
"presets": [["@babel/preset-react", { "runtime": "automatic" }]],
"plugins": [
"@babel/plugin-transform-flow-strip-types",
"@babel/plugin-proposal-class-properties"
Expand All @@ -11,7 +11,7 @@
"@babel/plugin-proposal-class-properties"
],
"presets": [
"@babel/preset-react",
["@babel/preset-react", { "runtime": "automatic" }],
["@babel/preset-env", { "targets": { "node": "current" } }]
]
}
Expand Down
4 changes: 1 addition & 3 deletions fusion-plugin-rpc-redux-react/test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,17 @@ export const Runtime = class Runtime {
}
async start() {
const cwd = this.fixturePath;
const env = Object.assign({}, process.env, {NODE_ENV: 'production'});

const [port] = await Promise.all([
getPort(),
execFile('fusion', ['build'], {cwd, env}),
execFile('fusion', ['build'], {cwd}),
]);
this.port = port;
this.url = `http://localhost:${this.port}`;

this.server = spawn('fusion', ['start', `--port=${port}`], {
stdio: 'inherit',
cwd,
env,
});

this.browser = await puppeteer.launch({
Expand Down
4 changes: 2 additions & 2 deletions fusion-plugin-styletron-react/.babelrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"presets": ["@babel/preset-react"],
"presets": [["@babel/preset-react", { "runtime": "automatic" }]],
"plugins": ["@babel/plugin-transform-flow-strip-types"],
"env": {
"test": {
"plugins": ["@babel/plugin-transform-flow-strip-types"],
"presets": [
"@babel/preset-react",
["@babel/preset-react", { "runtime": "automatic" }],
["@babel/preset-env", { "targets": { "node": "current" } }]
]
}
Expand Down
5 changes: 1 addition & 4 deletions fusion-plugin-styletron-react/test/basic/e2e.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,14 @@ const spawn = child_process.spawn;
const fixture = __dirname;

test('basic rendering and hydration works', async () => {
const env = Object.assign({}, process.env, {NODE_ENV: 'production'});

const [port] = await Promise.all([
getPort(),
execFile('fusion', ['build'], {cwd: fixture, env}),
execFile('fusion', ['build'], {cwd: fixture}),
]);

const server = spawn('fusion', ['start', `--port=${port}`], {
stdio: 'inherit',
cwd: fixture,
env,
});

const browser = await puppeteer.launch({
Expand Down
5 changes: 1 addition & 4 deletions fusion-plugin-styletron-react/test/prefix-token/e2e.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,14 @@ const spawn = child_process.spawn;
const fixture = __dirname;

test('token prefix', async () => {
const env = Object.assign({}, process.env, {NODE_ENV: 'production'});

const [port] = await Promise.all([
getPort(),
execFile('fusion', ['build'], {cwd: fixture, env}),
execFile('fusion', ['build'], {cwd: fixture}),
]);

const server = spawn('fusion', ['start', `--port=${port}`], {
stdio: 'inherit',
cwd: fixture,
env,
});

const browser = await puppeteer.launch({
Expand Down
4 changes: 2 additions & 2 deletions fusion-plugin-web-app-manifest/.babelrc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"presets": ["@babel/preset-react"],
"presets": [["@babel/preset-react", { "runtime": "automatic" }]],
"plugins": ["@babel/plugin-transform-flow-strip-types"],
"env": {
"test": {
"plugins": ["@babel/plugin-transform-flow-strip-types"],
"presets": [
"@babel/preset-react",
["@babel/preset-react", { "runtime": "automatic" }],
["@babel/preset-env", { "targets": { "node": "current" } }]
]
}
Expand Down
4 changes: 2 additions & 2 deletions fusion-react/.babelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"presets": ["@babel/preset-react"],
"presets": [["@babel/preset-react", { "runtime": "automatic" }]],
"plugins": [
"@babel/plugin-transform-flow-strip-types",
"@babel/plugin-proposal-class-properties"
Expand All @@ -11,7 +11,7 @@
"@babel/plugin-proposal-class-properties"
],
"presets": [
"@babel/preset-react",
["@babel/preset-react", { "runtime": "automatic" }],
["@babel/preset-env", { "targets": { "node": "current" } }]
]
}
Expand Down

0 comments on commit 50f3263

Please sign in to comment.