How to use bytenode - 2 common examples

To help you get started, we’ve selected a few bytenode examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github patrickmichalina / fusing-angular / src / electron / bytecode-entry.ts View on Github external
readdir(app.getAppPath(), (err, files) => {
  const filename = (files[0].split('/').pop() || '')
  const bytecodePath = join(app.getAppPath(), `/${filename.replace('.js', '')}.jsc`)
  const srcPath = join(app.getAppPath(), `/${filename}`)

  const bytecode = require('bytenode')

  if (existsSync(srcPath)) {
    bytecode.compileFile(srcPath, bytecodePath)
    unlinkSync(srcPath)
    if (process.env.BUILD_BYTECODE) process.exit(0)
  }

  require(bytecodePath)
})
github patrickmichalina / fusing-angular / tools / scripts / bytecode.js View on Github external
fs.readdir(appPath, (err, files) => {
  const sourcefile = files.find(a => a.match(/app.js$/))
  const bytefile = files.find(a => a.match(/app.jsc$/))

  if (err) {
    throw new Error(err)
  }

  if (sourcefile) {
    const srcPath = join(appPath, sourcefile)
    const bytecodePath = join(appPath, sourcefile.replace('.js', '.jsc'))
    bytecode.compileFile(srcPath, bytecodePath)
    fs.unlinkSync(srcPath)
    if (process.env.BUILD_BYTECODE) process.exit(0)
    require(bytecodePath)
  } else if (bytefile) {
    require(join(appPath, bytefile))
  } else {
    throw new Error('No application file')
  }
})

bytenode

A minimalist bytecode compiler for Node.js

MIT
Latest version published 2 months ago

Package Health Score

84 / 100
Full package analysis

Popular bytenode functions