Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

Error "Code generation from strings disallowed" #1268

Closed
PierBover opened this issue May 11, 2020 · 9 comments
Closed

Error "Code generation from strings disallowed" #1268

PierBover opened this issue May 11, 2020 · 9 comments
Labels
bug Something isn't working

Comments

@PierBover
Copy link

馃悰 Bug Report

Reporting this as suggested by @EverlastingBugstopper : #1047 (comment)

When running Webpack with mode: "development" wrangler throws the error:

EvalError: Code generation from strings disallowed for this context

The solution is to disable devtools this in the config:

devtool: 'none',
mode: 'development'

I assume the error is thrown because Webpack is using eval() with the default dev tool option from what I read in this other issue:

cloudflare/workers-webpack-example#1

Steps to reproduce

Use a custom Webpack config with mode: "development".

@EverlastingBugstopper EverlastingBugstopper changed the title [dev] Error "Code generation from strings disallowed" Error "Code generation from strings disallowed" May 11, 2020
@EverlastingBugstopper EverlastingBugstopper added the bug Something isn't working label May 11, 2020
@EverlastingBugstopper
Copy link
Contributor

Thanks for filing - to be clear, this only happens with mode: "development", correct? I'm sure the reason for this is because the Workers runtime does not allow the usage of eval and I bet that webpack's production mode either removes eval from its generated code, or the library you're using has a conditional on dev/prod that removes eval usage.

@xtuc do you think it's worth explicitly adding devtool: none to our default webpack config or should we document it some other way? If it's not necessary in production, should we add devtool: none to the default config if we implement #1084?

@PierBover
Copy link
Author

this only happens with mode: "development", correct?

In my case yes.

@xtuc
Copy link
Member

xtuc commented May 11, 2020

webpack production mode doesn't emit eval by default, but you can also configure that in devtool. none might not be a good default because source-map support implies to set it to inline-source-map. However, I think defending against devtool that we know will generate invalid code for worker would be useful.

I need to look into the dev things...

@stale
Copy link

stale bot commented Jul 11, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jul 11, 2020
@stale
Copy link

stale bot commented Jul 18, 2020

This issue has been automatically closed because it has not had recent activity. You may re-open the issue if it is still relevant.

@mehmetcansahin
Copy link

Hi, this bug is still ongoing. Is there a solution for this?

@willin
Copy link

willin commented Jan 16, 2022

image

@willin
Copy link

willin commented Feb 11, 2022

EvalError: Code generation from strings disallowed for this context
    at Function (<anonymous>)
    at o (/Users/v0/Projects/remix-i18n/documents/node_modules/frenchkiss/dist/esm/frenchkiss.js:6:706)
    at g (/Users/v0/Projects/remix-i18n/documents/node_modules/frenchkiss/dist/esm/frenchkiss.js:6:1389)
    at Object.b (/Users/v0/Projects/remix-i18n/documents/node_modules/frenchkiss/dist/esm/frenchkiss.js:6:1439)
    at Index (/Users/v0/Projects/remix-i18n/documents/app/routes/$.tsx:63:18)
    at processChild (/Users/v0/Projects/remix-i18n/documents/node_modules/react-dom/cjs/react-dom-server.browser.development.js:3352:14)
    at resolve (/Users/v0/Projects/remix-i18n/documents/node_modules/react-dom/cjs/react-dom-server.browser.development.js:3269:5)
    at ReactDOMServerRenderer2.render (/Users/v0/Projects/remix-i18n/documents/node_modules/react-dom/cjs/react-dom-server.browser.development.js:3752:22)
    at ReactDOMServerRenderer2.read (/Users/v0/Projects/remix-i18n/documents/node_modules/react-dom/cjs/react-dom-server.browser.development.js:3689:29)
    at renderToString2 (/Users/v0/Projects/remix-i18n/documents/node_modules/react-dom/cjs/react-dom-server.browser.development.js:4297:27)

@delivey
Copy link

delivey commented Jul 10, 2023

Still facing the issue. Mode is not development, it's not set.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants