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

Integration with Next.js #9349

Closed
aktoriukas opened this issue Dec 19, 2022 · 4 comments
Closed

Integration with Next.js #9349

aktoriukas opened this issue Dec 19, 2022 · 4 comments
Assignees

Comments

@aktoriukas
Copy link

Type of issue

Set-up with Next.js

Description

Facing issue with Nextjs integration with Prebid.js. Following example from ( https://www.npmjs.com/package/prebid.js ) by extending webpack config in next.config.js:

let path = require("path")

module.exports = {
  reactStrictMode: true,
  webpack: (config, { buildId, dev, isServer, defaultLoaders, nextRuntime, webpack }) => {

    config.module.rules.push({
      test: /.js$/,
      include: new RegExp(`\\${path.sep}prebid\\.js`),
      use: [
        {
          loader: "babel-loader",
          options: require("prebid.js/.babelrc.js"),
        },
      ],
    })

    return config
  },
}

after this while trying to import prebid.js facing this error:

import {getGlobal} from './prebidGlobal.js';
^^^^^^

SyntaxError: Cannot use import statement outside a module

Steps to reproduce

Fresh install of Nextjs

Test page

Expected results

Actual results

Platform details

Nextjs "12.2.2"
React "^17.0.2"

Other information

@aktoriukas
Copy link
Author

here is a code sample: codesandbox

@ChrisHuie
Copy link
Collaborator

@aktoriukas do you need the server side rendering from Next? I am able to get working with create-react-app but Next's build process is a bit more complex?

@aktoriukas
Copy link
Author

aktoriukas commented Jan 13, 2023

@ChrisHuie it can be client or server side , it does not really matter that much for now. Can you share process that you follow integrating with React and also Next.js if you manage?

I have managed integrate it by downloading generated file from prebid .
But that's not what i'm after. I would like import them from library ( NPM ). Something like codesandbox example above.

@ChrisHuie
Copy link
Collaborator

We think this pr will fix your current issue with Next -> #9558

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

No branches or pull requests

2 participants