From 49209a19580df3de4067f6aed90d20148cc579d6 Mon Sep 17 00:00:00 2001 From: erick Date: Thu, 31 Jul 2025 04:03:02 -0300 Subject: [PATCH 1/2] correcting polyfills --- apps/playground/frontend/package.json | 3 +++ apps/playground/frontend/src/global.ts | 10 ++++++++++ apps/playground/frontend/src/main.tsx | 1 + 3 files changed, 14 insertions(+) create mode 100644 apps/playground/frontend/src/global.ts diff --git a/apps/playground/frontend/package.json b/apps/playground/frontend/package.json index bc65efa..487d207 100644 --- a/apps/playground/frontend/package.json +++ b/apps/playground/frontend/package.json @@ -25,6 +25,7 @@ "tailwindcss": "^4.1.11" }, "devDependencies": { + "@esbuild-plugins/node-globals-polyfill": "^0.2.3", "@eslint/js": "^9.30.1", "@originjs/vite-plugin-commonjs": "^1.0.3", "@rolldown/pluginutils": "^1.0.0-beta.29", @@ -34,10 +35,12 @@ "@types/react": "^19.1.8", "@types/react-dom": "^19.1.6", "@vitejs/plugin-react": "^4.7.0", + "buffer": "^6.0.3", "eslint": "^9.30.1", "eslint-plugin-react-hooks": "^5.2.0", "eslint-plugin-react-refresh": "^0.4.20", "globals": "^16.3.0", + "rollup-plugin-node-polyfills": "^0.2.1", "tw-animate-css": "^1.3.6", "typescript": "~5.8.3", "typescript-eslint": "^8.35.1", diff --git a/apps/playground/frontend/src/global.ts b/apps/playground/frontend/src/global.ts new file mode 100644 index 0000000..586c357 --- /dev/null +++ b/apps/playground/frontend/src/global.ts @@ -0,0 +1,10 @@ +import { Buffer } from 'buffer'; + +// @ts-expect-error +globalThis.process = { + env: { + NODE_ENV: import.meta.env.MODE, // Map `MODE` to `process.env.NODE_ENV`. + }, +}; + +globalThis.Buffer = Buffer; \ No newline at end of file diff --git a/apps/playground/frontend/src/main.tsx b/apps/playground/frontend/src/main.tsx index 6f4ac9b..8090697 100644 --- a/apps/playground/frontend/src/main.tsx +++ b/apps/playground/frontend/src/main.tsx @@ -2,6 +2,7 @@ import { StrictMode } from 'react' import { createRoot } from 'react-dom/client' import App from './App.tsx' import './index.css' +import '@/global.ts' createRoot(document.getElementById('root')!).render( From a8ee2cf258a45c811b0f4ea05cfd4d512cca44e4 Mon Sep 17 00:00:00 2001 From: erick Date: Thu, 31 Jul 2025 06:19:56 -0300 Subject: [PATCH 2/2] correct lint config --- apps/docs/.eslintrc.json | 13 +++++++++++++ apps/docs/package.json | 3 ++- apps/playground/frontend/src/global.ts | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 apps/docs/.eslintrc.json diff --git a/apps/docs/.eslintrc.json b/apps/docs/.eslintrc.json new file mode 100644 index 0000000..a1428e7 --- /dev/null +++ b/apps/docs/.eslintrc.json @@ -0,0 +1,13 @@ +{ + "extends": ["next/core-web-vitals"], + "ignorePatterns": [ + "node_modules/", + ".next/", + "out/" + ], + "rules": { + "import/no-anonymous-default-export": "off", + "@typescript-eslint/no-unused-vars": ["warn", { "argsIgnorePattern": "^_" }], + "@typescript-eslint/no-unused-expressions": ["error", { "allowShortCircuit": true, "allowTernary": true }] + } +} diff --git a/apps/docs/package.json b/apps/docs/package.json index 636a21b..b84abb5 100644 --- a/apps/docs/package.json +++ b/apps/docs/package.json @@ -5,7 +5,8 @@ "version": "1.0.0", "scripts": { "dev": "next dev", - "build:apps": "next build" + "build:apps": "next build", + "lint": "eslint 'src/**/*.{js,jsx,ts,tsx}'" }, "dependencies": { "next": "^14.1.1", diff --git a/apps/playground/frontend/src/global.ts b/apps/playground/frontend/src/global.ts index 586c357..75cef6b 100644 --- a/apps/playground/frontend/src/global.ts +++ b/apps/playground/frontend/src/global.ts @@ -1,6 +1,6 @@ import { Buffer } from 'buffer'; -// @ts-expect-error +// @ts-expect-error - We're adding process.env to globalThis for compatibility with Node.js modules globalThis.process = { env: { NODE_ENV: import.meta.env.MODE, // Map `MODE` to `process.env.NODE_ENV`.