Skip to content
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

Doesn't work with other transformers #551

Open
vpzomtrrfrt opened this issue Feb 21, 2024 · 1 comment
Open

Doesn't work with other transformers #551

vpzomtrrfrt opened this issue Feb 21, 2024 · 1 comment

Comments

@vpzomtrrfrt
Copy link

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(
@vpzomtrrfrt
Copy link
Author

not that it's actually working though, I don't understand the resolution for #4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant