Comments (1)
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)
- Tokenizer crashes when a closing tag is wrapped in a link
- Document the Markdoc language server on markdoc.dev
- Update tokenizerOptions API in @markdoc/next.js to support parse and tokenize options
- Add support for Next.js page `metadata` export
- Add support for background `revalidate` export when using Next.js app-router
- Suggestion: Add VueJS and other mentioned examples and general support
- Add rowspan and colspan support to table headings.
- formatter: Support customization of link style preference HOT 1
- Markdoc Language Server does not respond to config
- Markdoc Language Server: HOT 9
- Code block followed by a string adds a <space> into the code block instead of outside HOT 1
- next.js plugin is missing types HOT 1
- appDir Configuration No Longer Working in Next.js 13.5 with markdoc/next.js HOT 4
- Fetching markdoc props inside the next app router HOT 1
- Allow metadata export to be optional in markdoc/next.js
- html-nodejs example: document undefined error in Windows system, but same works in macOS
- `\n` in string attribute causes syntax error HOT 2
- allowIndentation docs are outdated HOT 3
- Table's width attribute throws type error on strings HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from markdoc.