-
Notifications
You must be signed in to change notification settings - Fork 46.8k
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
Discussion: break up import()
that are NOT doing ES import work ?
#21910
Comments
|
I think the request here is to break the string "import()" up to avoid a false positive in the external code: react/packages/react/src/ReactLazy.js Lines 90 to 93 in 9b76d2d
e.g. 'lazy: Expected the result of a dynamic imp' + 'ort() call. ' + I'm not sure what others will think of this request (to modify React source b'c of the way an external project happens to work) but we can leave the request open for folks to comment. One thing you might do, @n0rush, to increase the visibility for this would be to just open a PR that makes the change you're requesting. |
Yep, I'm not sure either whether this should be done in React so I raised it as a discussion. Also I saw React seems to have done some similar work before. react/packages/react/src/ReactLazy.js Lines 93 to 95 in 9b76d2d
Sure. PR here :-) |
Closed by #21918. |
Background information
I have been developing a fimga plugin and recently get an exact error as described in figma/plugin-typings#36. The root cause is that the Secure ECMAScript (SES) in figma tries to block any instances of the
dynamic import expression
in the code being evaluated. However, The SES shim doesn't use a full parser, so they can't tell precisely when the evaluated code contains a real import, but they do employ a regular expression to spot anything that might be a real import expression. The regular expression used isnew RegExp('(^|[^.])\\bimport(\\s*(?:\\(|/[/*]))', 'g')
, which matches the stringimport()
in Reactlazy.js. Therefore, it's identified as adynamic import expression
, resulting in a false positive.The discussion I would like to bring up is: whether the
import()
should be be broken up, as what has been done inReact.lazy.js
? Thoughimport()
doesn't look like a valid Javascript import statement, it does lead to some confusion for some platforms (E.g. figma) which don't have a strict validation. And it seems there is no harm if theimport()
is also broken up?The text was updated successfully, but these errors were encountered: