sandpack icon indicating copy to clipboard operation
sandpack copied to clipboard

Vite template not working with specific dependency

Open YousefED opened this issue 1 year ago • 0 comments

Bug report

Packages affected

  • [x] sandpack-client
  • [ ] sandpack-react

Description of the problem

I try to create a sandpack example with a depencency for a library I'm working on. It doesn't work with the vite-react-ts template, unless I manually click the "refresh" button

What steps can we take to reproduce the problem?

Go to this example on your website: https://sandpack.codesandbox.io/docs/getting-started/usage#npm-dependencies

Change the code to the following:

import { Sandpack } from "@codesandbox/sandpack-react";

export default function App() {
  return (
    <Sandpack
      template="react-ts"
      customSetup={{ 
        dependencies: { 
          "@blocknote/react": "latest" 
        }
      }}
      files={{
        "/App.js": `import * as bn from '@blocknote/react' 

export default function App() {
  return JSON.stringify(bn)
}`
      }}
    />
  )
};
  • Notice that the output works and shows some data of the imported package.
  • Now, set template to template="vite-react-ts"
  • The preview page stays empty
  • When you click the sandpack refresh button, the correct content loads

YousefED avatar Dec 11 '23 10:12 YousefED