This example uses OpenLayers v10.9.0. The latest is v.
Edit

#### MapServer WMS

mapserver 5 wms 13 image 8

#####

Example of a MapServer WMS map.

Example of a map generated using a MapServer WMS, with an `ImageSource` and a `createLoader` function.
You only need to set `serverType` if `hidpi` is `true`. On high-DPI screens, OpenLayers automatically calculates the map's `pixelRatio` and sends an additional MAP_RESOLUTION parameter to MapServer to ensure fonts and symbols render correctly.

##### main.js

    import Map from 'ol/Map.js';
    import View from 'ol/View.js';
    import ImageLayer from 'ol/layer/Image.js';
    import ImageSource from 'ol/source/Image.js';
    import {createLoader} from 'ol/source/wms.js';

    const layer = new ImageLayer({
      source: new ImageSource({
        loader: createLoader({
          url: 'https://demo.mapserver.org/cgi-bin/wms?',
          params: {
            LAYERS: ['bluemarble,country_bounds,cities'],
            VERSION: '1.3.0',
            FORMAT: 'image/png',
          },
          projection: 'EPSG:4326',
          // note serverType only needs to be set when hidpi is true
          hidpi: true,
          serverType: 'mapserver',
        }),
      }),
    });

    const map = new Map({
      layers: [layer],
      target: 'map',
      view: new View({
        projection: 'EPSG:4326',
        center: [0, 0],
        zoom: 2,
      }),
    });

##### index.html

    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="UTF-8">
        <title>MapServer WMS</title>
        <link rel="stylesheet" href="node_modules/ol/ol.css">
        <style>
          .map {
            width: 100%;
            height: 400px;
          }
        </style>
      </head>
      <body>
        <div id="map" class="map"></div>

        <script type="module" src="main.js"></script>
      </body>
    </html>

##### package.json

    {
      "name": "mapserver-wms",
      "dependencies": {
        "ol": "10.9.0"
      },
      "devDependencies": {
        "vite": "^3.2.3"
      },
      "scripts": {
        "start": "vite",
        "build": "vite build"
      }
    }