Skip to content

Fix importing from Passage-Node #152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Sep 4, 2024

Conversation

flanagankp
Copy link
Contributor

@flanagankp flanagankp commented Sep 4, 2024

Description

The main export from Passage-Node was not behaving well in scenarios using more modern ESM tools like Vite in the context of things like SvelteKit and Remix. This was due to a couple of issues that have been resolved:

  • Package.json was not properly using the more modern exports field to differentiate between CJS and ESM builds
  • The ESM build was not being transformed properly so it had a module syntax error, resolved by using the tsup esbuild toolchain like we use in passage-js that has been well tested and understood (long term we should look into vite as the build tool but I've only ever used it to target browsers so didn't want to experiment with that yet for the node build).

Now you can use the package properly in modern frameworks like Sveltekit both of these ways:

  • import { Passage } from '@passageidentity/passage-node' (which we should push people to do as in the next major release I want to only support this option)
  • import Passage from '@passageidentity/passage-node'
    And in older contexts that don't use ES modules the following works
  • const { Passage } = require('@passageidentity/passage-node'); (again what we'll go with long term)
  • const { Passage } = require('@passageidentity/passage-node').default; (what you currently have to do)

Jira Story

PSG-4297

Images/Screen Capture

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Only
  • This change requires a documentation update

Testing

  • Tested local package build against Sveltekit using import Passage from '@passageidentity/passage-node syntax
  • Tested local package build against Sveltekit using import { Passage } from '@passageidentity/passage-node' syntax
  • Tested local package build against Remix using import Passage from '@passageidentity/passage-node syntax
  • Tested local package build against Remix using import { Passage } from '@passageidentity/passage-node' syntax
  • Tested local package build against pure-JS express app using const Passage = require('@passageidentity/passage-node') syntax
  • Tested local package build against pure-JS express app using const { Passage } = require('@passageidentity/passage-node') syntax

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

@flanagankp flanagankp linked an issue Sep 4, 2024 that may be closed by this pull request
@flanagankp flanagankp requested a review from a team September 4, 2024 15:03
Copy link

sonarqubecloud bot commented Sep 4, 2024

@flanagankp flanagankp merged commit 38215ac into main Sep 4, 2024
2 checks passed
@ctran88 ctran88 deleted the psg-4297-fix-contructor-call-issues branch November 21, 2024 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Constructor call fails in a Remix app
3 participants