marvinhagemeister / xhr-mocklet

Mock XMLHttpRequests in both the browser and node
5 stars 1 forks source link

Does not work with the rollup bundler #19

Open maoberlehner opened 6 years ago

maoberlehner commented 6 years ago
// some/file.js
import xhr from 'xhr-mocklet';
// ...
rollup  some/file.js --o dist/some/file.js --f iife -c rollup.config.js
[!] Error: Cannot call a namespace ('ee')
node_modules/xhr-mocklet/lib/es/MockXMLHttpRequestUpload.js (4:23)
// rollup.config.js
import commonjs from 'rollup-plugin-commonjs';
import resolve from 'rollup-plugin-node-resolve';
import uglify from 'rollup-plugin-uglify';

export default {
  plugins: [
    resolve(),
    commonjs(),
    uglify(),
  ],
};

Btw. you write Utility for mocking XMLHttpRequests both in the browser and nodejs – after looking at the code, I can't imagine how this could work in the browser – see: https://github.com/marvinhagemeister/xhr-mocklet/issues/9

I was hoping for a lightweight alternative to nise but currently this does not work for me (bundling for the browser).

marvinhagemeister commented 6 years ago

@maoberlehner Thanks for checking out xhr-mocklet. It has indeed a few rough spots that can be improved. I'm happy to review any PRs you have in store 👍