adobe / adobe/spectrum-web-components

[Bug]: Uncaught ReferenceError: `process` is not defined in `Base.ts`

Open Beginner friendly
#6,242 2 comments 0 reactions 0 assignees View on GitHub
bug needs-jira-ticket
Dominant language
TypeScript
Stars
1.5k
Forks
262
Avg merge
3d 10h
Merged PRs (30d)
68

Description

### Code of conduct

- [x] I agree to follow this project's code of conduct.

### Impacted component(s)

"@spectrum-web-components/shared": "^1.11.2", "@spectrum-web-components/split-view": "^1.11.2",

### Library version

1.11.2

### Expected behavior

The library should load correctly in a browser environment.

### Actual behavior

"`Uncaught ReferenceError`: `process` is not defined" is thrown in the browser, because such instance only exists in a nodejs-like environment.

This breaks downstream dependents like https://github.com/sass/sass-site/issues/1588

### Screenshots

_No response_

### What browsers are you seeing the problem in?

_No response_

### How can we reproduce this issue?

1. Clone https://github.com/sass/sass-site
2. `npm install`
3. `npm run serve`
4. Visit http://localhost:8080/playground/

### Sample code or abstract reproduction which illustrates the problem

```js
if (process.env.NODE_ENV === 'development') {
```

This should have been:

```js
if (typeof process !== 'undefined' && process.env.NODE_ENV === 'development') {
```

Note: `process?.env` does not work because `process` is not defined as an identifier.

### Severity

SEV 2

### Logs taken while reproducing problem

```
Uncaught ReferenceError: process is not defined
at Base.js:195:1
at playground.ts:417:1
```

### Would you like to track this issue in Jira?

- [ ] Yes, please tell me the ticket number!

Contributor guide

Open the contributing guide

Research direction

Start with Base.ts, then reproduce the browser failure through the sass-site playground at playground.ts:417 using npm install and npm run serve. Verify that the library loads in the browser without the ReferenceError and that the development-environment check remains safe when process is unavailable.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.