You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The shim should be inserted in the right place, even if the source file contains static imports in comments.
For example, the shim should be inserted right after the import in the file below:
importfoofrom"./other_module.js";// Triggers the shimrequire();/*import BAD from "./bad";*/
Actual Behavior
The shim is inserted in a strange place, causing syntax errors.
Additional Information
I believe this bug happens because the plugin tries to insert the shim after the last import, but incorrectly detects them when they're inside comments.
imports are detected with the following regular expression:
Expected Behavior
The shim should be inserted in the right place, even if the source file contains static
import
s in comments.For example, the shim should be inserted right after the
import
in the file below:Actual Behavior
The shim is inserted in a strange place, causing syntax errors.
Additional Information
I believe this bug happens because the plugin tries to insert the shim after the last
import
, but incorrectly detects them when they're inside comments.import
s are detected with the following regular expression:plugins/packages/esm-shim/src/constants.ts
Lines 13 to 14 in 9e7f576
This expression is unaware of comments.
I would probably solve this by parsing the AST rather than using a regular expression. Let me know if you'd like me to make that pull request.
The text was updated successfully, but these errors were encountered: