Skip to content
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

fix: Do not depend on the 'path' package for basename #765

Merged
merged 2 commits into from
Feb 20, 2025

Conversation

artonge
Copy link
Contributor

@artonge artonge commented Feb 20, 2025

This is causing issues with ESM: "process is not defined".

Include package version bump

@susnux
Copy link
Contributor

susnux commented Feb 20, 2025

This is causing issues with ESM: "process is not defined".

Sounds like the bundler configuration of that app is not configured correctly

@@ -3,7 +3,10 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { basename } from 'path'
function basename(path: string): string {
return path.split(/[\\/]/).pop() ?? ''
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect we are only on POSIX so backslash is a valid part of a filename

Suggested change
return path.split(/[\\/]/).pop() ?? ''
return path.split('/').pop()

(also the result of split will always be an array with at least one string element and the result of pop always that element, so the nullish operator is useless).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect we are only on POSIX so backslash is a valid part of a filename

Don't we have colleagues running Windows? But indeed, this could break if the filename contains \. Not sure how to best handle that.

(also the result of split will always be an array with at least one string element and the result of pop always that element, so the nullish operator is useless).

Typing was not happy. I added as string instead.

This is causing issues with ESM: "process is not defined".

Signed-off-by: Louis Chemineau <[email protected]>
@artonge artonge force-pushed the artonge/fix/usageimport branch from 068f73f to 7937921 Compare February 20, 2025 16:06
@artonge artonge merged commit 7355ed3 into main Feb 20, 2025
12 checks passed
@artonge artonge deleted the artonge/fix/usageimport branch February 20, 2025 16:32
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.

3 participants