-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
walkObject
to work with module namespace objects
- Loading branch information
Showing
2 changed files
with
20 additions
and
1 deletion.
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,19 @@ | ||
--- | ||
'@vanilla-extract/private': patch | ||
--- | ||
|
||
**walkObject**: Use an empty object instead of calling the input object's `constructor` when mapping over it | ||
|
||
This allows `walkObject` to be used on module namespace objects: | ||
|
||
```ts | ||
import * as ns from './foo'; | ||
|
||
// Would sometimes cause a runtime error | ||
walkObject(ns, myMappingFunction); | ||
``` | ||
|
||
The previous implementation did not work with these objects because [they do not have a `constructor` function][es6 spec]. | ||
`esbuild` seems to have papered over this issue by providing a `constructor` function on these objects, but this seems to not be the case with `vite-node`, hence the need for this fix. | ||
|
||
[es6 spec]: https://262.ecma-international.org/6.0/#sec-module-namespace-objects |
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