Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default to Running Studio Without Strict Mode #426

Merged
merged 11 commits into from
Oct 31, 2023
2 changes: 1 addition & 1 deletion apps/test-site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"tailwindcss": "^3.3.4"
},
"scripts": {
"dev": "studio",
"dev": "studio --strict",
"localData": "yext pages generate-test-data -a",
"start": "craco start",
"build-test-site": "craco build"
Expand Down
2 changes: 2 additions & 0 deletions packages/studio-plugin/src/types/CliArgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ export interface CliArgs {
port?: string;
// The project root for studio.
root?: string;
// Whether or not to run Studio in React Strict Mode
strict?: boolean;
// Any arguments present after double dashes when invoking studio, e.g.
// `npx studio -- args like these` will result in ['args', 'like', 'these']
// Not currently used for anything but always provided by the cac package
Expand Down
5 changes: 4 additions & 1 deletion packages/studio/bin/studio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ cli
.command("", "start dev server")
.option("--port <port>", "[number] port to run studio")
.option("--root <directory>", `[string] path to the root directory`)
.option("--strict", "Runs Studio in React Strict Mode")
.action((options: CliArgs) => {
const { strict, ...studioArgs } = options;
spawnSync(
"npx",
[
Expand All @@ -31,7 +33,8 @@ cli
stdio: ["ignore", "inherit", "inherit"],
env: {
...process.env,
YEXT_STUDIO_ARGS: JSON.stringify(options),
YEXT_STUDIO_ARGS: JSON.stringify(studioArgs),
VITE_STUDIO_STRICT: String(strict),
},
shell: true,
}
Expand Down
12 changes: 9 additions & 3 deletions packages/studio/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@ if (import.meta.hot) {
void hotReloadGitData(hmrPayload);
});
}
const WrappedApp =
import.meta.env.VITE_STUDIO_STRICT === "true" ? (
<React.StrictMode>
<AppWithLazyLoading />
</React.StrictMode>
) : (
<AppWithLazyLoading />
);

ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
<React.StrictMode>
<AppWithLazyLoading />
</React.StrictMode>
WrappedApp
);
Loading