diff --git a/.changeset/build-react-production-mode.md b/.changeset/build-react-production-mode.md new file mode 100644 index 00000000..cb766b0b --- /dev/null +++ b/.changeset/build-react-production-mode.md @@ -0,0 +1,5 @@ +--- +"playground-cli": patch +--- + +Build the compiled CLI binary with `process.env.NODE_ENV=production` so React ships in production mode. This removes the spurious React development warnings (e.g. "Cannot update a component while rendering a different component") that surfaced during `playground deploy`, and makes React faster and smaller in the shipped binary. diff --git a/.github/workflows/dev-release.yml b/.github/workflows/dev-release.yml index 3115668f..2b936446 100644 --- a/.github/workflows/dev-release.yml +++ b/.github/workflows/dev-release.yml @@ -27,10 +27,10 @@ jobs: - name: Compile CLI binaries run: | - bun build --compile --target=bun-linux-x64 src/index.ts --outfile dot-linux-x64 - bun build --compile --target=bun-linux-arm64 src/index.ts --outfile dot-linux-arm64 - bun build --compile --target=bun-darwin-x64 src/index.ts --outfile dot-darwin-x64 - bun build --compile --target=bun-darwin-arm64 src/index.ts --outfile dot-darwin-arm64 + bun build --compile --define process.env.NODE_ENV='"production"' --target=bun-linux-x64 src/index.ts --outfile dot-linux-x64 + bun build --compile --define process.env.NODE_ENV='"production"' --target=bun-linux-arm64 src/index.ts --outfile dot-linux-arm64 + bun build --compile --define process.env.NODE_ENV='"production"' --target=bun-darwin-x64 src/index.ts --outfile dot-darwin-x64 + bun build --compile --define process.env.NODE_ENV='"production"' --target=bun-darwin-arm64 src/index.ts --outfile dot-darwin-arm64 - name: Ensure gh CLI run: type gh >/dev/null 2>&1 || (sudo apt-get update -qq && sudo apt-get install -y gh) diff --git a/.github/workflows/release-contract-manifest.yml b/.github/workflows/release-contract-manifest.yml index 96d0e90f..9c7b4052 100644 --- a/.github/workflows/release-contract-manifest.yml +++ b/.github/workflows/release-contract-manifest.yml @@ -130,10 +130,10 @@ jobs: - name: Compile CLI binaries if: steps.manifest.outputs.changed == 'true' || steps.current_release.outputs.missing == 'true' run: | - bun build --compile --target=bun-linux-x64 src/index.ts --outfile dot-linux-x64 - bun build --compile --target=bun-linux-arm64 src/index.ts --outfile dot-linux-arm64 - bun build --compile --target=bun-darwin-x64 src/index.ts --outfile dot-darwin-x64 - bun build --compile --target=bun-darwin-arm64 src/index.ts --outfile dot-darwin-arm64 + bun build --compile --define process.env.NODE_ENV='"production"' --target=bun-linux-x64 src/index.ts --outfile dot-linux-x64 + bun build --compile --define process.env.NODE_ENV='"production"' --target=bun-linux-arm64 src/index.ts --outfile dot-linux-arm64 + bun build --compile --define process.env.NODE_ENV='"production"' --target=bun-darwin-x64 src/index.ts --outfile dot-darwin-x64 + bun build --compile --define process.env.NODE_ENV='"production"' --target=bun-darwin-arm64 src/index.ts --outfile dot-darwin-arm64 - name: Commit release changes if: steps.manifest.outputs.changed == 'true' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 39597ca7..f24b0500 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -59,10 +59,10 @@ jobs: - name: Compile CLI binaries if: steps.changesets.outputs.found == 'true' run: | - bun build --compile --target=bun-linux-x64 src/index.ts --outfile dot-linux-x64 - bun build --compile --target=bun-linux-arm64 src/index.ts --outfile dot-linux-arm64 - bun build --compile --target=bun-darwin-x64 src/index.ts --outfile dot-darwin-x64 - bun build --compile --target=bun-darwin-arm64 src/index.ts --outfile dot-darwin-arm64 + bun build --compile --define process.env.NODE_ENV='"production"' --target=bun-linux-x64 src/index.ts --outfile dot-linux-x64 + bun build --compile --define process.env.NODE_ENV='"production"' --target=bun-linux-arm64 src/index.ts --outfile dot-linux-arm64 + bun build --compile --define process.env.NODE_ENV='"production"' --target=bun-darwin-x64 src/index.ts --outfile dot-darwin-x64 + bun build --compile --define process.env.NODE_ENV='"production"' --target=bun-darwin-arm64 src/index.ts --outfile dot-darwin-arm64 - name: Generate release tag if: steps.changesets.outputs.found == 'true' diff --git a/package.json b/package.json index 99183c6b..68ba41a1 100644 --- a/package.json +++ b/package.json @@ -15,8 +15,8 @@ "format:check": "biome format .", "lint:license": "./scripts/check-license-headers.sh", "typecheck": "tsc --noEmit", - "build": "bun build --compile src/index.ts --outfile ./dist/playground", - "cli:install": "bun build --compile src/index.ts --outfile ~/.polkadot/bin/playground && ln -sf ~/.polkadot/bin/playground ~/.polkadot/bin/pg", + "build": "bun build --compile --define process.env.NODE_ENV='\"production\"' src/index.ts --outfile ./dist/playground", + "cli:install": "bun build --compile --define process.env.NODE_ENV='\"production\"' src/index.ts --outfile ~/.polkadot/bin/playground && ln -sf ~/.polkadot/bin/playground ~/.polkadot/bin/pg", "test": "vitest run", "test:watch": "vitest", "test:e2e": "vitest run --config e2e/vitest.config.ts",