Skip to content

Doesn't work with other transformers #551

@vpzomtrrfrt

Description

@vpzomtrrfrt

Getting errors like this:

TypeError: Cannot read properties of undefined (reading 'text')
    at NodeObject.getText (evalmachine.<anonymous>:144243:29)
    at visitor (/home/colin/filerepo/node_modules/ts-transform-css-modules/dist/transform.js:72:33)
...

Based on this StackOverflow answer, this seems to resolve the issue in my case:

diff --git a/src/transform.ts b/src/transform.ts
index 794b9f9..2978a85 100644
--- a/src/transform.ts
+++ b/src/transform.ts
@@ -145,7 +145,7 @@ function visitor(
       }
     } else if (ts.isCallExpression(node)) {
       if (
-        node.expression.getText() === "require" &&
+        ts.isIdentifier(node.expression) && node.expression.escapedText === "require" &&
         CSS_EXTENSION_REGEX.test(node.arguments[0].getText())
       ) {
         cssPath = resolveCssPath(

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions