From c08ce3fc4f61385e726374f82416d48cf5515693 Mon Sep 17 00:00:00 2001 From: Simon Ihmig Date: Wed, 9 Oct 2024 13:40:19 +0200 Subject: [PATCH] Fix broken default export when required from CJS When this package was converted to TS, `module.exports = ` was converted to `export default`, without taking into account that this would TS emit this as a named export of "default" (`exports.default = sideWatch`), so CJS consumers would have to call it as `require('@embroider/broccoli-side-watch').default()` (aka "double default" problem). As we are only targeting CJS consumers, this changes makes the compiled js have a single main export as `module.exports = sideWatch`. --- packages/broccoli-side-watch/src/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/broccoli-side-watch/src/index.ts b/packages/broccoli-side-watch/src/index.ts index 64e6a2e17..cc3ece350 100644 --- a/packages/broccoli-side-watch/src/index.ts +++ b/packages/broccoli-side-watch/src/index.ts @@ -27,7 +27,7 @@ interface SideWatchOptions { dependencies that you're actively developing. For example, right now @embroider/webpack doesn't rebuild itself when non-ember libraries change. */ -export default function sideWatch(actualTree: InputNode, opts: SideWatchOptions = {}) { +function sideWatch(actualTree: InputNode, opts: SideWatchOptions = {}) { const cwd = opts.cwd ?? process.cwd(); if (!opts.watching || !Array.isArray(opts.watching)) { @@ -65,3 +65,6 @@ export default function sideWatch(actualTree: InputNode, opts: SideWatchOptions }), ]); } + +// We expose this as CJS, so make sure this transpiles to module.exports = sideWatch +export = sideWatch;