https://github.com/dop251/goja_nodejs
Nodejs compatibility library for Goja
https://github.com/dop251/goja_nodejs
Last synced: about 2 months ago
JSON representation
Nodejs compatibility library for Goja
- Host: GitHub
- URL: https://github.com/dop251/goja_nodejs
- Owner: dop251
- License: mit
- Created: 2016-11-11T18:14:31.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2025-04-09T16:30:59.000Z (3 months ago)
- Last Synced: 2025-05-13T11:56:33.093Z (about 2 months ago)
- Language: Go
- Size: 114 KB
- Stars: 380
- Watchers: 11
- Forks: 86
- Open Issues: 20
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Nodejs compatibility library for Goja
====This is a collection of [Goja](https://github.com/dop251/goja) modules that provide nodejs compatibility.
Example:
```go
package mainimport (
"github.com/dop251/goja"
"github.com/dop251/goja_nodejs/require"
)func main() {
registry := new(require.Registry) // this can be shared by multiple runtimesruntime := goja.New()
req := registry.Enable(runtime)runtime.RunString(`
var m = require("./m.js");
m.test();
`)m, err := req.Require("./m.js")
_, _ = m, err
}
```Type Definitions
---Type definitions are published to https://npmjs.com as @dop251/types-goja_nodejs-MODULE.
They only include what's been implemented so far.To make use of them you need to install the appropriate modules and add `node_modules/@dop251` to `typeRoots` in `tsconfig.json`.
I didn't want to add those to DefinitelyTyped partly because I don't think they really belong there,
and partly because I'd like to fully control the release cycle, i.e. publish the modules by an automated CI job and
exactly at the same time as the Go code is released.And the reason for splitting them into different packages is that the modules can be enabled or disabled individually, unlike in nodejs.
More modules will be added. Contributions welcome too.