Codesandbox-client: [Template update] Preact template isn't using preact/compat

Created on 12 Mar 2020  路  7Comments  路  Source: codesandbox/codesandbox-client

馃悰 bug report

Description of the problem. How has this issue affected you? What are you trying to accomplish?

I tried to use react component like react-window in preact sandox which works perfectly fine locally but is not working in codesandbox.

Link to sandbox: preact-template-compat-issue

Root cause

Preact transpiler is currently using preact-compat instead of preact/compat (Required for Preact 10). I think we just need to fix this file https://github.com/codesandbox/codesandbox-client/blob/a616fcf3fd31eb75ee40451fbf9c2beb936b9559/packages/app/src/sandbox/eval/presets/preact-cli/index.js#L20
I will send PR soon after testing.

Your Environment

N/A. This issue is related to preact template

All 7 comments

Exact same code is working fine with preact 8 (because it uses preact-compat). https://codesandbox.io/s/preact-8-template-compat-test-votvs

So we need to ensure that both Preact 8 and 10 sandboxes work after this fix.

We need to use preact/compat only if this module is available. Otherwise alias should fall back to preact-compat. I am not sure how to conditionally check whether a module is installed or not in sandbox like https://github.com/preactjs/preact-cli/blob/4319ff54b7a8ac073d700940d521cf25b84c3276/packages/cli/lib/lib/webpack/webpack-base-config.js#L99

This issue is stale because it has been open many days with no activity. It will be closed soon unless the stale label is removed or a comment is made.

This issue is still there so I think this shouldn't be closed.
@CompuIves can you please guide me how to fix this without breaking preact 8 sandboxes? :)

Hey!

So sorry this is still a thing, just made a PR to fix this

@all-contributors please add @armujahid for bug.

@armujahid

I've put up a pull request to add @armujahid! :tada:

Was this page helpful?
0 / 5 - 0 ratings