Hi, I'm looking for a browser ready build of enzyme. I found this article to make one myself but I'd rather use a build that is updated regularly. Is there such a thing?
There isn't any official browser build, no.
Would you consider tagging this issue as a feature request? A browser build would make fiddling with React/enzyme in a plain project (no build process) much easier and faster with a simple link to unpkg.com.
I don't mind including a browser build, provided that it can only be consumed by browserify. However, I wouldn't want one that served AMD, UMD, or created browser globals.
We had to browserify enzyme so we could use it with our other AMD modules to run our tests in the browser. We had to add a script to do some post-processing on the browserified file, to avoid collisions with the global require, to remove some problematic polyfills that came from pulling in sub-libraries, and to inject the license into the src file.
@ljharb why do you not want one that serves AMD or UMD?
Those who need AMD can use a browserify transform to produce it, but I don't want to encourage an obsolete module format with the default build.
I too need an AMD module. The extra steps to make it work (as @finnigantime described) are not trivial. Adding the AMD build to the package would make enzime accessible to a broader audience.
@finnigantime, until then, would you mind sharing your build scripts here? They could then be used to document a "How to build an AMD version of enzime?" help page.
@sylvain-hamel making things accessible to people still using AMD in 2017 isn't doing them any favors; if you insist on remaining an AMD user, you must learn how to adapt all the CJS modules out there to your build system; if you don't know how to do that, you should hit a wall sooner rather than later.
Hi I ended up building it myself with browserify.
npm run react:15npm run buildcd buildbrowserify index.js -o enzyme.2.7.1.js -x react/addons -x react/lib/ReactContext -x react/lib/ExecutionEnvironment -s enzyme -denzyme.2.7.1.js where I need it and use itYou can close this issue.
Thanks
I updated the procedure in my previous comment to make sure you get a react 15 build; not a react 14.
Just because ES6 Modules are the new thing doesn't mean all the thousands (or millions) of apps out there have upgraded to that. There is a vast sea of projects still using RequireJS.
Far less vast than the sea on npm using node-style CJS modules, which is what everyone should be migrating to, if not ES modules.
Most helpful comment
Hi I ended up building it myself with browserify.
npm run react:15npm run buildcd buildbrowserify index.js -o enzyme.2.7.1.js -x react/addons -x react/lib/ReactContext -x react/lib/ExecutionEnvironment -s enzyme -denzyme.2.7.1.jswhere I need it and use itYou can close this issue.
Thanks