Facing module issue while doing purescript migration to v0.15.15

Hi,
I am currently working on Purescript migration from 0.13 to latest version v0.15.15.
i am stuck with one issue while using the purescript module in my react typescript project.

The pure script project is bundled as single js file using below command.
spago bundle-module --main Module --to index.js

Since v15 was using esbuild internally and generated es module file. But when i try to run the react project, i am getting below error.

export {
^^^^^^
SyntaxError: Unexpected token ‘export’ in the index.js file.

Any one has idea like why i am getting this error?

Version details
spago : 0.20.8
purescript : 0.15.15

Thanks in advance.

The error is because the program you’re using to run the react project expects index.js to be a CommonJS module, but spago is creating an ES Module.

What command (and version) are you using to run the react project?


A little more detail:

You can read a little about the differences between CJS and ES in this StackOverflow answer, and it also links to more in-depth articles from the NodeJS documentation.

You’re getting the error now because in 0.14 PureScript added support for ES modules, and in 0.15 support for CommonJS modules was removed.

1 Like