Skip to content

Version 4.10.3 causes next.js app to fail run due to a SyntaxError #7970

@simPod

Description

@simPod

Similar to #7944 but for next.js

Q&A (please complete the following information)

  • OS: macos/linux
  • Method of installation: npm
  • Swagger-UI version: 4.10.3

Content & configuration

{
  "compilerOptions": {
    "target": "ES6",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,

Describe the bug you're encountering

In next.js app build crashes on

SyntaxError: Cannot use import statement outside a module
    at Object.compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1027:15)
    at Module._compile (node:internal/modules/cjs/loader:1063:27)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:999:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/path/node_modules/swagger-ui-react/commonjs.js:10:53)
    at Module._compile (node:internal/modules/cjs/loader:1099:14) {
  type: 'SyntaxError'
}

To reproduce...

  • Require swagger react
  • import SwaggerUI from 'swagger-ui-react';

Expected behavior

No err

Additional context or thoughts

It worked ok on 4.2.1

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions