Skip to content

Commit

Permalink
remove wasm import from chain libs
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterBenc committed Dec 3, 2019
1 parent 9410a69 commit d196c50
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
24 changes: 24 additions & 0 deletions server/helpers/removeChainLibsWasmImport.js
Original file line number Original file line Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions server/index.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@ const compression = require('compression')
const fs = require('fs') const fs = require('fs')
const https = require('https') const https = require('https')
const {frontendConfig, backendConfig} = require('./helpers/loadConfig') const {frontendConfig, backendConfig} = require('./helpers/loadConfig')
const removeChainLibsWasmImport = require('./helpers/removeChainLibsWasmImport')


let app = express() let app = express()


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


removeChainLibsWasmImport()

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


Expand Down

0 comments on commit d196c50

Please sign in to comment.