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
4 changes: 3 additions & 1 deletion packages/studio-plugin/src/types/CliArgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ export interface CliArgs {
root?: string;
// 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
// This option is always provided by the cac package, and we only use it to
// configure Studio to run in React Strict Mode for internal development by
// using `-- strict`.
"--"?: string[];
}
2 changes: 2 additions & 0 deletions packages/studio/bin/studio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ cli
.option("--port <port>", "[number] port to run studio")
.option("--root <directory>", `[string] path to the root directory`)
.action((options: CliArgs) => {
const useStrictMode: boolean = options["--"]?.includes("strict") ?? false;
spawnSync(
"npx",
[
Expand All @@ -32,6 +33,7 @@ cli
env: {
...process.env,
YEXT_STUDIO_ARGS: JSON.stringify(options),
VITE_STUDIO_STRICT: String(useStrictMode),
nmanu1 marked this conversation as resolved.
Show resolved Hide resolved
},
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