-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(nammatham): fix bun error on windows when using default import
- Loading branch information
1 parent
0e0ee34
commit a792187
Showing
7 changed files
with
85 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Bun | ||
|
||
## Issues | ||
|
||
Summary: | ||
- `lodash_default is not a function` error when using `lodash.camelcase` package | ||
- Using default import of `lodash` package may cause this issue | ||
|
||
Deployment at: | ||
- https://github.com/thaitype/nammatham/actions/runs/9105382778 | ||
- Executable File from `bun-win-x64` target | ||
- Using bun to compile into single executable file | ||
|
||
Platform: | ||
|
||
- Azure Functions Windows | ||
- Bun v1.1.8 (Windows x64) | ||
|
||
Package: | ||
|
||
- lodash.camelcase v4.3.0 | ||
- nammatham on [commit 3f3b7b7 (2024-05-15)](https://github.com/thaitype/nammatham/commit/96ad8958c843553b0156d968b72e1d285c85041f) | ||
- Build with tsup v8.0.1 | ||
|
||
``` | ||
Bun v1.1.8 (Windows x64) | ||
n/a | ||
at B:/~BUN/root/main.exe:3061:12 | ||
at http (B:/~BUN/root/main.exe:2983:5) | ||
at http (B:/~BUN/root/main.exe:3031:13) | ||
TypeError: lodash_default is not a function. (In 'lodash_default(options.name ?? options.route)', 'lodash_default' is undefined) | ||
^ | ||
3031 | name: lodash_default(options.name ?? options.route), | ||
3030 | this.functions.push({ | ||
3029 | } | ||
3028 | throw new Error("Route or Name is required"); | ||
3027 | if (options.route === undefined && options.name === undefined) { | ||
3026 | http(options) { | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { describe, expect, test } from 'vitest'; | ||
import { pascalCase } from './utils'; | ||
|
||
describe('pascalCase', () => { | ||
test('converts undefined to an empty string', () => { | ||
expect(pascalCase(undefined)).toBe(''); | ||
}); | ||
test('converts a simple sentence to PascalCase', () => { | ||
expect(pascalCase('convert any string to pascal case')).toBe('ConvertAnyStringToPascalCase'); | ||
}); | ||
|
||
test('handles special characters correctly', () => { | ||
expect(pascalCase('convert_any string-to!pascal@case')).toBe('ConvertAnyStringToPascalCase'); | ||
}); | ||
|
||
test('handles a single word correctly', () => { | ||
expect(pascalCase('hello')).toBe('Hello'); | ||
}); | ||
|
||
test('handles an empty string correctly', () => { | ||
expect(pascalCase('')).toBe(''); | ||
}); | ||
|
||
test('handles multiple spaces correctly', () => { | ||
expect(pascalCase(' multiple spaces in string ')).toBe('MultipleSpacesInString'); | ||
}); | ||
|
||
test('handles numbers correctly', () => { | ||
expect(pascalCase('convert 123 number')).toBe('Convert123Number'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export function pascalCase(str: string | undefined): string { | ||
if (str === undefined) { | ||
return ''; | ||
} | ||
return str | ||
.split(/[^a-zA-Z0-9]+/) | ||
.map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()) | ||
.join(''); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.