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

fix: fix esbuild break when importRe matches multiline import #4054

Merged
merged 4 commits into from Jul 1, 2021

Conversation

dejour
Copy link
Contributor

@dejour dejour commented Jun 30, 2021

Description

when importsRE of scan.ts matches multiline import statement, that breaks esbuild. this pr solve the problem issue #4027 presented through removing linebreaks. according to comments about the importsRE, it doesn't have to be bullet proof. so i choose not to change the importsRE, maybe there is better approach, i'm open to suggestions.

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.
  • [x]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.

@dejour
Copy link
Contributor Author

dejour commented Jun 30, 2021 via email

@patak-dev
Copy link
Member

Ok, then I misinterpreted the issue. I don't understand how this fixes it though then. Looks to me that as you described in the first comment of the PR a better fix will be to modify the regex to avoid interpreting this case as an import statement:

<script lang="ts">
	fetch("import", {
		body: "" });
</script>

I think it is worth checking what can be modified in importsRe

@dejour
Copy link
Contributor Author

dejour commented Jun 30, 2021

So after some looking, adding $ to the regex to indicate end of match seems like a better approach. also, i had the test remained to verify it works against the edge case.

@antfu antfu merged commit eb2e41b into vitejs:main Jul 1, 2021
aleclarson pushed a commit to aleclarson/vite that referenced this pull request Nov 8, 2021
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