compressjs icon indicating copy to clipboard operation
compressjs copied to clipboard

AMD module definition breaks Webpack

Open saltyJeff opened this issue 6 years ago • 4 comments

This isn't really an issue with the code, but it does hurt integration with Webpack. Webpack uses their own custom "version" of AMD, which injects a pseudo-object that takes over from AMD.

Since the fake AMD is not an function, this line fails:

if (typeof define !== 'function') { var define = require('amdefine')(module); }

Simply taking out this line on every single file will allow Webpack to handle this module. I already have a copy of the module with that line taken out from every file, let me know if you would be interested in merging my PR.

saltyJeff avatar Mar 23 '18 05:03 saltyJeff

There's actually a module that has fixed this issue, I would submit using that rather than my fork (mine's kind of hacky)

webpack compressjs

saltyJeff avatar Mar 23 '18 18:03 saltyJeff

What module fixes it?

myrddraall avatar Mar 25 '18 20:03 myrddraall

Hey,

This still breaks in the browser using browserify. Would it be possible to fix that line? I would love to use this library.

Dénes

pinting avatar Jul 22 '18 08:07 pinting

Use the following command to install the last commit (https://github.com/Faithlife/compressjs/commit/19652f100671e559d7731980c26cd06a7e999b8d as of Oct 18 2018) in this fork: https://github.com/Faithlife/compressjs/commits/hermit

npm install --save https://github.com/Faithlife/compressjs/archive/19652f100671e559d7731980c26cd06a7e999b8d.tar.gz

Even works for React Native Packager (the least-forgiving packager of all), so it should work for Webpack and browserify

EdmondChuiHW avatar Oct 18 '18 20:10 EdmondChuiHW