question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Rollup build options for bytenode

See original GitHub issue

Would be lovely to have more information of how the build process works as for me to understand how to include rollup options/plugins and manipulate the output process.

Specifically I’m interested on adding rollup-plugin-bytenode within the build process but couldn’t figure out how to do it exactly.

// vite.config.js:

import bytenode from 'rollup-plugin-bytenode';
const path = require('path');
const srcPath = path.resolve(__dirname, 'src');

module.exports = {
  port: 4000,
  open: false, // do not open the browser as we use electron
  alias: {
    // setup aliases for cleaner imports
    '/~/': srcPath
  },
  optimizeDeps: {
    exclude: [
      'path',
      'electron-window-state',
      'electron-context-menu'
    ]
  },
  rollupInputOptions: {
    input: 'src/main.js',
    output: [
      {
        file: 'dist/main.js',
        format: 'cjs'
      }
    ],
    plugins: [bytenode()]
  }
};

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:19 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
underfincommented, Jul 14, 2020

Hope this help you out.Other you can just call bytenode compiled js files instead of rollup and rollup-plugin-bytenode.

plugins: [{
    transforms: [
      {
        test({ path }) {
          return path.endsWith('a.js') //matched your want compiled files
        },
        async transform({ id, code }) {
          const bundle = await rollup({
            input: id,
            output: [
              {
                file: id,
                format: 'cjs'
              }
            ],
            plugins: [
              bytenode()
            ]
          });

          await bundle.write({ file: id, format: "cjs" });

          return { code: code }
        }
      }
    ]
   }]
1reaction
Aferzcommented, Jul 9, 2020

@gianniskarmas I understand now. I think you could accomplish it by writing this in your vite.config.js:

module.exports = {
  outDir: 'dist',

  rollupInputOptions: {
    input: 'main.js'
  },

  rollupOutputOptions: {
    format: 'cjs',
    entryFileNames: `[name].js`, // Default is `[name].[hash].js`,
    plugins: [
      bytenode()
    ]
  },
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

rollup-plugin-bytenode - npm Package Health Analysis - Snyk
Rollup plugin for compile javascript code to byte code For more information about how to use this package see README.
Read more >
rollup.js
To build different bundles with the same input, you supply an array of output options for each input: // rollup.config.js (building more than...
Read more >
Bytenode NPM | npm.io
A minimalist bytecode compiler for Node.js. This tool truly compiles your JavaScript code into V8 bytecode, so that you can protect your source...
Read more >
How to Bundle JavaScript With Rollup — Step-by-Step Tutorial
To make this actually do stuff, we need to update rollup.config.js . Inside, we import the Babel plugin, then add it to a...
Read more >
How to Compile Node.js Code Using Bytenode? - HackerNoon
jsc of your JavaScript files. You can also bundle all your .js files using Browserify, then compile that single file into .jsc. Check...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found