Angular-Shepherd 19 CommonJS build fails with TS2309
Attempting to upgrade to Angular-Shepherd 19 in a project using moduleResolution: node generates the following error:
Error: node_modules/shepherd.js/dist/cjs/shepherd.d.cts:581:1 - error TS2309: An export assignment cannot be used in a module with other exported elements.
581 export = Shepherd;
~~~~~~~~~~~~~~~~~~
@KeithGillette would you be able to update to "moduleResolution": "bundler"? That's how I fixed things. I am unfamiliar with how Angular usually does things, so if node is required for all Angular projects we probably do need a different fix, but I find it strange that a browser framework would be using node.
Hi, @RobbieTheWagner — Since I opened this issue, I was able to update my Angular 19 project to "moduleResolution": "bundler" since a different dependency of our project corrected their package.json exports, which was previously preventing the update, so this is no longer actually a problem for me. However, I think there's an error in the CommonJS distributable in the published Angular-Shepherd 19 package, per the output I reported, as "moduleResolution": "node" worked fine with Angular-Shepherd 18. I see a couple of people reacted to my original post, so this may still be problematic for others.
I have the same issue...
Fully agree with @KeithGillette - while this setting solves the problem, it's just a workaround, and not a final solution, which should be considered in a future fix.
We're actually likely to drop CJS entirely soon and highly recommend that folks use "moduleResolution": "bundler"
Looking forward to the fix - thanks!
Temporarily I could fix it the following way because I'm not able to set "moduleResolution": "bundler"
Modify the file
// node_modules/shepherd.js/dist/cjs/shepherd.d.cts
// REMOVE or comment this line:
// export = Shepherd;
Run the command
npx patch-package shepherd.js
Does Angular not support ESM?
Angular definitely supports ESM. The problem is that non-Angular legacy dependencies in projects can prevent upgrading to a moduleResolution that will actually use the Angular-Shepherd ESM distributable and instead try to use Angular-Shepherd's CJS modules, which are not correct, generating the error I reported. I was able to replace the other dependency in my project that was preventing switching moduleResolution, and so now am using the correctly formatting ESM Angular-Shepherd modules, but I think the other commenters on this thread have been unable to do so for their projects, leading to the request to correct the CJS distributable.
We are planning to ship ESM only soon, so I just wanted to understand.
any update on this?
any update on this?
No. We are stuck trying to update Shepherd to Svelte 5. I highly recommend folks use "moduleResolution": "bundler"
Unfortunately we use a lot of dependencies that don't support ESM (this is the problem with ESM isn't it -- it splits the ecosystem!)
Just wanted to offer a voice of "please continue to support common JS" since that would allow us to continue to use your great tool!