exceptionless / Exceptionless.JavaScript

Exceptionless JavaScript client
http://exceptionless.com
Apache License 2.0
59 stars 24 forks source link

Can't Use exceptionless/react on Next.js project #103

Closed polluterofminds closed 1 year ago

polluterofminds commented 3 years ago

When trying to import the @exceptionless/react package in Next.js, the following error occurs:

SyntaxError: Named export 'fromError' not found. The requested module 'stacktrace-js' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'stacktrace-js';
const { fromError } = pkg;

Steps to reproduce:

  1. npx create-next-app app-name
  2. npm i @exceptionless/react
  3. in pages/index.js add the import line at the top: import { Exceptionless } from "@exceptionless/react";
niemyjski commented 3 years ago

@polluterofminds Did you enable esm support as described here: https://nextjs.org/blog/next-11-1#es-modules-support

polluterofminds commented 3 years ago

Just tested this, and I get the same error. Looks like this is a known Next.js issue: https://github.com/vercel/next.js/issues/25454

niemyjski commented 3 years ago

Did their fix solve this? I think we need to bring in stacktrace.js and convert it to be 100% esm

niemyjski commented 1 year ago

I just confirmed this is still broken in 2.0.1 but is fixed in main! I tested it by running npm install --save ../Exceptionless.JavaScript/packages/react