remix icon indicating copy to clipboard operation
remix copied to clipboard

Warning: Top-Level "this" will be replaced with undefined. Remix + CF Pages

Open derpoho opened this issue 3 years ago • 6 comments

What version of Remix are you using?

1.7.0

Steps to Reproduce

Bundle Remix app and start wrangler pages dev

Expected Behavior

no warnings.

Actual Behavior

Warnings while compiling "worker". => This file is considered to be an ECMAScript module because of the "export"

Traceable to this block (or blocks like this) in functions/[[path]].js

// app/components/Wrapper/Document/Document.jsx
var import_jsx_dev_runtime = __toESM(require_jsx_dev_runtime()), Document = ({ children }) => /* @__PURE__ */ (0, import_jsx_dev_runtime.jsxDEV)("html", {
  lang: "en",
  children
}, void 0, !1, {
  fileName: "app/components/Wrapper/Document/Document.jsx",
  lineNumber: 4,
  columnNumber: 36
}, this);

derpoho avatar Sep 07 '22 11:09 derpoho

Addition, relevant package versions:

"@remix-run/cloudflare": "^1.7.0",
"@remix-run/cloudflare-pages": "^1.7.0",
"@remix-run/react": "^1.7.0",
"remix": "^1.7.0",
"@cloudflare/workers-types": "^3.16.0",
"@remix-run/dev": "^1.7.0",
"@remix-run/eslint-config": "^1.7.0",
"wrangler": "^2.0.16",

derpoho avatar Sep 08 '22 08:09 derpoho

I too am experiencing this.

osdiab avatar Sep 09 '22 07:09 osdiab

Me too, there is a way to temporary fix this, but we need to override the esbuild config (which is not allowed natively in Remix): https://github.com/vitejs/vite/issues/8644#issuecomment-115930880

mnismt avatar Sep 12 '22 05:09 mnismt

I started experiencing these errors when I updated a route component to use arrow function syntax (e.g. export default () => { ... }) instead of function keyword syntax (e.g. export default function () { ... }).

BrandonNoad avatar Sep 15 '22 18:09 BrandonNoad

When working on a slower processor, the log spam causes the computer's CPU to max out. I've only found my team can continue working if they're on pretty beefy computers (m1 pro or greater).

This bug makes debugging on slower devices nigh impossible. Likely need to be changing what infra we're deploying to due to this issue.

Acen avatar Sep 20 '22 00:09 Acen

This error starts with @remix-run/cloudflare v1.6.5.

I can also confirm that removing a React component I was using in an MDX file made this warning go away. If I inline the component I was importing, the warning also goes away.

brandonpittman avatar Nov 07 '22 05:11 brandonpittman

I tried to reproduce this locally with Remix 1.19.3 and wrangler 3.6.0 but wasn't able to reproduce the error. Can you please try again with the latest code? Happy to reopen (or file a new issue) if you can provide a reproduction.

Thanks! 🙏

mjackson avatar Aug 24 '23 18:08 mjackson