You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm working on a project that uses power-assert together with karma, mocha, rollup and coffeescript. To make it all work together, I needed to make rollup the only preprocessor to karma, use the coffeescript plugin for rollup, and add power-assert support through the babel preset, which in turn I enabled through the babel plugin for rollup. Since everything needs to run in the browser, I'm also using rollup-plugin-node-polyfills, which ends up providing its own version of the Node.js standard assert module.
A consequence of this setup is that assert.oket al end up being defined as getters of the assert module object. This means that these properties cannot simply be reassigned, even if you try to do this on an intermediate object that inherits the module through the prototype chain. Unfortunately, this is exactly what empower-core/index.js is trying to do on line 50. Fortunately, there is a straightforward alternative: use core-js's define helper instead, which was already imported in the module, anyway.
Using patch-package, I generated the following diff that solved my problem:
diff --git a/node_modules/empower-core/index.js b/node_modules/empower-core/index.js
index e9118c7..8074a81 100644
--- a/node_modules/empower-core/index.js+++ b/node_modules/empower-core/index.js@@ -47,7 +47,8 @@ function empowerAssertObject (assertObject, options) {
var config = assign(defaultOptions(), options);
var target = config.destructive ? assertObject : create(assertObject);
var decorator = new Decorator(target, config);
- return assign(target, decorator.enhancement());+ define(target, decorator.enhancement());+ return target;
}
function empowerAssertFunction (assertFunction, options) {
Thanks for making power-assert possible!
I'm working on a project that uses power-assert together with karma, mocha, rollup and coffeescript. To make it all work together, I needed to make rollup the only preprocessor to karma, use the coffeescript plugin for rollup, and add power-assert support through the babel preset, which in turn I enabled through the babel plugin for rollup. Since everything needs to run in the browser, I'm also using rollup-plugin-node-polyfills, which ends up providing its own version of the Node.js standard
assert
module.A consequence of this setup is that
assert.ok
et al end up being defined as getters of theassert
module object. This means that these properties cannot simply be reassigned, even if you try to do this on an intermediate object that inherits the module through the prototype chain. Unfortunately, this is exactly whatempower-core/index.js
is trying to do on line 50. Fortunately, there is a straightforward alternative: usecore-js
'sdefine
helper instead, which was already imported in the module, anyway.Using patch-package, I generated the following diff that solved my problem:
This issue body was partially generated by patch-package.
The text was updated successfully, but these errors were encountered: