CommonJS
Require the constructor from a browser bundle. The example build handles the stylesheet import and runs the app after the input exists.
App source
main.cjs
const DateRangePicker = require('daterangepicker');
require('daterangepicker/daterangepicker.css');
const input = document.querySelector('#dates');
new DateRangePicker(input, { singleCalendar: true });index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Report dates</title>
<link rel="stylesheet" href="../../daterangepicker.css">
<script type="module" src="../assets/commonjs.js"></script>
</head>
<body>
<label>Report dates<input id="dates" type="text"></label>
</body>
</html>Run this example locally
Serve the website directory over HTTP and open /examples/commonjs/. To edit the app, change its files in example/integrations/commonjs and run these commands from example/integrations.
npm ci
npm run build