Skip to content

Discrepency between prod and dev build on vite - Uncaught ReferenceError: process is not defined #627

@AlexMili

Description

@AlexMili

Summary

Hello,

I tried installing snack-sdk on a fresh Vite (6.2.1 and 5.4.X) + React (19.0.0 and 18.0.0) install.
So far, I just added the snack-sdk lib and instanciated a simple snack instance. The bug arrise when I run npm run dev and go to the browser. There I get errors at runtime saying that assert is not define. When the corresponding lib is installed, a new one is thrown saying that process is not defined. The problem with is that installing the process package doesn't fix anything.

Note that npm run build is working as expected since the process var is provided directly by node.

Snack SDK should be working on a fresh vite/react install in dev mode without further configuration. This look like a bug to me but maybe I am missing something.

What platform(s) does this occur on?

Web

SDK Version

6.4.0

Reproducible demo or steps to reproduce from a blank project

Create a dummy react project using vite.

npm create vite@latest

npm install snack-sdk

Use this default code instanciating a simple snack instance in App.tsx:

import { useState } from 'react'
import reactLogo from './assets/react.svg'
import viteLogo from '/vite.svg'
import './App.css'
import { Snack } from "snack-sdk";

function App() {
  const [count, setCount] = useState(0)

  const snack = new Snack({
    dependencies: {
      'expo-font': { version: '8.2.1' }
    }
  });

  return (
    <>
      <div>
        <a href="https://vite.dev" target="_blank">
          <img src={viteLogo} className="logo" alt="Vite logo" />
        </a>
        <a href="https://react.dev" target="_blank">
          <img src={reactLogo} className="logo react" alt="React logo" />
        </a>
      </div>
      <h1>Vite + React</h1>
      <div className="card">
        <button onClick={() => setCount((count) => count + 1)}>
          count is {count}
        </button>
        <p>
          Edit <code>src/App.tsx</code> and save to test HMR
        </p>
      </div>
      <p className="read-the-docs">
        Click on the Vite and React logos to learn more
      </p>
    </>
  )
}

export default App

Then run

npm run dev

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions