Skip to content
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

Packages are using tsc-compiled files instead of ESM #3958

Closed
4 tasks done
sarenji opened this issue Nov 14, 2023 · 2 comments · Fixed by #3968
Closed
4 tasks done

Packages are using tsc-compiled files instead of ESM #3958

sarenji opened this issue Nov 14, 2023 · 2 comments · Fixed by #3968

Comments

@sarenji
Copy link

sarenji commented Nov 14, 2023

Prerequisites

What theme are you using?

core

Version

5.x

Current Behavior

We're trying to upgrade @rjsf/core, @rjsf/utils and @rjsf/validator-ajv8 from 5.8.2 to 5.14.1. However, we run into a bundle error when importing @rjsf/utils with ESM, because Yarn cannot resolve tslib:

    .yarn/__virtual__/@rjsf-utils-virtual-221548ebb0/0/cache/@rjsf-utils-npm-5.14.1-5c751cec25-68b230fb55.zip/node_modules/@rjsf/utils/lib/schema/getMatchingOption.js:1:23:
      1 │ import { __rest } from "tslib";

Expected Behavior

Ideally we should be able to import @rjsf/utils without error.

I dug into it a little bit and discovered that @rjsf/utils@5.14.1 compiles its files into .js using tsc. The package then sets lib/index.js as the module field., which eventually points to a file that has tslib injected.

On the other hand, version 5.8.2 uses the compiled ESM file instead.

Yarn protects us from ghost dependencies, which is why we get the error.

I believe @rjsf could either:

  1. Revert the change to the module field from dist/utils.esm.js to lib/index.js.
  2. OR add tslib to the package's dependencies, if you want to continue using TypeScript-compiled files.

Steps To Reproduce

Import @rjsf/utils with Yarn as the package manager.

Example repro: https://codesandbox.io/s/condescending-platform-q8wtk8?file=/src/index.js

Environment

- OS: Mac OS X 13.6
- Node: 18.15.0
- Yarn: 4.0.0-rc.50

Anything else?

No response

@sarenji sarenji added bug needs triage Initial label given, to be assigned correct labels and assigned labels Nov 14, 2023
@heath-freenome heath-freenome added help wanted and removed needs triage Initial label given, to be assigned correct labels and assigned labels Nov 17, 2023
@heath-freenome
Copy link
Member

heath-freenome commented Nov 17, 2023

@zxbodya Since you made the change to switch to tsc, do you have an idea on how to fix this?

@zxbodya
Copy link
Contributor

zxbodya commented Nov 20, 2023

good catch, we indeed have incorrect configuration for tsc output -- created a PR updating it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants