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

npm run link-watch produces "type in ./package.json must be of type 'commonjs' | 'module' (received undefined)" #59

Open
wildseansy opened this issue Dec 31, 2022 · 1 comment
Labels

Comments

@wildseansy
Copy link

wildseansy commented Dec 31, 2022

When running the README.md quick run steps, the package.json doesn't seem to be properly configured.

# Initialize a new plugin (outside of your Sanity studio folder)
npx @sanity/plugin-kit init sanity-plugin-testing-it-out

# Make your plugin linkable, and compile an initial version
cd sanity-plugin-testing-it-out
npm run link-watch

npm run link-watch produces

[error] `type` in `./package.json` must be of type 'commonjs' | 'module' (received undefined)

To fix this

  1. The plugin template package.json needs "type": "module" added
  2. "exports": {
     ".": {
       "types": "./lib/src/index.d.ts",
       "source": "./src/index.ts",
       "import": "./lib/index.esm.js",
       "require": "./lib/index.js", // Update to .cjs
       "default": "./lib/index.esm.js"
     },
     "main": "./lib/index.js", //update to .cjs
@EmilyYond
Copy link

Thank you @wildseansy for this, this is still an issue but this has resolved this error for me. However, I immediately get another error

[error] exports["."]: the `types` condition shouldn't be used as dts files are generated in such a way that both CJS and ESM is supported

I'm not very familiar with how to set up a typescript package, so I'm not sure how to resolve this? Could you give me a hand?

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

No branches or pull requests

3 participants