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

Outdated "@sanity/schema" Dep Produces Invalid Code #59

Closed
matthewborgman opened this issue Aug 1, 2023 · 0 comments · Fixed by #60
Closed

Outdated "@sanity/schema" Dep Produces Invalid Code #59

matthewborgman opened this issue Aug 1, 2023 · 0 comments · Fixed by #60

Comments

@matthewborgman
Copy link
Contributor

Hi.

I'm attempting to bundle "sanity-naive-html-serializer" with some application code, but the currently-pinned version of the "@sanity/schema" dependency produces invalid code that causes the whole thing to fail.

Specifically, the last line of the following code in "@sanity/schema/lib/_exports/index.cjs.mjs":

import cjs from './index.js';

export const Schema = cjs.Schema;
export const default = cjs.default;

default is a reserved word and as a result is not allowed as a variable declaration name.

Note that no other exports from the dependency (e.g. "index.js" or "index.esm.js") have this problem.

How to Reproduce

  1. Clone the repo
  2. npm install
  3. Open "sanity-naive-html-serializer/node_modules/@sanity/schema/lib/_exports/index.cjs.mjs"
  4. Note the above-mentioned assignment to the default variable

How to Resolve

  1. Update the "@sanity/schema" dependency to a newer version (e.g. 3.14.4) in "package.json"*
  2. npm install
  3. Open "sanity-naive-html-serializer/node_modules/@sanity/schema/lib/_exports/index.cjs.mjs"
  4. Note the following code is produced:
import cjs from './index.js';

export const Schema = cjs.Schema;

export default cjs.default;

Notes

  • sanity-io/sanity@25dcc57 seems directly related to this change and it's tagged in v3.3.0
  • changing the "@sanity/schema" version to anything other than v3.3.1 in the dependencies, even v3.3.0, seems to produce valid code. I've tried v3.3.0, v3.5.0, and v3.14.4 and received the same results...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant