tss-react: Updating to 4.1.1 caused import error

I upgraded from 4.0.0 to 4.1.1, and got the following error when building my project:

import { createMakeStyles } from "./makeStyles";
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at Object.compileFunction (node:vm:360:18)
    at wrapSafe (node:internal/modules/cjs/loader:1049:15)
    at Module._compile (node:internal/modules/cjs/loader:1084:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1174:10)
    at Module.load (node:internal/modules/cjs/loader:998:32)
    at Module._load (node:internal/modules/cjs/loader:839:12)
    at Module.require (node:internal/modules/cjs/loader:1022:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/dru/code/fitted/frontend-retailer-portal-test/frontend-retailer-portal/node_modules/@fitted/shared/dist/utils/make-styles.js:4:21)
    at Module._compile (node:internal/modules/cjs/loader:1120:14) {
  type: 'SyntaxError'
}

Node.js v18.6.0

I did not try 4.1.0

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 21 (9 by maintainers)

Commits related to this issue

Most upvoted comments

I see the problem, itโ€™s something else

@garronej I believe this is due to the module being removed from the tsconfig.json. This would change the value from "CommonJS" to the default (which is "ES6"/"ES2015" for when the target is not "ES3" or "ES5").

So, I think to solve, the commonjs build just needs to set the module option back to "CommonJS"

@garronej @jiby-aurum No problem, and thank you for fixing it so quick! ๐Ÿ˜Š