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

ES6 module system not supported. #122

Open
Jeremboo opened this issue Mar 21, 2024 · 1 comment
Open

ES6 module system not supported. #122

Jeremboo opened this issue Mar 21, 2024 · 1 comment

Comments

@Jeremboo
Copy link

Hi,

My project is setup with a next.config.mjs which use the ES module system instead of CommomJS.

And the project doesn't look to work with ES6:

import createNextPluginPreval from 'next-plugin-preval/config'

...

Error [ERR_MODULE_NOT_FOUND]: Cannot find module

import createNextPluginPreval from 'next-plugin-preval' looks to exists but is just a [Function (anonymous)] who does nothing.

Maybe should you just place the config.js into the dist/ folder ? I can do a PR if you want.

@rickdrumond
Copy link

👋
Can confirm this is still an issue.
I was able to work around it by wrapping the require in a CJS file:

// prevalWrapper.cjs

const createNextPluginPreval = require('next-plugin-preval/config');
const withNextPluginPreval = createNextPluginPreval();

module.exports = withNextPluginPreval;

Then importing the wrapper:

// next.config.mjs

import withNextPluginPreval from './prevalWrapper.cjs';

const nextConfig = { /* options */ };

export default withNextPluginPreval(nextConfig);

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