Skip to content

Conversation

@hpinkos
Copy link

@hpinkos hpinkos commented Aug 29, 2024

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
Copy link

vercel bot commented Aug 29, 2024

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

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
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
Copy link
Author

hpinkos commented Aug 29, 2024

@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