feat: bugfix for : Problem Temporarily Solved, Not Fix: Error building my application #1414 (#1567)

* V1

## [Unreleased] - 2025-03-28

###  Fixed
- Fixed deployment errors on Cloudflare Pages caused by:
  - Missing or outdated `compatibility_date` and `compatibility_flags` in `wrangler.toml`
  - Use of Node.js built-ins (`crypto`, `stream`) in functions without proper polyfilling
  - Invalid Wrangler CLI options (`--log-level`) used during deployment
  - Type error when importing the Remix server build

### 🛠 Changed
- `wrangler.toml` updated:
  ```toml
  name = "bolt"
  compatibility_date = "2025-03-28"
  compatibility_flags = ["nodejs_compat"]
  pages_build_output_dir = "./build/client"
  send_metrics = false
  ```
- `functions/[[path]].ts` updated:
  ```ts
  import type { ServerBuild } from '@remix-run/cloudflare';
  import { createPagesFunctionHandler } from '@remix-run/cloudflare-pages';
  import * as serverBuild from '../build/server';

  export const onRequest = createPagesFunctionHandler({
    build: serverBuild as unknown as ServerBuild,
  });
  ```

### 🚀 Deployment
- Successful deployment to:
  - Preview: https://979e2ca9.bolt-55b.pages.dev
  - Production: https://main.bolt-55b.pages.dev

* V1

## [Unreleased] - 2025-03-28

###  Fixed
- Fixed deployment errors on Cloudflare Pages caused by:
  - Missing or outdated `compatibility_date` and `compatibility_flags` in `wrangler.toml`
  - Use of Node.js built-ins (`crypto`, `stream`) in functions without proper polyfilling
  - Invalid Wrangler CLI options (`--log-level`) used during deployment
  - Type error when importing the Remix server build

### 🛠 Changed
- `wrangler.toml` updated:
  ```toml
  name = "bolt"
  compatibility_date = "2025-03-28"
  compatibility_flags = ["nodejs_compat"]
  pages_build_output_dir = "./build/client"
  send_metrics = false
  ```
- `functions/[[path]].ts` updated:
  ```ts
  import type { ServerBuild } from '@remix-run/cloudflare';
  import { createPagesFunctionHandler } from '@remix-run/cloudflare-pages';
  import * as serverBuild from '../build/server';

  export const onRequest = createPagesFunctionHandler({
    build: serverBuild as unknown as ServerBuild,
  });
  ```

### 🚀 Deployment
- Successful deployment to:
  - Preview: https://979e2ca9.bolt-55b.pages.dev
  - Production: https://main.bolt-55b.pages.dev

* feat: small bugfix
This commit is contained in:
Stijnus 2025-03-29 10:26:42 +01:00 committed by GitHub
parent 1364d4a503
commit 47444970e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 659 additions and 204 deletions

8
.gitignore vendored
View File

@ -44,3 +44,11 @@ changelogUI.md
docs/instructions/Roadmap.md docs/instructions/Roadmap.md
.cursorrules .cursorrules
*.md *.md
<<<<<<< Updated upstream
=======
.qodo
exponent.txt
<<<<<<< Updated upstream
>>>>>>> Stashed changes
=======
>>>>>>> Stashed changes

View File

@ -1,9 +1,12 @@
import type { ServerBuild } from '@remix-run/cloudflare'; import type { ServerBuild } from '@remix-run/cloudflare';
import { createPagesFunctionHandler } from '@remix-run/cloudflare-pages'; import { createPagesFunctionHandler } from '@remix-run/cloudflare-pages';
// @ts-ignore because the server build file is generated by `remix vite:build` export const onRequest: PagesFunction = async (context) => {
import * as serverBuild from '../build/server'; const serverBuild = (await import('../build/server')) as unknown as ServerBuild;
export const onRequest = createPagesFunctionHandler({ const handler = createPagesFunctionHandler({
build: serverBuild as unknown as ServerBuild, build: serverBuild,
}); });
return handler(context);
};

View File

