101arrowz / fflate

High performance (de)compression in an 8kB package
https://101arrowz.github.io/fflate
MIT License
2.27k stars 79 forks source link

Incorrect modules field for node.js #211

Closed tornadocontrib closed 5 months ago

tornadocontrib commented 6 months ago

The modules field would only resolve to browser builds when using bundlers like rollup.js. I think the workaround would be building a file that could resolve to both environment or we could simply use node.js exports only and let the browser bundlers like webpack or other would resolve it for browsers.

101arrowz commented 6 months ago

The "module" field of package.json is meant for backwards compatibility; modern bundlers and Node.js should pick up on the "exports" field instead (which is properly configured for Node.js). I believe there is a way to configure Rollup to have this behavior via the node-resolve plugin.

tornadocontrib commented 5 months ago

@101arrowz Yes I ended up using webpack with the following, seriously rollup should improve their deps resolving system

resolve: {
      alias: {
        'fflate': 'fflate/node'
      },
    },