wallabyjs / quokka

Repository for Quokka.js questions and issues
https://quokkajs.com
1.18k stars 31 forks source link

ReferenceError: require is not defined  #954

Closed mann-david closed 6 months ago

mann-david commented 6 months ago

Issue description or question

Trying a "simple" test to see how quokka works and getting the error in the Title. Tried with and without a Snap in the file. I would expect to see output either in the console or live in Quokka, but I get an error and the code won't run at all.

Is this issue related to Quokka not outputting the expected results of your code?: Yes/No NO

Sample code

import { merge, interval } from 'rxjs';

{
  {
    const one$ = interval(1500);
    const two$ = interval(1000);
    const merged$ = merge(one$, two$);
    merged$.subscribe((z) => console.log(z));
  }
}

Sample repository link

n/a

Quokka.js Console Output

​Quokka PRO {⚡} 'rxjs merge.ts' (node: v18.19.1, babel: v7.20.12, plugins: auto-detect:create-react-app, jsdom-quokka-plugin)​​​​

ReferenceError: require is not defined 
    at file:///C:/path/to/FE/quokkaTemp/rxjs%20merge.ts?session=zpdr9:5:22 
    at file:///C:/path/to/FE/quokkaTemp/rxjs%20merge.ts?session=zpdr9:23:3 
    at ModuleJob.run (node:internal/modules/esm/module_job:195:25) 
    at ModuleLoader.import (node:internal/modules/esm/loader:336:24) 
    at importModuleDynamicallyWrapper (node:internal/vm/module:429:15) 
  ​​​​​at ​​​​​​./quokkaTemp/rxjs%20merge.ts:5​
  ​​​​​at ​​​​​​./quokkaTemp/rxjs%20merge.ts:23​

Code editor version

Visual Studio Code v1.90.0

OS name and version

Windows 11

smcenlly commented 6 months ago

This seems to be working for us.

Could you please try downloading this sample repo and then install dependencies with npm install and see if rxjs merge.ts works for you?

The code should run, but you won't see inline values, only Quokka Console Output because the program never terminates.

image

I suspect there's something specific to your project that may be misconfigured or else not supported by Quokka. You should be able to compare our sample repo with your repo to work it out. Alternatively, if you can provide us with a sample that doesn't work as you're seeing, we can take a look for you to help you work it out.

mann-david commented 6 months ago

Thanks for the quick reply. Confirmed that it is some issue in my project.