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: add list of known js source extensions to config #3828

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dominikg
Copy link
Contributor

Description

implementation of #3219 with config option at runtime as requested in #3219 (comment)

Separate PR to be able to compare the two and avoid having to rebase/force-push

I don't really like how the array is passed through several function calls to reach the util, but without some structural changes this is the least invasive i could manage.

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

Comment on lines +291 to +293
if (!config.knownJsSrcExtensions) {
config.knownJsSrcExtensions = [...DEFAULT_KNOWN_JS_SRC_EXTENSIONS]
}
Copy link
Member

Choose a reason for hiding this comment

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

We can wait until we discuss this with Evan, but I think it is better if this works like assetsInclude. So the user will give us extra extensions and they are added to the ones supported by default by vite.

@@ -416,6 +447,7 @@ export async function resolveConfig(
assetsInclude(file: string) {
return DEFAULT_ASSETS_RE.test(file) || assetsFilter(file)
},
knownJsSrcExtensions: resolvedKnownJsSrcExtensions,
Copy link
Member

Choose a reason for hiding this comment

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

We discussed a bit about this in Discord. IMO we could also use the same scheme utilized by assetsInclude here. In the ResolvedConfig, we will have a resolved.isJsRequest(path) function that plugins can then use. This is something else to discuss with Evan, if we go here, we may want to have all these helpers in resolve.utils.isJsRequest, but I am not sure if it is really needed and the flat structure is enough here. @antfu what do you think?

@Shinigami92 Shinigami92 requested a review from antfu June 17, 2021 07:35
@patak-dev
Copy link
Member

Commenting for reference, as this was already discussed in Discord. We may be able to avoid the need for defining these known imports altogether, so for the moment is better to hold on with exposing a new config option here. We can continue to accept new known types if that helps the ecosystem in the meanwhile. @dominikg I'll make this one a draft for the time being.

@benmccann
Copy link
Collaborator

We may be able to avoid the need for defining these known imports altogether, so for the moment is better to hold on with exposing a new config option here.

@patak-dev do you happen to remember how it was that we might be able to avoid defining these known imports? Is there any update on that or whether we should move forward with this PR? I see you referred to this PR positively in a recent comment, so I'm wondering if there might be a path forward for it if it were rebased?

@espipj
Copy link

espipj commented May 9, 2023

Hello! I am finding hard to make vite to pre-process .feature files (cucumber) which seems related to this PR and this issue #9963
is there any timeline for these changes to be merged into main? is there any way I can help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2-nice-to-have Not breaking anything but nice to have (priority)
Projects
Status: Discussing
Development

Successfully merging this pull request may close these issues.

None yet

5 participants