https://github.com/nervosnetwork/moleculec-es
ECMAScript plugin for the molecule serialization system
https://github.com/nervosnetwork/moleculec-es
Last synced: over 1 year ago
JSON representation
ECMAScript plugin for the molecule serialization system
- Host: GitHub
- URL: https://github.com/nervosnetwork/moleculec-es
- Owner: nervosnetwork
- License: mit
- Created: 2020-03-11T01:44:31.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-06-03T06:34:23.000Z (about 2 years ago)
- Last Synced: 2025-04-12T01:55:07.956Z (over 1 year ago)
- Language: Go
- Size: 36.1 KB
- Stars: 8
- Watchers: 3
- Forks: 9
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# moleculec-es
ECMAScript plugin for the molecule serialization system
# Usage
First, download precompiled binary from [releases](https://github.com/xxuejie/moleculec-es/releases) page, and put the binary in our PATH. You could also clone and build the project from source. The only dependency is Golang here.
```
$ cargo install moleculec
$ moleculec --language - --schema-file "your schema file" --format json > /tmp/schema.json
$ moleculec-es -inputFile /tmp/schema.json -outputFile "your JS file"
```
Generated file from this project follows latest ECMAScript standard, it is also orgnaized as an ECMAScript module to allow for tree shaking.
## Options
```
Usage of moleculec-es:
-generateTypeScriptDefinition
True to generate TypeScript definition
-hasBigInt
True to generate BigInt related functions
-inputFile string
Input file to use
-outputFile string
Output file to generate, use '-' to print to stdout (default "-")
```
## ESM to CommonJS
Since moleculec-es generates ECMAScript modules, if you are using TS (< 4.5) or NodeJS(without ESM support) then you can convert ESM to CommonJS first. For example
```
npm i @babel/core @babel/cli @babel/plugin-transform-modules-commonjs
./node_modules/.bin/babel --plugins @babel/plugin-transform-modules-commonjs generated.js
```