Fix importing from Passage-Node #152
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.



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:
exportsfield to differentiate between CJS and ESM buildstsupesbuild 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
Testing
import Passage from '@passageidentity/passage-nodesyntaximport { Passage } from '@passageidentity/passage-node'syntaximport Passage from '@passageidentity/passage-nodesyntaximport { Passage } from '@passageidentity/passage-node'syntaxconst Passage = require('@passageidentity/passage-node')syntaxconst { Passage } = require('@passageidentity/passage-node')syntaxChecklist: