angular-shepherd icon indicating copy to clipboard operation
angular-shepherd copied to clipboard

Angular-Shepherd 19 CommonJS build fails with TS2309

Open KeithGillette opened this issue 11 months ago • 12 comments

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 avatar Jan 29 '25 23:01 KeithGillette

@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.

RobbieTheWagner avatar Feb 04 '25 12:02 RobbieTheWagner

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.

KeithGillette avatar Feb 04 '25 13:02 KeithGillette

I have the same issue...

itmilos avatar Feb 04 '25 16:02 itmilos

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.

cdelgadob avatar Mar 09 '25 08:03 cdelgadob

We're actually likely to drop CJS entirely soon and highly recommend that folks use "moduleResolution": "bundler"

RobbieTheWagner avatar Mar 12 '25 14:03 RobbieTheWagner

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

FloSojer avatar Apr 04 '25 06:04 FloSojer

Does Angular not support ESM?

RobbieTheWagner avatar Apr 04 '25 13:04 RobbieTheWagner

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.

KeithGillette avatar Apr 04 '25 14:04 KeithGillette

We are planning to ship ESM only soon, so I just wanted to understand.

RobbieTheWagner avatar Apr 05 '25 12:04 RobbieTheWagner

any update on this?

kav-viasat avatar May 12 '25 10:05 kav-viasat

any update on this?

No. We are stuck trying to update Shepherd to Svelte 5. I highly recommend folks use "moduleResolution": "bundler"

RobbieTheWagner avatar Jun 30 '25 15:06 RobbieTheWagner

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!

slifty avatar Jul 23 '25 15:07 slifty