Discussion: break up import()
that are NOT doing ES import work ? #21910
Description
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 is new RegExp('(^|[^.])\\bimport(\\s*(?:\\(|/[/*]))', 'g')
, which matches the string import()
in Reactlazy.js. Therefore, it's identified as a dynamic 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 in React.lazy.js
? Though import()
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 the import()
is also broken up?