Giter VIP home page Giter VIP logo

Comments (1)

rpaul-stripe avatar rpaul-stripe commented on June 6, 2024

When the language server loads a schema, it literally attempts to import it, so it has to conform with the requirements imposed by the Node.js runtime for imports.

On the first line of your schema, you have something like this: import {...} from "./(components)", which is a directory import that attempts to load an index.ts file, which is not valid in a pure ES module. The schema file itself also has a .js extension, which also prevents it from being loaded as an ES module. After changing the extension to .mjs and removing both the line that imports the React components as well as the component export at the bottom I was able to get it to load successfully in the language server.

In projects that use TypeScript and couple React components with the schema, what I'd recommend is adding a build step of some kind to generate a pure schema output. You can have a TypeScript file somewhere that just imports the schema part of the configuration, and then do a standalone build of that entry point. I typically do this with esbuild in my projects.

I'm going to convert this issue to a discussion, but I will explore some options for exposing schema loading errors and see if there's something that I can do to make these kinds of issues less opaque to the end user. There should be an easy way to see when there is a schema loading exception.

from markdoc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.