Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make ESM module #146

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

fix: make ESM module #146

wants to merge 4 commits into from

Conversation

Skn0tt
Copy link
Member

@Skn0tt Skn0tt commented Oct 20, 2023

Closes #145.

The code we were compiling into dist was CJS, not ESM. But when the user installed SuperJSON 2, which is ESM-only, it tried require-ing it. That failed, see #145. This PR fixes that, by making this package (including /tools) an ESM package as well.

@Skn0tt Skn0tt self-assigned this Oct 20, 2023
@Skn0tt
Copy link
Member Author

Skn0tt commented Oct 20, 2023

@mongolyy I prereleased this as v0.4.6-0, could you check if that fixes your problem before we release this?

@mongolyy
Copy link

@Skn0tt
Thanks for the improvement.

Unfortunately, however, my application fails with an error when I run the next build or next dev command.
I am attaching a terminal log from when I ran the next build command.

$ next build
 ✓ Linting and checking validity of types
   Disabled SWC as replacement for Babel because of custom Babel configuration ".babelrc" https://nextjs.org/docs/messages/swc-disabled
   Using external babel configuration from C:\Users\mongolyy\repos\next-app\app\.babelrc
Failed to compile.

./src/pages/_app.tsx
Error: [BABEL]: You appear to be using a native ECMAScript module plugin, which is only supported when running Babel asynchronously. (While processing: C:\Users\mongolyy\repos\next-app\app\node_modules\babel-plugin-superjson-next\dist\index.js)
    at loadCjsOrMjsDefault (C:\Users\mongolyy\repos\next-app\app\node_modules\next\dist\compiled\babel\bundle.js:1:35044)
    at loadCjsOrMjsDefault.next (<anonymous>)
    at requireModule (C:\Users\mongolyy\repos\next-app\app\node_modules\next\dist\compiled\babel\bundle.js:1:41464)
    at requireModule.next (<anonymous>)
    at loadPlugin (C:\Users\mongolyy\repos\next-app\app\node_modules\next\dist\compiled\babel\bundle.js:1:38200)
    at loadPlugin.next (<anonymous>)
    at createDescriptor (C:\Users\mongolyy\repos\next-app\app\node_modules\next\dist\compiled\babel\bundle.js:1:23608)
    at createDescriptor.next (<anonymous>)
    at evaluateSync (C:\Users\mongolyy\repos\next-app\app\node_modules\next\dist\compiled\babel\bundle.js:1910:740999)
    at C:\Users\mongolyy\repos\next-app\app\node_modules\next\dist\compiled\babel\bundle.js:1910:738372

However, I think this can be worked around by babel configuration, so I will try trial and error.
I will comment here if I make progress.
If you have any advice, I would appreciate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Doesn't work with superjson@2
2 participants