Skip to content
Permalink
Browse files

remove wasm import from chain libs

  • Loading branch information
PeterBenc committed Dec 3, 2019
1 parent 9410a69 commit d196c5028183066a2f014b3e8b01a380b128566c
Showing with 27 additions and 0 deletions.
  1. +24 −0 server/helpers/removeChainLibsWasmImport.js
  2. +3 −0 server/index.js
@@ -0,0 +1,24 @@
const fs = require('fs')
const wasmImportString = "import * as wasm from './js_chain_libs_bg.wasm';"
const chainLibsPath = 'node_modules/@emurgo/js-chain-libs/js_chain_libs.js'

const removeChainLibsWasmImport = () => {
fs.readFile(chainLibsPath, 'utf8', (err, data) => {
if (err) throw err
const splitArray = data.toString().split('\n')
if (splitArray[0] === wasmImportString) {
splitArray.splice(splitArray.indexOf(wasmImportString), 1)
const result = splitArray.join('\n')
fs.writeFile(chainLibsPath, result, (err) => {
if (err) throw err
})
// eslint-disable-next-line no-console
console.log('Removed wasm import from js-chain-libs.')
} else {
// eslint-disable-next-line no-console
console.log('Wasm import not found.')
}
})
}

module.exports = removeChainLibsWasmImport
@@ -4,11 +4,14 @@ const compression = require('compression')
const fs = require('fs')
const https = require('https')
const {frontendConfig, backendConfig} = require('./helpers/loadConfig')
const removeChainLibsWasmImport = require('./helpers/removeChainLibsWasmImport')

let app = express()

express.static.mime.types.wasm = 'application/wasm'

removeChainLibsWasmImport()

app.use(bodyParser.json())
app.use(compression())

0 comments on commit d196c50

Please sign in to comment.
You can’t perform that action at this time.