Skip to content

Fixed #4564 by checking process type #4569

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/playground/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default defineConfig({
'@rjsf/semantic-ui': path.resolve(__dirname, '../semantic-ui/src'),
'@rjsf/shadcn': path.resolve(__dirname, '../shadcn/src'),
// We want to pick up the browser version of the utils
'@rjsf/utils': path.resolve(__dirname, '../utils/src/indexBrowser'),
'@rjsf/utils': path.resolve(__dirname, '../utils/src'),
'@rjsf/validator-ajv8': path.resolve(__dirname, '../validator-ajv8/src'),
'@rjsf/daisyui': path.resolve(__dirname, '../daisyui/src'),
},
Expand Down
6 changes: 1 addition & 5 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"main": "dist/index.js",
"module": "lib/index.js",
"typings": "lib/index.d.ts",
"browser": "dist/indexBrowser.js",
"type": "module",
"description": "Utility functions for @rjsf/core",
"exports": {
Expand Down Expand Up @@ -46,13 +45,10 @@
"scripts": {
"compileReplacer": "tsc -p tsconfig.replacer.json && move-file lodashReplacer.js lodashReplacer.cjs",
"build:ts": "npm run compileReplacer && rimraf ./lib && tsc -b tsconfig.build.json && tsc-alias -p tsconfig.build.json",
"build:esm-browser": "esbuild ./src/indexBrowser.ts --bundle --outfile=dist/utils-browser.esm.js --sourcemap --packages=external --format=esm",
"build:cjs-browser": "esbuild ./src/indexBrowser.ts --bundle --outfile=dist/indexBrowser.js --sourcemap --packages=external --format=cjs",
"build:umd-browser": "rollup dist/utils-browser.esm.js --format=umd --file=dist/utils-browser.umd.js --name=@rjsf/utils",
"build:cjs": "esbuild ./src/index.ts --bundle --outfile=dist/index.js --sourcemap --packages=external --format=cjs",
"build:esm": "esbuild ./src/index.ts --bundle --outfile=dist/utils.esm.js --sourcemap --packages=external --format=esm",
"build:umd": "rollup dist/utils.esm.js --format=umd --file=dist/utils.umd.js --name=@rjsf/utils",
"build": "npm run build:ts && npm run build:cjs && npm run build:cjs-browser && npm run build:esm && npm run build:esm-browser && npm run build:umd && npm run build:umd-browser",
"build": "npm run build:ts && npm run build:cjs && npm run build:esm && npm run build:umd",
"cs-check": "prettier -l \"{src,test}/**/*.ts?(x)\"",
"cs-format": "prettier \"{src,test}/**/*.ts?(x)\" --write",
"lint": "eslint src test",
Expand Down
10 changes: 2 additions & 8 deletions packages/utils/src/getTestIds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@ import get from 'lodash/get';

import { TestIdShape } from './types';

/** Returns an empty object for use on the browser since we'll never use test ids there.
*/
export function getTestIdsBrowser(): TestIdShape {
return {};
}

/** Returns an object of test IDs that can only be used in test mode. If the function is called in a test environment
* (`NODE_ENV === 'test'`, this is set by jest) then a Proxy object will be returned. If a key within the returned
* object is accessed, if the value already exists the object will return that value, otherwise it will create that key
Expand All @@ -27,8 +21,8 @@ export function getTestIdsBrowser(): TestIdShape {
export default function getTestIds(): TestIdShape {
// For some reason, even though process.env contains the value of `test` for NODE_ENV, accessing it directly returns
// 'development'. Using `get()` does, in fact, return test so sticking with it
if (get(process, 'env.NODE_ENV') !== 'test') {
return getTestIdsBrowser();
if (typeof process === 'undefined' || get(process, 'env.NODE_ENV') !== 'test') {
return {};
}

const ids = new Map();
Expand Down
144 changes: 0 additions & 144 deletions packages/utils/src/indexBrowser.ts

This file was deleted.