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

feat: auto-exclude svelte dependencies in vite.optimizeDeps #145

Merged
merged 10 commits into from
Aug 20, 2021

Conversation

dominikg
Copy link
Member

@dominikg dominikg commented Aug 19, 2021

A simple test has been added.

@dominikg dominikg marked this pull request as draft August 19, 2021 10:17
Copy link
Member

@benmccann benmccann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!! I'm excited to try this out once the Vite change lands!

packages/vite-plugin-svelte/src/utils/dependencies.ts Outdated Show resolved Hide resolved
packages/vite-plugin-svelte/src/utils/dependencies.ts Outdated Show resolved Hide resolved
packages/vite-plugin-svelte/src/utils/dependencies.ts Outdated Show resolved Hide resolved
@dominikg dominikg marked this pull request as ready for review August 19, 2021 15:11
@dominikg dominikg changed the title Feat/auto exclude feat: auto-exclude svelte dependencies in vite.optimizeDeps Aug 19, 2021
return !!pkg.svelte;
}

const COMMON_DEPENDENCIES_WITHOUT_SVELTE_FIELD = [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we include everything that comes with a new SvelteKit project?

  "devDependencies": {
    "@sveltejs/kit": "next",
    "@types/cookie": "^0.4.0",
    "@typescript-eslint/eslint-plugin": "^4.19.0",
    "@typescript-eslint/parser": "^4.19.0",
    "eslint": "^7.22.0",
    "eslint-config-prettier": "^8.1.0",
    "eslint-plugin-svelte3": "^3.2.0",
    "prettier": "~2.2.1",
    "prettier-plugin-svelte": "^2.2.0",
    "svelte": "^3.34.0",
    "svelte-check": "^2.0.0",
    "svelte-preprocess": "^4.0.0",
    "tslib": "^2.0.0",
    "typescript": "^4.0.0"
  },
  "type": "module",
  "dependencies": {
    "@fontsource/fira-mono": "^4.2.2",
    "@lukeed/uuid": "^2.0.0",
    "cookie": "^0.4.1"
  }

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

most of it was covered already by the prefix checks, added the remaining ones. thanks!!

Comment on lines 58 to 60
if (path.length === 3) {
log.warn.once(`encountered deep svelte dependency tree: ${path.join('>')}`);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be warning when we encounter this scenario? The crawler should be able to continue down the tree, just that it's weird for this to ever happen. I think we can remove these lines, or maybe convert to debug if it helps for debugging.

Copy link
Member Author

@dominikg dominikg Aug 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Such a deeply nested svelte component package is a sign something is afoot with the project and a warning is in order imho.

I agree that it is weird and tbh i'm hoping this never occurs in the wild. Still i'd like to know if it does and debug output would not be noticed in regular use.

To avoid spam, the warning is logged only once per run and not again if the tree is even deeper. foo>bar>baz gets logged, but foo>bar>baz>qoox won't.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose it's good to know if this ever happens in the wild, but I'm concern if it would annoy the end-user since it may be something not fixable on their end. We might get an issue/pr to remove that line too. Since if it's a warning, the end-user should be able to suppress or fix it (which sometimes isn't possible).

Or we could leave it there and increment the number if someone do report it, so we know there exist an atrocity like that 😆

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

made it debug for now. I guess such a deep path would cause other issues and if it cannot be resolved with the package authors we can add back a warning (and an extra option to filter some logs?)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good 👍

@dominikg
Copy link
Member Author

manually tested it with npm@6 and yarn1 + yarn3 with pnp. and it works 🥳

@dominikg dominikg merged commit 066be0c into main Aug 20, 2021
@dominikg dominikg deleted the feat/auto-exclude branch August 20, 2021 10:39
@github-actions github-actions bot mentioned this pull request Aug 20, 2021
@github-actions github-actions bot mentioned this pull request Jul 13, 2022
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.

None yet

3 participants