-
Notifications
You must be signed in to change notification settings - Fork 9k
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
Latest package not working with CommonJS #8311
Comments
Documentation for current SwaggerUI build fragments: #7831 |
This includes: - ESM - CommonJs Refs #8311
This issue have been addressed in #9137. Following exports field has been used: "exports": {
"./dist/swagger-ui.css": "./dist/swagger-ui.css",
"./dist/oauth2-redirect.html": "./dist/oauth2-redirect.html",
"./dist/swagger-ui-standalone-preset": "./dist/swagger-ui-standalone-preset.js",
".": {
"browser": {
"import": "./dist/swagger-ui-es-bundle-core.js",
"require": "./dist/swagger-ui.js"
},
"node": {
"import": "./dist/swagger-ui-bundle.js",
"require": "./dist/swagger-ui-es-bundle.js"
},
"default": {
"import": "./dist/swagger-ui-bundle.js",
"require": "./dist/swagger-ui-es-bundle.js"
}
}
} Explanation:
|
This includes: - ESM - CommonJs Refs #8311
Fixed by #9137
|
Q&A (please complete the following information)
Content & configuration
Example Swagger/OpenAPI definition:
# your YAML here
Swagger-UI configuration options:
Describe the bug you're encountering
I am getting following error while starting the nodejs server
'Cannot use import statement outside a module'
Stack: C:\Development\connect-supplier-link\Dev\ConnectSupplierLink\node_modules\react-syntax-highlighter\dist\esm\light.js:1
import highlight from './highlight';
^^^^^^
To reproduce...
Steps to reproduce the behavior:
Try to use SwaggerUI package with CommonJS
const SwaggerUI = require('swagger-ui');
SwaggerUI({
url: 'http://localhost:7071/api/swagger.json',
dom_id: '#body'
})
Getting following error on server startup:
'Cannot use import statement outside a module'
Stack: C:\Development\connect-supplier-link\Dev\ConnectSupplierLink\node_modules\react-syntax-highlighter\dist\esm\light.js:1
import highlight from './highlight';
^^^^^^
Expected behavior
I should be able to use SwaggerUI with CommonJS
Screenshots
Additional context or thoughts
The text was updated successfully, but these errors were encountered: