microsoft / TypeChat

TypeChat is a library that makes it easy to build natural language interfaces using types.
https://microsoft.github.io/TypeChat/
MIT License
8.25k stars 391 forks source link

typechat does not take effect in vscode extension #251

Open 7neves opened 5 months ago

7neves commented 5 months ago

There is no problem using typechat during the development process, but after packaging it through vsce package, it does not take effect.

7neves commented 5 months ago

When I use

import { createTypeScriptJsonValidator } from "typechat/ts"

When imported, it will become

const ts1 = require('typechat/ts');

As a result, the package cannot be imported I manually modified the directory structure of typechat in node_moudles, moved the validate.js file in the typechat/dist/ts directory to the typechat/dist directory, and then used import { createTypeScriptJsonValidator } from "typechat" The problem is solved. Is there a problem with the configuration of tsconfig? Or is there something wrong somewhere else?

DanielRosenwasser commented 5 months ago

I'm not exactly sure what is going wrong (I'm not seeing what error you're hitting) - however, if you are using typechat/ts, my guess is that you need to find a way to bring the original source text of your .ts schema around as an asset. Depending on your bundler, there are different ways to achieve this. In many bundlers (like Vite), you can add ?raw to the path to import the contents as a string.

import schema from './schema.ts?raw';