@ -170,11 +170,12 @@
"@types/path-browserify": "^1.0.3", "@types/path-browserify": "^1.0.3",
"@types/react": "^18.3.12", "@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1", "@types/react-dom": "^18.3.1",
"@vitejs/plugin-react": "^4.3.4",
"concurrently": "^8.2.2", "concurrently": "^8.2.2",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"crypto-browserify": "^3.12.1",
"electron": "^33.2.0", "electron": "^33.2.0",
"electron-builder": "^25.1.8", "electron-builder": "^25.1.8",
"@vitejs/plugin-react": "^4.3.4",
"fast-glob": "^3.3.2", "fast-glob": "^3.3.2",
"husky": "9.1.7", "husky": "9.1.7",
"is-ci": "^3.0.1", "is-ci": "^3.0.1",
@ -184,6 +185,7 @@
"prettier": "^3.4.1", "prettier": "^3.4.1",
"rimraf": "^4.4.1", "rimraf": "^4.4.1",
"sass-embedded": "^1.81.0", "sass-embedded": "^1.81.0",
"stream-browserify": "^3.0.0",
"typescript": "^5.7.2", "typescript": "^5.7.2",
"unified": "^11.0.5", "unified": "^11.0.5",
"unocss": "^0.61.9", "unocss": "^0.61.9",
@ -192,7 +194,7 @@
"vite-plugin-optimize-css-modules": "^1.1.0", "vite-plugin-optimize-css-modules": "^1.1.0",
"vite-tsconfig-paths": "^4.3.2", "vite-tsconfig-paths": "^4.3.2",
"vitest": "^2.1.7", "vitest": "^2.1.7",
"wrangler": "^3.91.0" "wrangler": "^4.5.1"
}, },
"resolutions": { "resolutions": {
"@typescript-eslint/utils": "^8.0.0-alpha.30" "@typescript-eslint/utils": "^8.0.0-alpha.30"

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,6 @@ import { join } from 'path';
dotenv.config(); dotenv.config();
// Get detailed git info with fallbacks
const getGitInfo = () => { const getGitInfo = () => {
try { try {
return { return {
@ -40,7 +39,6 @@ const getGitInfo = () => {
} }
}; };
// Read package.json with detailed dependency info
const getPackageJson = () => { const getPackageJson = () => {
try { try {
const pkgPath = join(process.cwd(), 'package.json'); const pkgPath = join(process.cwd(), 'package.json');
@ -89,7 +87,6 @@ export default defineConfig((config) => {
__PKG_DEV_DEPENDENCIES: JSON.stringify(pkg.devDependencies), __PKG_DEV_DEPENDENCIES: JSON.stringify(pkg.devDependencies),
__PKG_PEER_DEPENDENCIES: JSON.stringify(pkg.peerDependencies), __PKG_PEER_DEPENDENCIES: JSON.stringify(pkg.peerDependencies),
__PKG_OPTIONAL_DEPENDENCIES: JSON.stringify(pkg.optionalDependencies), __PKG_OPTIONAL_DEPENDENCIES: JSON.stringify(pkg.optionalDependencies),
// Define global values
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV), 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
}, },
build: { build: {
@ -113,18 +110,19 @@ export default defineConfig((config) => {
resolve: { resolve: {
alias: { alias: {
buffer: 'vite-plugin-node-polyfills/polyfills/buffer', buffer: 'vite-plugin-node-polyfills/polyfills/buffer',
crypto: 'crypto-browserify',
stream: 'stream-browserify',
}, },
}, },
plugins: [ plugins: [
nodePolyfills({ nodePolyfills({
include: ['buffer', 'process', 'util', 'stream'], include: ['buffer', 'process', 'util', 'stream', 'crypto'],
globals: { globals: {
Buffer: true, Buffer: true,
process: true, process: true,
global: true, global: true,
}, },
protocolImports: true, protocolImports: true,
// Exclude Node.js modules that shouldn't be polyfilled in Cloudflare
exclude: ['child_process', 'fs', 'path'], exclude: ['child_process', 'fs', 'path'],
}), }),
{ {
@ -136,6 +134,8 @@ export default defineConfig((config) => {
map: null, map: null,
}; };
} }
return null;
}, },
}, },
config.mode !== 'test' && remixCloudflareDevProxy(), config.mode !== 'test' && remixCloudflareDevProxy(),

View File

@ -1,6 +1,6 @@
#:schema node_modules/wrangler/config-schema.json #:schema node_modules/wrangler/config-schema.json
name = "bolt" name = "bolt"
compatibility_flags = ["nodejs_compat"] compatibility_flags = ["nodejs_compat"]
compatibility_date = "2024-07-01" compatibility_date = "2025-03-28"
pages_build_output_dir = "./build/client" pages_build_output_dir = "./build/client"
send_metrics = false send_metrics = false