Imports from a package's lib folder no longer resolve
Detect
@rjsf/<package>/libor@rjsf/<package>/lib/<file>.jsin your code.- Node throws
ERR_PACKAGE_PATH_NOT_EXPORTEDfor one of those imports, or your bundler fails to resolve it. - Type checker under
node16,nodenextorbundlerresolution:Cannot find module '@rjsf/<package>/lib/<file>.js' or its corresponding type declarations. - A tool that reads
@rjsf/snapshot-tests/package.json.
Change
An import of a path the package's exports doesn't list now fails in Node, in every bundler and in each TypeScript resolution that reads exports. A tool that ignores exports, such as webpack 4 or TypeScript's node10 resolution, still finds the file, but nothing there is part of the public API.
These still resolve:
- each package's root, such as
@rjsf/coreor@rjsf/utils; @rjsf/core/markdown,@rjsf/core/testing,@rjsf/core/rjsf.cssand@rjsf/core/rjsf-theme.css;@rjsf/validator-ajv8/compileSchemaValidatorsand@rjsf/validator-ata/compileSchemaValidators, see compileSchemaValidators is imported from its own subpath.
Most deep imports name something the package root exports too, so import it from there:
-import SchemaField from '@rjsf/core/lib/components/fields/SchemaField.js';
-import { getUiOptions } from '@rjsf/utils/lib/getUiOptions.js';
+import { SchemaField } from '@rjsf/core';
+import { getUiOptions } from '@rjsf/utils';
@rjsf/core now exports GridType, Operators, LAYOUT_GRID_OPTION, LAYOUT_GRID_UI_OPTION and the GridProps, GridSchemaType, LayoutGridSchemaType and LayoutGridFieldProps types, which only lib/components/fields/LayoutGridField.js used to export. @rjsf/utils now exports getMatchingPatternProperties(), which only lib/schema/retrieveSchema.js used to export. Label from lib/components/templates/FieldTemplate/Label.js is exported as FieldLabel, see core's Label is exported as FieldLabel.
These have no import path any more:
@rjsf/core'sLayoutGridFieldandLayoutMultiSchemaFieldhelpers, such asgetSchemaDetailsForField()andcomputeEnumOptions().@rjsf/core'sLOOKUP_REGEX, whichLayoutGridField.jsexported besideLAYOUT_GRID_OPTION.@rjsf/snapshot-tests/package.json. A tool that needs it can read the file fromnode_modules.- A theme's individual components, see a theme's individual widgets and templates have no import path.
@rjsf/utils' default-state internals andcalculateIndexScore(), see getDefaultFormState internals and calculateIndexScore have no import path.- Every other module that a package's root doesn't export.
Verify
- No code imports an
@rjsf/*path outside the list above. - Your build, tests and type checker resolve every
@rjsf/*import.
Also read:
- Core's Label is exported as FieldLabel and takes its class as className
- compileSchemaValidators is imported from its own subpath
- A theme's individual widgets and templates have no import path
- getDefaultFormState internals and calculateIndexScore have no import path
- Every RJSF package ships only ESM, and the dist builds are gone