feat: web bundle (#394)

This commit is contained in:
Asia
2023-04-17 15:37:54 +02:00
committed by GitHub
parent f1b4b3da73
commit eb87d5a0f3
2 changed files with 11 additions and 21 deletions

View File

@@ -1,6 +1,7 @@
const { build } = require('esbuild');
const rimraf = require('rimraf');
const fs = require('fs');
const plugin = require('node-stdlib-browser/helpers/esbuild/plugin');
const stdLibBrowser = require('node-stdlib-browser');
const clean = async () => {
return new Promise((resolve) => {
@@ -17,11 +18,13 @@ const runBuild = async () => {
platform: 'browser',
target: ['esnext'],
format: 'esm',
globalName: 'warp'
globalName: 'warp',
inject: [require.resolve('node-stdlib-browser/helpers/esbuild/shim')],
plugins: [plugin(stdLibBrowser)]
};
console.log('Building web bundle esm.');
const result = await build({
await build({
...buildConfig,
minify: true,
// metafile: true,
@@ -31,11 +34,6 @@ const runBuild = async () => {
process.exit(1);
});
/*fs.writeFileSync('metadata.json', JSON.stringify({
inputs: result.metafile.inputs,
outputs: result.metafile.outputs
}));*/
console.log('Building web bundle iife.');
await build({
...buildConfig,

View File

@@ -4,8 +4,10 @@
"description": "An implementation of the SmartWeave smart contract protocol.",
"types": "./lib/types/index.d.ts",
"main": "./lib/cjs/index.js",
"browser": {
"./lib/cjs/index.js": "./bundles/web.bundle.min.js"
},
"exports": {
"./web": "./bundles/web.bundle.min.js",
"./mjs": "./lib/mjs/index.js",
".": "./lib/cjs/index.js"
},
@@ -118,7 +120,8 @@
"typescript": "^4.9.5",
"warp-contracts-plugin-deploy": "^1.0.3",
"warp-contracts-plugin-vm2": "1.0.0",
"ws": "^8.11.0"
"ws": "^8.11.0",
"node-stdlib-browser": "^1.2.0"
},
"resolutions": {
"bn.js": "5.2.1",
@@ -129,16 +132,5 @@
"bn.js": "5.2.1",
"bignumber.js": "9.1.1",
"buffer-pipe": "0.0.5"
},
"browser": {
"fs": false,
"path": false,
"crypto": false,
"archiver": false,
"stream-buffers": false,
"constants": false,
"os": false,
"process": false,
"url": false
}
}