shakacode / shakacode/rescript-classnames

[bug] cannot use with next.js

Open
#15 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
ReScript
Stars
109
Forks
6
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with Next.js and rescript-classnames using Cn.make or Cx.cx, then inspect node_modules/rescript-classnames/src/Cn.bs.js and the generated .next/server/pages/index.js entry point. The work is done when page generation no longer raises Unexpected token 'export' for these APIs.

Written by the indexing model from the issue text.

Assessment

Tech stack
next.js
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.