NathanaelA / fluentreports

:page_facing_up: Fluent Reports - Data Driven Reporting Engine for Node.js and Browsers :page_facing_up:
https://fluentreports.com
MIT License
377 stars 84 forks source link

Buffer is not defined, Platform React JS #266

Open Hassaan0 opened 1 year ago

Hassaan0 commented 1 year ago

Steps to reproduce.

Sample Data

 const data = [
        { name: "Elijah", age: 18 },
        { name: "Abraham", age: 22 },
        { name: "Gavin", age: 28 },
      ];
      const rpt = new Report("grocery1.pdf")
        .data(data) // Add our Data
        .pageHeader(["My Grocery List"]) // Add a simple header
        .detail("{{count}} {{unit}} of {{item}}") // Put how we want to print out the data line.
        .render();

I already tried window.buffer and webpack handling given below

  1. Adding plugins section with ProviderPlugin into webpack.config.js: module.exports = { // ... plugins: [ // Work around for Buffer is undefined: // https://github.com/webpack/changelog-v5/issues/10 new webpack.ProvidePlugin({ Buffer: ['buffer', 'Buffer'], }), new webpack.ProvidePlugin({ process: 'process/browser', }), ]

  2. Also add in resolve.fallback into webpack.config.js : resolve: { extensions: [ '.ts', '.js' ], fallback: { "stream": require.resolve("stream-browserify"), "buffer": require.resolve("buffer") } }

NathanaelA commented 1 year ago

Hi did you follow the instructions here https://github.com/NathanaelA/fluentreports/tree/master/generator

Specifically creating the browser version of the code base: browserify fluentReportsBuilder.js -s fluentReports --ignore iconv-lite -o ../generator/fluentReportsBrowser.js

If you are doing server only, then Node provides "Buffer"

Hassaan0 commented 1 year ago

Hi did you follow the instructions here https://github.com/NathanaelA/fluentreports/tree/master/generator

Specifically creating the browser version of the code base: browserify fluentReportsBuilder.js -s fluentReports --ignore iconv-lite -o ../generator/fluentReportsBrowser.js

If you are doing server only, then Node provides "Buffer"

Yeah I tried it again and it works.. but its showing me the GUI .. i want to use code base functionality but i cant figure it out how to use it .. could you please help me out