Skip to content

Browserify support? #1596

@achingbrain

Description

@achingbrain

Has anyone had any luck with using swagger-ui with Browserify?

I have an app.js file with the follwing:

var SwaggerUi = require('swagger-ui')

var swaggerUi = new SwaggerUi({
  // ... options
})
swaggerUi.load()

..and a gulp file with:

gulp.task('js', function () {
  return browserify({
    entries: ['./path/to/app.js']
  })
  .bundle()
  .pipe(source('app.js'))
  .pipe(gulp.dest('path/to/output/folder'))
})

Running gulp then results in:

> gulp

[17:39:10] Using gulpfile ~/path/to/gulpfile.js
[17:39:10] Starting 'js'...
events.js:141
      throw er; // Unhandled 'error' event
      ^

Error: Cannot find module './lib/auth' from '/path/to/my/project/node_modules/swagger-ui/dist'
    at /path/to/my/project/node_modules/browserify/node_modules/resolve/lib/async.js:55:21
    at load (/path/to/my/project/node_modules/browserify/node_modules/resolve/lib/async.js:69:43)
    at onex (/path/to/my/project/node_modules/browserify/node_modules/resolve/lib/async.js:92:31)
    at /path/to/my/project/node_modules/browserify/node_modules/resolve/lib/async.js:22:47
    at FSReqWrap.oncomplete (fs.js:82:15)

(paths changed to protect the innocent)

It looks like swagger-ui inlines swagger-client which has a bunch of calls to require which try to find a non-existent ./lib/auth file.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions