JQLEditorForge doesn't work with forge tunnel

I need to add a JQL editor onto a Global page in my Custom UI App.

I found the @atlassianlabs/jql-editor-forge package and tried implementing it following all the docs I found (the ones for both the general and forge jql editor packages, and the forge-jql-editor-custom-ui sample app). However, when accessing the page with the dev tunnel active, the whole page fails to render. In the browser console, I can see the following error:

Uncaught ReferenceError: process is not defined    util.js:109:4
    util chunk-O3GQ4FX7.js:2708
    __require chunk-ROME4SDB.js:11
    assert chunk-O3GQ4FX7.js:3635
    __require chunk-ROME4SDB.js:11
    assert chunk-O3GQ4FX7.js:5015
    __require chunk-ROME4SDB.js:11
    antlr4ts chunk-O3GQ4FX7.js:5722
    __require chunk-ROME4SDB.js:11
    antlr4ts chunk-O3GQ4FX7.js:24200
    __require chunk-ROME4SDB.js:11
    <anonymous> JQLLexer.js:8
    js util.js:109
    __require chunk-ROME4SDB.js:11
    js assertion_error.js:25
    __require chunk-ROME4SDB.js:11
    js assert.js:39
    __require chunk-ROME4SDB.js:11
    js Array2DHashSet.ts:8
    __require chunk-ROME4SDB.js:11
    js ATNDeserializer.ts:9
    __require chunk-ROME4SDB.js:11
    <anonymous> JQLLexer.js:8

However, when I turn off the tunnel and actually deploy the App, both the page and the JQL editor itself work fine.

Does anyone know how to solve this?

EDIT: I should probably mention that I’m using a customized project structure with Vite as bundler for the Custom UI code. I use Vite’s react-swc-ts template as a base, with some modifications to account for my project structure. It hasn’t caused any issues so far, but I have found some clues indicating it could be the culprit while just Googling around for the errors.

EDIT 2: I have figured it out, the problem was indeed with Vite. To solve it, add the following code to your vite.config.ts:

define: {
  "process.env": process.env, // Or {}, using process.env can apparently cause issues in some scenarios
},

Credit for the solution: Uncaught ReferenceError: process is not defined · Issue #1973 · vitejs/vite · GitHub

1 Like