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

Deprecate svelte field in package.json #7489

Closed
wants to merge 4 commits into from

Conversation

benmccann
Copy link
Member

The svelte field was originally intended to allow package authors to be able to provide uncompiled .svelte files as well as a compiled .js version. We have decided if packages would like to provide a compiled version that a better way to do this is to create sub-package such as compiled.

The way the svelte field is currently implemented in vite-plugin-svelte breaks Vite's dependency optimization and we've decided removing support for the svelte field is the best path forward

@benmccann benmccann added the pkg:svelte-package Issues related to svelte-package label Nov 3, 2022
@changeset-bot
Copy link

changeset-bot bot commented Nov 3, 2022

🦋 Changeset detected

Latest commit: 099dd34

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

This PR includes changesets to release 1 package
Name Type
@sveltejs/package 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

@dummdidumm
Copy link
Member

If we do that we need to make sure the rollup and webpack plugins still work correctly. How can we ensure that?

@benmccann
Copy link
Member Author

The svelte field is optional in both plugins today

Here's a test showing that the Rollup plugin works without the svelte field: https://github.com/sveltejs/rollup-plugin-svelte/blob/master/test/node_modules/esm-no-pkg-export/package.json

Here's some documentation showing which fields svelte-loader resolves in order: https://github.com/sveltejs/svelte-loader#usage

vite-plugin-svelte does more complicated stuff with the field, but I believe that functionality is just an optimization and can be removed. I sent sveltejs/vite-plugin-svelte#483 for that

@dominikg
Copy link
Member

dominikg commented Nov 4, 2022

related sveltejs/vite-plugin-svelte#482

That fixes the situation mostly with vps, but i'm still testing it. Perf can be a problem and also what happens with ssr.optimizeDeps.

@dominikg
Copy link
Member

The svelte field is optional in both plugins today

Here's a test showing that the Rollup plugin works without the svelte field: https://github.com/sveltejs/rollup-plugin-svelte/blob/master/test/node_modules/esm-no-pkg-export/package.json

there are no .svelte files in that test directory, sure that's testing svelte resolve? i think it may just be fore the package.json export warning.

@benmccann
Copy link
Member Author

there are no .svelte files in that test directory, sure that's testing svelte resolve?

You're right. It wasn't testing it. However, it does work. I just made a sample Rollup project using a node module with the following package.json to confirm:

{
	"main": "./src/Component.svelte"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg:svelte-package Issues related to svelte-package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants