-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Description
Describe the bug
I am building a table library for Svelte which uses classes and instanceof checks quite extensively. I've noticed that the behaviour of instanceof is different between yarn dev and yarn build && yarn preview. More specifically, instanceof returns false in cases where I expect it to return true.
My core library (svelte-headless-table) exposes an argument that accepts an object of plugins. These plugins are exported from svelte-headless-table/plugins that can extend the library's functionality. Some plugins use instanceof checks for their logic, but instanceof results in incorrect behaviour.
The issue persists with npm and pnpm.
Catching the issue
The issue does not surface if I use npm link or pnpm.overrides to debug the package. I've only been able to catch the issue by adding console.log statements to the packaged library files in node_modules/. I've added instructions to the reproduction repo on how to do so.
Dev mode
Preview mode
Relevant discussion
An existing issue thread exists here.
Reproduction
https://github.com/bryanmylee/svelte-headless-table-vite-instanceof-check
System Info
System:
OS: macOS 12.4
CPU: (10) arm64 Apple M1 Pro
Memory: 111.06 MB / 32.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.15.0 - ~/.nvm/versions/node/v16.15.0/bin/node
Yarn: 1.22.18 - ~/.nvm/versions/node/v16.15.0/bin/yarn
npm: 8.5.5 - ~/.nvm/versions/node/v16.15.0/bin/npm
Watchman: 2022.07.04.00 - /Users/bryanmylee/homebrew/bin/watchman
Browsers:
Chrome: 103.0.5060.134
Safari: 15.5Used Package Manager
yarn
Logs
No errors are thrown and the library fails silently in dev.
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.

