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

test: Cannot create proxy with a non-object as target or handler #14633

Closed
peterpeterparker opened this issue Dec 9, 2024 · 1 comment
Closed

Comments

@peterpeterparker
Copy link

peterpeterparker commented Dec 9, 2024

Describe the bug

I'm facing a similar issue with Svelte v5 in testing context to the one someone reported on SO today. The unit test works fine until I add a <style></style> to the component.

As soon as a component contains a style, the following error starts appearing when running npm run test:

FAIL src/tests/lib/components/Back.spec.ts [ src/tests/lib/components/Back.spec.ts ]
TypeError: Error while preprocessing src/lib/components/Back.svelte - Cannot create proxy with a non-object as target or handler
❯ new PartialEnvironment node_modules/vite/dist/node/chunks/dep-yUJfKD1i.js:16766:19
❯ preprocessCSS node_modules/vite/dist/node/chunks/dep-yUJfKD1i.js:48447:23
❯ node_modules/@sveltejs/vite-plugin-svelte/src/preprocess.js:114:10
❯ style node_modules/@sveltejs/vite-plugin-svelte/src/preprocess.js:77:37
❯ process_single_tag node_modules/svelte/src/compiler/preprocess/index.js:283:21
❯ replace_in_code node_modules/svelte/src/compiler/preprocess/replace_in_code.js:70:23
❯ process_tag node_modules/svelte/src/compiler/preprocess/index.js:300:26
❯ Module.preprocess node_modules/svelte/src/compiler/preprocess/index.js:363:25
❯ compileSvelte node_modules/@sveltejs/vite-plugin-svelte/src/utils/compile.js:85:20

I'm facing an issue in our design kit, which I started using for migrating our existing app to Svelte v5 (PR).

Note that I originally reported the issue to Svelte Testing (here), but since I can reproduce the issue with a Svelte mount, we can rule out that library as the root cause.

Reproduction

git clone https://github.com/peterpeterparker/svelte-vite-testing-library-css
cd svelte-vite-testing-library-css
npm ci
npm run test

Logs

No response

System Info

System:
    OS: macOS 15.1.1
    CPU: (8) arm64 Apple M2
    Memory: 105.69 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.12.0 - ~/.n/bin/node
    Yarn: 1.22.22 - ~/.n/bin/yarn
    npm: 10.9.2 - ~/.n/bin/npm
    pnpm: 9.15.0 - ~/.n/bin/pnpm
  Browsers:
    Brave Browser: 131.1.73.97
    Chrome: 131.0.6778.109
    Safari: 18.1.1
  npmPackages:
    svelte: ^5.0.0 => 5.9.0

Severity

blocking an upgrade

@paoloricciuti
Copy link
Member

This is a duplicate of sveltejs/vite-plugin-svelte#1043

and you can see a why in this comment sveltejs/vite-plugin-svelte#1043 (comment)

@paoloricciuti paoloricciuti closed this as not planned Won't fix, can't repro, duplicate, stale Dec 9, 2024
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

No branches or pull requests

2 participants