Enzyme: browser build of enzyme

Created on 10 Feb 2017  路  11Comments  路  Source: enzymejs/enzyme

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?

question

Most helpful comment

Hi I ended up building it myself with browserify.

  • clone enzyme repo
  • checkout v7.2.1
  • npm run react:15
  • npm run build
  • cd build
  • browserify index.js -o enzyme.2.7.1.js -x react/addons -x react/lib/ReactContext -x react/lib/ExecutionEnvironment -s enzyme -d
  • move enzyme.2.7.1.js where I need it and use it

You can close this issue.

Thanks

All 11 comments

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.

  • clone enzyme repo
  • checkout v7.2.1
  • npm run react:15
  • npm run build
  • cd build
  • browserify index.js -o enzyme.2.7.1.js -x react/addons -x react/lib/ReactContext -x react/lib/ExecutionEnvironment -s enzyme -d
  • move enzyme.2.7.1.js where I need it and use it

You 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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nelsonchen90 picture nelsonchen90  路  3Comments

AdamYahid picture AdamYahid  路  3Comments

amcmillan01 picture amcmillan01  路  3Comments

potapovDim picture potapovDim  路  3Comments

mattkauffman23 picture mattkauffman23  路  3Comments