rescript-classnames icon indicating copy to clipboard operation
rescript-classnames copied to clipboard

[bug] cannot use with next.js

Open tx46 opened this issue 3 years ago • 1 comments

Using Next.js 12 or whatever the latest version is together with rescript-classnames is not working. Using either Cn.make or Cx.cx (with or without open) generates the following error message:

Server Error

SyntaxError: Unexpected token 'export'
This error happened while generating the page. Any console logs will be displayed in the terminal window.
Call Stack
<unknown>
file:/home/.../node_modules/rescript-classnames/src/Cn.bs.js (16)
Object.compileFunction
node:vm (360:18)
wrapSafe
node:internal/modules/cjs/loader (1049:15)
Module._compile
node:internal/modules/cjs/loader (1084:27)
Module._extensions..js
node:internal/modules/cjs/loader (1174:10)
Module.load
node:internal/modules/cjs/loader (998:32)
Module._load
node:internal/modules/cjs/loader (839:12)
Module.require
node:internal/modules/cjs/loader (1022:19)
require
node:internal/modules/cjs/helpers (102:18)
rescript-classnames/src/Cn.bs.js
file:/home/.../.next/server/pages/index.js (62:18)
__webpack_require__
file:/home/.../.next/server/webpack-runtime.js (33:42)

I suspect this has to do with ESM modules, it might even be possible to fix it by just renaming the file Cn.bs.js to Cn.mjs

tx46 avatar Aug 04 '22 09:08 tx46

I changed module spec from commonjs to es6 in 7.0.0. Let me know if it makes any difference.

alex35mil avatar Feb 16 '24 14:02 alex35mil