Skip to content

[bug] cannot use with next.js #15

@tx46

Description

@tx46

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions