Skip to content

Commit

Permalink
use automatic jsx compiler that doesn't require react imports
Browse files Browse the repository at this point in the history
  • Loading branch information
psugihara committed Aug 3, 2022
1 parent 5ab2874 commit 9713de0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion babel.config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"presets": [
"@babel/react",
["@babel/react", { "runtime": "automatic" }],
["@babel/preset-typescript", { "isTSX": true, "allExtensions": true }],
"@babel/preset-env"
]
Expand Down
15 changes: 12 additions & 3 deletions packages/cli/src/commands/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,23 @@ export const handler = async (argv: PreviewArgs) => {
require("ts-node").register({
compilerOptions: {
module: "commonjs",
jsx: "react",
jsx: "react-jsx",
moduleResolution: "node",
skipLibCheck: true,
},
});

require("@babel/register")({
presets: ["@babel/react", "@babel/preset-env"],
presets: [
[
"@babel/react",
{
runtime: "automatic",
},
],
"@babel/preset-env",
],
compact: false,
});
}

Expand Down Expand Up @@ -131,7 +140,7 @@ export const handler = async (argv: PreviewArgs) => {
showIntercept(req, res);
} else if (/^\/previews\/.*\.json/.test(req.url)) {
showPreview(req, res);
} else if (/^\/_next/.test(req.url)) {
} else if (/^\/_+next/.test(req.url)) {
noLog = true;
await app.render(req, res, `${pathname}`, query);
} else {
Expand Down
13 changes: 11 additions & 2 deletions packages/cli/src/dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,22 @@ process.env.MM_DEV = 1;
require("ts-node").register({
compilerOptions: {
module: "commonjs",
jsx: "react",
jsx: "react-jsx",
moduleResolution: "node",
skipLibCheck: true,
},
});

require("@babel/register")({
presets: ["@babel/react", "@babel/preset-env"],
presets: [
[
"@babel/react",
{
runtime: "automatic",
},
],
"@babel/preset-env",
],
compact: false,
});
require("./index.ts");

0 comments on commit 9713de0

Please sign in to comment.