Skip to content

Fix goober running in vitest - #589

Open
hpinkos wants to merge 1 commit into
cristianbote:masterfrom
hpinkos:master
Open

Fix goober running in vitest#589
hpinkos wants to merge 1 commit into
cristianbote:masterfrom
hpinkos:master

Conversation

@hpinkos

@hpinkos hpinkos commented Aug 29, 2024

Copy link
Copy Markdown

Prevents an error when importing a component using goober into a vitest unit test

TypeError: Cannot add property p, object is not extensible
 ❯ a node_modules/goober/dist/goober.modern.js:1:2084

The error is happening because this is equivalent to module.exports

console.log(this);

[Module: null prototype] {
  css: [Function: u],
  extractCss: [Function: r],
  glob: [Function: bound u],
  keyframes: [Function: bound u],
  setup: [Function: m],
  styled: [Function: j]
}

Reproducible example of the error: https://github.com/hpinkos/vitest-goober

@vercel

vercel Bot commented Aug 29, 2024

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
goober-rocks ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 29, 2024 3:18pm

@codesandbox-ci

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@cristianbote

Copy link
Copy Markdown
Owner

heya @hpinkos thanks for looking into this. Adding that check adds +17B and wondering if this #562 could also fix what you are seeing but with a smaller footprint?

@hpinkos

hpinkos commented Aug 29, 2024

Copy link
Copy Markdown
Author

@cristianbote unfortunately no. I did check that out and try it first, but in this environment globalThis is set up to be a mocked version of window so it's not equivalent to this

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.

2 participants