diff --git a/.gitignore b/.gitignore index 9aadc15..b856850 100644 --- a/.gitignore +++ b/.gitignore @@ -103,3 +103,5 @@ lib # TernJS port file .tern-port + +web/ diff --git a/build.ts b/build.ts index 189dfa8..ad5b956 100644 --- a/build.ts +++ b/build.ts @@ -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(); \ No newline at end of file diff --git a/package.json b/package.json index 841f110..7f42e17 100644 --- a/package.json +++ b/package.json @@ -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 ", "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", diff --git a/src/blockweave.ts b/src/blockweave.ts index 92b0fb2..d6f76f5 100644 --- a/src/blockweave.ts +++ b/src/blockweave.ts @@ -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; @@ -91,3 +91,5 @@ declare global { Blockweave: typeof Blockweave; } } + +export = Blockweave;