Updated ReScript + NextJS template (Webpack 5 edition)

Following up on the recent ReScript 9.1.2 release, I updated my rescript-nextjs-template to the latest Next & ReScript version.

It now comes with Webpack 5 and ES6 compilation enabled by default. The changes are running on rescript-lang.org as well, so it has proven to be stable.

Thanks to @jorge / @kanishka for kicking off the discussion to fix some weird node_modules / ES6 module related issues.

Check it out here:


Very cool, thanks!
Is it better to run next and rescript in different tabs or concurrently? I have been using concurrent so I’m curious about your approach

I run the compiler process separately to keep it simple mostly.

1 Like

I have been thinking lately that I wish next build was fast enough where I could run it together in some sort of watch mode along side bsb -make-world -w and next dev, to get all build errors immediately.

1 Like

I am strangely able to upgrade without adding the patchResDeps hack, even though I encountered the error that you encountered in the past…

I see now that 7.1.0 removed the main requirement:

When trying to locate the packages you are trying to transpile, since v5, next-transpile-modules tries to resolve your module names you pass to it, which required a valid main or exports field. It will now tries to resolve directly to its package.json.

hm, interesting. Would you mind trying the same changes to rescript-lang.org? I feel like you are running into a happy path there.

does next js support vite?

1 Like

Next hired the creator of webpack, so I reckon they will not even be thinking about switching to anything else there


I was trying ntm v7.1 so I removed node_modules to attempt next.config.js without the patchResDeps but now I get this error

Could not resolve  @reasonml-community/graphql-ppx/ppx in /Users/jorge/code/app
Fatal error: exception Failure("@reasonml-community/graphql-ppx/ppx not found when resolving ppx-flags")
The terminal process "/bin/zsh '-c', 'npm run build-brezza'" terminated with exit code: 2.

any clue what’s happening here? I tried to roll back and it still throws the error :scream:


Seems that it was because I had graphql-ppx in my dependencies instead of my dev-dependencies in package.json. It’s working now

1 Like

If we stored static data and markdown strings as constants in ReScript modules, and people figure out how to use esm modules with vite and ReScript, it feels like a static site generator will become irrelevant.

Update: GitHub - brillout/vite-plugin-ssr: Vite SSR Plugin. Simple, full-fledged, do-one-thing-do-it-well. (from nextjs vite github discussion thread) - WOW! Imagine having 50 transitive deps instead of 250, for a hello world static site.

@ryyppy when using this template with rescript@9.1.3 we are seeing an error when working with the /pages .resi files for:

type props
type params
Next.GetServerSideProps.t<props, params, _>
let default: props => React.element

Not sure I completely understand what this error means and how to fix it.

Thanks in advance, once fixed, I would love to add a getServerSideProps example page to the repo.