feat: web bundle (#394)
This commit is contained in:
14
bundle.js
14
bundle.js
@@ -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,
|
||||
|
||||
18
package.json
18
package.json
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user