OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Omit the Buffer shim for the browser version in Webpack

  • Thread starter Thread starter fedd
  • Start date Start date
F

fedd

Guest
I'm trying to use the Level database abstraction and the IndexedDB-based Level-down for the browser variant of my app. It converts everything in a byte array, as stated in the documentation:

Like other implementations of abstract-level, browser-level has first-class support of binary keys and values, using either Uint8Array or Buffer. In order to sort string and binary keys the same way as other databases, browser-level internally converts data to a Uint8Array before passing them to IndexedDB. If you have no need to work with Buffer keys or values, you can choose to omit the buffer shim from a JavaScript bundle (through configuration of Webpack, Browserify or other bundlers).

I'm having hard time debugging my app as I can't browse the database when everything is binary.

How do I tell Webpack 5.91.0 to exclude the "buffer shim" so that the browser-lever doesn't make the unneeded conversion as it promises in the docs?

This is my webpack config:

Code:
import path from 'path';
import { fileURLToPath } from 'url';

const __dirname = path.dirname(fileURLToPath(import.meta.url));


export default {
  entry: './src/la.js',
  output: {
    filename: 'laio.js',
    path: path.resolve(__dirname, 'dist'),
    library: "la"
  }
};

The internet search makes me think everybody understands how to do it in Webpack 5, but I'm missing something.

<p>I'm trying to use the Level database abstraction and the IndexedDB-based Level-down for the browser variant of my app.
It converts everything in a byte array, as stated in the <a href="https://github.com/Level/browser-level" rel="nofollow noreferrer">documentation</a>:</p>
<blockquote>
<p>Like other implementations of abstract-level, browser-level has first-class support of binary keys and values, using either Uint8Array or Buffer. In order to sort string and binary keys the same way as other databases, browser-level internally converts data to a Uint8Array before passing them to IndexedDB. If you have no need to work with Buffer keys or values, you can choose to omit the buffer shim from a JavaScript bundle (through configuration of Webpack, Browserify or other bundlers).</p>
</blockquote>
<p>I'm having hard time debugging my app as <a href="https://stackoverflow.com/questions...ddb-as-a-storage-shows-arrays-of-bytes-instea">I can't browse the database</a> when everything is binary.</p>
<p>How do I tell Webpack 5.91.0 to <strong>exclude</strong> the "buffer shim" so that the <code>browser-lever</code> doesn't make the unneeded conversion as it promises in the docs?</p>
<p>This is my webpack config:</p>
<pre><code>import path from 'path';
import { fileURLToPath } from 'url';

const __dirname = path.dirname(fileURLToPath(import.meta.url));


export default {
entry: './src/la.js',
output: {
filename: 'laio.js',
path: path.resolve(__dirname, 'dist'),
library: "la"
}
};
</code></pre>
<p>The internet search makes me think everybody understands how to do it in Webpack 5, but I'm missing something.</p>
 

Latest posts

Top