-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Conversation
original issue doesn't relate to normal way of importing a package (since
we usually dont break package name into multiline),it's the edge case which
described in the test case that caused the problem,cause it accident ally
captured by the importsRE regex.
patak ***@***.***>于2021年7月1日 周四01:57写道:
… ***@***.**** commented on this pull request.
------------------------------
In packages/playground/vue/ScanDep.vue
<#4054 (comment)>:
> +let body = ""
+function testMultiline(a, b) {
+ body = b.body
+}
+testMultiline("import", {
+body: "ok" });
Could we get a test case with a proper import statement that fails without
this PR?
IIUC, it should be something like:
import { something } from
'package'
Or something based on the issue this is fixing.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#4054 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABXDV3F4HAW3AVPBLKNE5MDTVNLJTANCNFSM47SMZCPQ>
.
|
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:
I think it is worth checking what can be modified in |
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. |
…#4054) Co-authored-by: taylorliu <[email protected]>
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?
Before submitting the PR, please make sure you do the following
fixes #123
).