Skip to content

Commit

Permalink
chore: Cross BSC and Gnfd init
Browse files Browse the repository at this point in the history
  • Loading branch information
rrr523 committed Apr 12, 2024
1 parent c346d6b commit 61476ef
Show file tree
Hide file tree
Showing 9 changed files with 469 additions and 201 deletions.
10 changes: 10 additions & 0 deletions packages/bsc-cross-sdk/config/tsconfig-cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"target": "ES2015",
"module": "ESNext",
"outDir": "../dist/cjs/",
"esModuleInterop": true,
"moduleResolution": "node"
}
}
9 changes: 9 additions & 0 deletions packages/bsc-cross-sdk/config/tsconfig-esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"target": "es2020",
"module": "ES2020",
"outDir": "../dist/esm/",
"moduleResolution": "node"
}
}
10 changes: 10 additions & 0 deletions packages/bsc-cross-sdk/config/tsconfig-test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"target": "ES6",
"module": "CommonJS",
"outDir": "./dist/test",
"esModuleInterop": true,
"moduleResolution": "node"
}
}
38 changes: 38 additions & 0 deletions packages/bsc-cross-sdk/config/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"compilerOptions": {
"lib": [
"es2021",
],
"baseUrl": ".",
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "NodeNext",
"strict": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"declaration": true,
"declarationDir": "../dist/types",
"outDir": "../dist",
"emitDeclarationOnly": false,
"allowUmdGlobalAccess": true,
"allowJs": true,
"resolveJsonModule": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"strictPropertyInitialization": false,
"paths": {
"@/*": [
"../src/*"
]
},
},
"include": [
"../src",
"../types/*.d.ts"
],
"exclude": [
"../node_modules",
"../src/tests"
]
}
82 changes: 82 additions & 0 deletions packages/bsc-cross-sdk/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{
"name": "@bnb-chain/bsc-cross-greenfield-sdk",
"version": "0.0.1",
"description": "bsc cross greenfield sdk",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"types": "./dist/esm/index.d.ts",
"exports": {
".": {
"import": {
"types": "./dist/esm/**.d.ts",
"default": "./dist/esm/index.js"
},
"require": {
"types": "./dist/cjs/types/**.d.ts",
"default": "./dist/cjs/index.js"
}
}
},
"browser": {
"./dist/cjs/index.js": "./dist/cjs/index.js",
"./dist/esm/index.js": "./dist/esm/index.js"
},
"scripts": {
"predev": "rimraf ./dist",
"dev": "rollup -cw",
"prebuild": "rimraf ./dist",
"build": "rollup -c",
"test": "jest --runInBand",
"lint": "prettier --write './src/*.{ts,tsx,js,jsx}' && eslint ./src/ --ext .js,.jsx,.ts,.tsx --fix"
},
"repository": {
"type": "git",
"url": "https://github.com/bnb-chain/greenfield-js-sdk",
"directory": "packages/bsc-cross-sdk"
},
"homepage": "https://github.com/bnb-chain/greenfield-js-sdk/tree/alpha/packages/js-sdk#readme",
"bugs": "https://github.com/bnb-chain/greenfield-js-sdk/issues",
"keywords": [
"bsc",
"greenfiled",
"js-sdk"
],
"author": "",
"license": "GPLv3",
"files": [
"dist",
"types"
],
"publishConfig": {
"registry": "https://registry.npmjs.org/",
"access": "public"
},
"browserslist": {
"production": [
"last 2 chrome version",
"last 2 firefox version",
"last 2 safari version",
"last 2 edge version"
]
},
"dependencies": {
"@bnb-chain/greenfield-cosmos-types": "0.4.0-alpha.31",
"long": "^5.2.1",
"reflect-metadata": "^0.1.13",
"tsyringe": "^4.8.0",
"viem": "^2.9.16"
},
"devDependencies": {
"@jest/globals": "^29.5.0",
"@rollup/plugin-typescript": "^11.1.3",
"@types/jest": "^29.5.1",
"@types/mime": "^3.0.1",
"@types/xml2js": "^0.4.11",
"dotenv": "^16.0.3",
"jest": "^29.5.0",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
"tslib": "^2.5.0",
"typescript": "^4.9.5"
}
}
85 changes: 85 additions & 0 deletions packages/bsc-cross-sdk/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import alias from '@rollup/plugin-alias';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import resolve from '@rollup/plugin-node-resolve';
import nodePolyfills from 'rollup-plugin-polyfill-node';
import typescript from '@rollup/plugin-typescript';
import path from 'path';

import autoExternal from 'rollup-plugin-auto-external';
import pkg from './package.json';
const pathResolve = (p) => path.resolve(__dirname, p);

function resolveExternal() {
return [...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.peerDependencies || {})];
}

export default async () => {
return [
{
input: './src/index.ts',
output: {
dir: './dist/esm',
format: 'esm',
sourcemap: true,
},
external: resolveExternal(),
context: 'window',
treeshake: true,
plugins: [
json({
include: ['src/**'],
}),
// builtins(),
resolve({
exportConditions: ['default', 'module', 'import'],
mainFields: ['module', 'main'],
modulesOnly: true,
preferBuiltins: false,
}),
commonjs({
defaultIsModuleExports: false,
}),
typescript({
tsconfig: './config/tsconfig-esm.json',
declarationDir: './dist/esm',
}),
alias({
entries: {
'@': pathResolve('src'),
},
}),
],
},
{
input: './src/index.ts',
output: {
dir: './dist/cjs',
format: 'cjs',
sourcemap: true,
},
external: resolveExternal(),
plugins: [
json({
include: ['src/**'],
}),
autoExternal(),
nodePolyfills({
include: 'node_modules/**',
}),
commonjs({
ignoreDynamicRequires: true,
}),
typescript({
tsconfig: './config/tsconfig-cjs.json',
declarationDir: './dist/cjs/types',
}),
alias({
entries: {
'@': pathResolve('src'),
},
}),
],
},
];
};
1 change: 1 addition & 0 deletions packages/bsc-cross-sdk/src/Executor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default class Executor {}
1 change: 1 addition & 0 deletions packages/bsc-cross-sdk/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './Executor';
Loading

0 comments on commit 61476ef

Please sign in to comment.