Skip to content
This repository has been archived by the owner on Oct 6, 2023. It is now read-only.

JavaScript node and Browser environment support #8

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,5 @@ lib

# TernJS port file
.tern-port

web/
26 changes: 26 additions & 0 deletions build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,32 @@ const runBuild = async () => {
console.log(e);
process.exit(1)
});

// Build to frontend frameworks
build({
plugins: [nodeBuiltIns()],
entryPoints: ['./src/blockweave.ts'],
minify: false,
bundle: true,
platform: 'browser',
target: ['es2019'],
format: 'esm', // to allow import support
splitting: true,
outdir: './web',
sourcemap: 'external',
define: {
'process.env.NODE_DEBUG': 'false',
'process.env.NODE_ENV': 'production',
'process.env.DEBUG': 'false',
'global': 'window',
'process.cwd': 'String',
'_smartweave_1.LoggerFactory.INST': '{"create": "function() {}"}',
'__filename': 'String',
}
}).catch((e) => {
console.log(e);
process.exit(1);
});
};

runBuild();
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
"name": "blockweave",
"version": "1.0.17",
"main": "dist/blockweave.js",
"browser": "web/blockweave.js",
"types": "dist/blockweave.d.ts",
"repository": "https://github.com/textury/blockweave.git",
"author": "Cedrik <[email protected]>",
"license": "MIT",
"files": [
"dist/**/*"
"dist",
"web"
],
"scripts": {
"prebuild": "rimraf dist",
"prebuild": "rimraf dist && rimraf web",
"build": "tsc && ts-node build.ts",
"format": "prettier --write \"src/**/*.ts\"",
"test": "npm run test:node && npm run test:web",
Expand Down
4 changes: 3 additions & 1 deletion src/blockweave.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import * as blockweaveUtils from './utils/buffer';
import Logging from './utils/logging';
import Blocks from './lib/blocks';

export default class Blockweave {
class Blockweave {
public api: Api;
public wallets: Wallets;
public transactions: Transactions;
Expand Down Expand Up @@ -91,3 +91,5 @@ declare global {
Blockweave: typeof Blockweave;
}
}

export = Blockweave;