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

Mountebank not working when bundled #621

Open
SuperOleg39 opened this issue May 27, 2021 · 0 comments
Open

Mountebank not working when bundled #621

SuperOleg39 opened this issue May 27, 2021 · 0 comments
Projects

Comments

@SuperOleg39
Copy link

Prerequisites

Webpack can bundle server code at single JS file, with all dependencies.
This allows to create Docker container with one server.js bundle, without unnecessary node_modules.
Some framework, NextJS for example, create one complete server bundle.

Problem

After mountebank integration as middleware, at existing application endpoint (see #610 issue), mountebank can be a part of this application server bundle.

At current time, bundled mountebank throw few errors:

  1. errorhandler middleware try to read files from file system, on run server code, here code, and error example - ENOENT: no such file or directory, open 'http:/localhost:4000/dist/server/public/style.css
  2. mountebank hardcode path to templates here, error example - Error: Failed to lookup view "imposters" in views directory "http:/localhost:4000/dist/server/views"
  3. mountebank hardcode path to static resources here, impossible to load working HTML on different application endpoint
  4. (low priority, ease to fix)express view try to require ejs on GET request to /imposters, use dynamic require and webpack can't bundle ejs module, more about problem here

Possible solutions

Working solution for 1, 2 and 4 cases - mark mountebank as external for webpack, and copy few libraries from node_modules to Docker container.
Problem here - you need to change Dockerfile.

Another solutions for errors from list:

  1. Remove errorhandler or require it only on development mode
  2. Don't have a solution =(
  3. Add option publicPath to mountebank
  4. Require ejs manually

Summary

1, 2 and 4 cases solvable with externals, if nobody have better solution.
But 3 case, looks like we need a publicPath in all cases.

@bbyars bbyars added this to Wishlist in Roadmap Mar 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Roadmap
Wishlist
Development

No branches or pull requests

1 participant