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 walkObject to work with module namespace objects #1368

Merged
merged 5 commits into from
Mar 28, 2024

Conversation

askoufis
Copy link
Contributor

@askoufis askoufis commented Mar 21, 2024

Fixes #1360.

walkObject doesn't work on module namespace objects when running inside vite-node. This is because module namespace objects don't have a constructor function.

This "bug" has gone unnoticed for a long time because esbuild was modifying the export in some way that made it work, but vite-node doesn't seem to do this.

I don't think we need to use constructor anymore since walkObject is constrained to only work on objects, at least as far as the type signature is concerned.

Copy link

changeset-bot bot commented Mar 21, 2024

🦋 Changeset detected

Latest commit: 3919a1c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 15 packages
Name Type
@vanilla-extract/private Patch
@vanilla-extract/vite-plugin Patch
@vanilla-extract/css Patch
@fixtures/features Patch
@fixtures/layers Patch
@fixtures/low-level Patch
@fixtures/recipes Patch
@fixtures/sprinkles Patch
@fixtures/template-string-paths Patch
@fixtures/themed Patch
@fixtures/thirdparty Patch
@fixtures/unused-modules Patch
@fixtures/thirdparty-dep Patch
@fixtures/thirdparty-dep-dep Patch
vanilla-extract-example-webpack-react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@@ -11,7 +11,7 @@ export function walkObject<T extends Walkable, MapTo>(
fn: (value: Primitive, path: Array<string>) => MapTo,
path: Array<string> = [],
): MapLeafNodes<T, MapTo> {
const clone = obj.constructor();
const clone = {} as any;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The types are a bit gnarly here, clone was any before this change, so this just keeps the status quo.

@askoufis askoufis enabled auto-merge (squash) March 28, 2024 04:09
@askoufis askoufis merged commit 90f0315 into master Mar 28, 2024
11 checks passed
@askoufis askoufis deleted the namespace-theme-tokens branch March 28, 2024 04:13
@gu-stav
Copy link

gu-stav commented Mar 28, 2024

Thank you everyone 👏

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.

4.x: Uncaught TypeError: e.constructor is not a function
3 participants