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

Microbundle Compile Error Next.js #117

Open
janniclas opened this issue Apr 8, 2023 · 1 comment
Open

Microbundle Compile Error Next.js #117

janniclas opened this issue Apr 8, 2023 · 1 comment

Comments

@janniclas
Copy link

When adding this component to a new next.js application I got the following compile error:

SyntaxError: Cannot use import statement outside a module

After a lot of digging around I found this GitHub Issue describing a similar problem when using microbundle.
The suggested solution to change the "export" value in the package.json to the following worked for me

"exports": { "import": "./dist/react-cytoscape.modern.js", "require": "./dist/react-cytoscape.js" },

However, I'm completely unfamiliar with microbundle, @akx would u mind briefly looking into this if it makes sense to update the package.json with this code snippet?

@TheApeMachine
Copy link

That should go in your NextJS config, unless you're under version 13. NextJS has built in support to fix this now. For instance, from another project I was working on, here is my next.config.js (fixing the same error message for three older packages)

/** @type {import('next').NextConfig} */
const withTM = require('next-transpile-modules')(['@arcgis/core', '@stencil/core', '@esri/calcite-components']);

module.exports = withTM({
  reactStrictMode: true,
});

There should be no need to install any transpile package, it should be included.

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

No branches or pull requests

2 participants