Skip to content
This repository has been archived by the owner on Dec 2, 2022. It is now read-only.

How import module from Node? #50

Open
gretmn102 opened this issue Aug 13, 2020 · 4 comments
Open

How import module from Node? #50

gretmn102 opened this issue Aug 13, 2020 · 4 comments

Comments

@gretmn102
Copy link

Hello, friends. Help me please, because I don't know what to do. I tried:

type [<Import("Disposable","vscode")>] Disposable(callOnDispose: JsFunc) =
    static member from([<ParamArray>] disposableLikes: obj[]): Disposable = failwith "JS only"
    member __.dispose(): obj = failwith "JS only"

But npm run build given me error:

ERROR in ./src/Fable.Import.VSCode.fs
Module not found: Error: Can't resolve 'vscode' in 'E:\Project\fable2-samples\nodejsbundle\src'
 @ ./src/Fable.Import.VSCode.fs 8:14-31
 @ ./src/App.fs
 @ ./src/App.fsproj

Here is my code cloned from your sample repository. What am I doing wrong?

@alfonsogarciacaro
Copy link
Member

Did you run "npm install"?

@gretmn102
Copy link
Author

Yes, of course
output.txt

@alfonsogarciacaro
Copy link
Member

Hmm, I did try your code and got the same error, but I'm not sure what's the reason. I guess the vscode module needs to be resolved differently. To be honest, I don't know what Fable.Import.VSCode.fs is doing in that example. You should be able to remove it. Are you interested in writing a VS Code plugin with Fable? I think at one point we had an example/tutorial of doing that but it's been a while and I don't know f they've changed the API.

@gretmn102
Copy link
Author

gretmn102 commented Aug 15, 2020

Are you interested in writing a VS Code plugin with Fable?

Yes. It's very very old, and I wonted upgrade it. It uses this principle of import, and I naively wanted to repeat it. But it is also logical that somehow I can import modules from Node into Fable. It works in old versions, but how to do it in the new one? Thanks for your help. Fable is the best thing what I ever seen 👍

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

No branches or pull requests

2 participants