Description
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.
With this setup, I ran into the following problem. Wherever assert(...)
expressions in my test code are instrumented, it is replaced by complex powerAssert(...)
expressions. This presumes that powerAssert
is a function. However, the source module is assigning a non-callable object to module.exports
as well as module.exports.default
. Both of these should actually be the assert.ok
function.
Using patch-package, I generated the following diff, which solved my problem. Note that this is a non-breaking change: module.exports
and module.exports.default
still have all the assert.*
functions as properties.
diff --git a/node_modules/power-assert/index.js b/node_modules/power-assert/index.js
index acd429a..debd81e 100644
--- a/node_modules/power-assert/index.js
+++ b/node_modules/power-assert/index.js
@@ -62,6 +62,6 @@ function customize (customOptions) {
}
var defaultAssert = customize();
-define(defaultAssert, { '__esModule': true });
-defaultAssert['default'] = defaultAssert;
-module.exports = defaultAssert;
+define(defaultAssert, { '__esModule': true, 'default': defaultAssert.ok });
+define(defaultAssert.ok, defaultAssert);
+module.exports = defaultAssert.ok;
Note that I also replaced the direct assignment of the default
property by a define
call. I explained the reason for this in more detail in twada/power-assert-runtime#26.
This issue body was partially generated by patch-package.
Activity