{"_id":"browser-cjs","_rev":"4-36ade42128126fa12d9788c64ccee490","name":"browser-cjs","dist-tags":{"latest":"1.0.3"},"versions":{"1.0.0":{"name":"browser-cjs","version":"1.0.0","description":"A minimal CommonJS module loader for the browser environment.","main":"require.js","scripts":{"build":"babel --presets @babel/env --watch require.es6 --out-file require.js","build:sample:tasks":"babel --presets @babel/env,@babel/react --watch ./examples/TasksApp/src --out-dir ./Examples/TasksApp/dist"},"keywords":["require","js","browser","commonjs","cjs","module loader","nodejs"],"author":{"name":"Lucian Vuc","url":"https://github.com/luciVuc"},"license":"ISC","devDependencies":{"@babel/cli":"^7.4.4","@babel/core":"^7.4.5","@babel/preset-env":"^7.4.5","@babel/preset-react":"^7.0.0"},"dependencies":{},"gitHead":"6934643c3f2e38919901a6dc1cc31a982f2be84f","_id":"browser-cjs@1.0.0","_nodeVersion":"8.11.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-mMlXCZvDgXdjP8pWnPpUEW/0ds+Gw6POYKRAHeSz8A2Yj/1s+RwcSF2wB2WQr4aMFJXuk236zxu/uP1ZmWFGDg==","shasum":"facf7cbabcac2e77558f602ad14a6b77cafb23b9","tarball":"https://registry.npmjs.org/browser-cjs/-/browser-cjs-1.0.0.tgz","fileCount":4,"unpackedSize":15201,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdGbqpCRA9TVsSAnZWagAAhUcQAIyveXdH0Z+EgFcEZjGH\ncIgyl/UWL3RW5i/8egy9Y9HC9iYNy5+vNLBCRMdwj7JmP/KaityLzXwjWfKy\nQaoerzHSh4wPri1S6llQ4cu8lB0IEFBLeIaufooUiG08OwJH6J5ZkW6qUrPX\nc1KDF0BlPCqObUesFj3vxiiAqAlDwWDp1E6ZnXULasT8fyA6MkjlE3bDz2le\nRcLjE0lTrnzITZ8RSu8VaqzlE+ylBn3FTOI2zebFLYFuBsifHVyPk7lHK7XC\nhUSseinWKCURTz2GmqdyoOT6WP0JdN9sgqc/DavATlHam71LZqIa7dHW79MG\nbtt+sOi7kGgYv1fRsDKNvOYWGJkp/OX6mIkCGBko+FHQ4sJT5DSeozsUGLpk\nSOrvtJCnQLIY9sX6SMh/4MSop/OxpbW7GjV/ee+CdTZ10byjBSRI5azV2Vag\nSjWMfyOdGGXsugSmZ03b54FCWY6iB0Qs56/Y8WoQ7pYLMh0x5Hi3EBtFL1nY\n7pdVeOo2tI3sq6z6yuVeyEsiGpJafKz8uluNGcNSpMJo8q0jX1o2ZbZGSsZN\n6o1XcnYfQRJ8jY2iOlBEQ/I5JH5thnjxruFJP/5U60L0POI9AsmBmGFeoeNC\nBFQxBvAG1EhSAPuWp2GXQu0lwOVpFiwxKrZ3YV8Sf5wIlvRsmbuvzU+thwFy\n3zKd\r\n=K79R\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCv/CILNVhBt2XAPhyL6BXfbTbzkB2m3vV0OhlBmZvZ5wIgAOFYTMq4AnPU2aKk+xPQLnk3xhYOTWRGP0qxKt6i5PA="}]},"maintainers":[{"name":"lucivuc","email":"lucian.vuc@gmail.com"}],"_npmUser":{"name":"lucivuc","email":"lucian.vuc@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/browser-cjs_1.0.0_1561967272468_0.9032722195685827"},"_hasShrinkwrap":false},"1.0.1":{"name":"browser-cjs","version":"1.0.1","description":"A minimal CommonJS-compatible module loader for the browser environment.","main":"require.js","scripts":{"build":"babel --presets @babel/env --watch require.es6 --out-file require.js","minify":"uglifyjs require.js -o require.min.js"},"keywords":["require","js","browser","commonjs","cjs","module loader","nodejs"],"repository":{"type":"git","url":"git+https://github.com/luciVuc/browser-cjs.git"},"homepage":"https://github.com/luciVuc/browser-cjs#readme.md","author":{"name":"Lucian Vuc","url":"https://github.com/luciVuc"},"license":"MIT","devDependencies":{"@babel/cli":"^7.4.4","@babel/core":"^7.4.5","uglify-js":"^3.6.0"},"dependencies":{},"gitHead":"e33f998e205497dd2ab746a72bfe5bf59b65436d","bugs":{"url":"https://github.com/luciVuc/browser-cjs/issues"},"_id":"browser-cjs@1.0.1","_nodeVersion":"8.11.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-FLLa+GsVbhCAo9gWsVIC//y+xtdwUO1W9SCh76uBXHXW4cDMhZTA0VyEhdc2xvq4VCIL/51qP3yAeZqKI09sEw==","shasum":"4eff0433af2ed5bcff91006745b1e6d83ec4d4c5","tarball":"https://registry.npmjs.org/browser-cjs/-/browser-cjs-1.0.1.tgz","fileCount":5,"unpackedSize":20820,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdIwl9CRA9TVsSAnZWagAA9/cQAKUImryLk19Z0vJ+9m/7\nMfl3V8qaOXPZxOUp5Amws+FjJVa94s189nYoCLD/GCcMxndp8UtSvvFUWJGP\n9QHspIEIG3xSOM35YfSOntC/+NmPmleqwrltco3H1yfW2k0L1MeWtqyCrYYZ\nAnE5g9hGXkvZq0oO1X49nywI1GjGWGAU2LBejx3v57rbwMicE6m+WNOlgbW1\nk6e9idLDDAqQm2UOdkiZDsiMSsm1D/lxTAMUbqWrO3IDgPcZMXGDPHQkuQF4\nCWNntRm3fECKQyTlIVEjsXnnLOtc2ypRtF136c4G1tuUSc7hHPSIMKRkdFG0\nF5MoP0IFawQDf8K0BZpdy3e1ob/49vkiFIDvW6fbQPkVspN1ydo4jHt3W6jr\nR502feik9cAFVUh9DWhd9szjM9Aq+9KNqJEPng4CQfx6BteNr2vQhP8Nr/Z2\nywC2OijNbzdTCcqM6TMMx+pNiQh7L4JEpJ5u/JaNUFsSeKXCFxc5XlauTbnU\n5cjYvYd3aL5od1SkHpRrtGJ/p3AbGrY4uNsdc9hNNHzoS4n9mkv2+UlwxAxF\nM801kIJ9fYmMe3Mq7IAPNjccIcEEUy1X5hOkGZMLW/gvHX/ivRPyIH/GZNl1\n+KkpNlTBLIgtrFE5tzqmm5MF6r8wNqdPKnQDHOkM/fVpL72fcMz6jkMhPfvt\nd4gc\r\n=fkIh\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCUoK7Hrfj36GKgjUrBvPV3vo3ilAZZEoE7utcvYKp6OAIhAPetJttw5bqtPpB1nnyPwSEmQ30vm7bLpNHyeWGcDUPj"}]},"maintainers":[{"name":"lucivuc","email":"lucian.vuc@gmail.com"}],"_npmUser":{"name":"lucivuc","email":"lucian.vuc@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/browser-cjs_1.0.1_1562577277239_0.5172175417357501"},"_hasShrinkwrap":false},"1.0.2":{"name":"browser-cjs","version":"1.0.2","description":"A minimal CommonJS-compatible module loader for the browser environment.","main":"require.js","scripts":{"deploy":"npm run minify && npm run build:demo:eventList && bash deployChromeServer.sh","build":"babel --presets @babel/env src/require.es6 --out-file require.js","build:watch":"babel --presets @babel/env --watch src/require.es6 --out-file require.js","minify":"npm run build && uglifyjs require.js -o require.min.js","build:demo:eventList":"babel --presets @babel/env,@babel/react ./demo/EventListApp/src --out-dir ./demo/EventListApp/dist","build:watch:demo:eventList":"npm run build && babel --presets @babel/env,@babel/react --watch ./demo/EventListApp/src --out-dir ./demo/EventListApp/dist"},"keywords":["require","js","browser","commonjs","cjs","module loader","nodejs"],"repository":{"type":"git","url":"git+https://github.com/luciVuc/browser-cjs.git"},"homepage":"https://github.com/luciVuc/browser-cjs#readme.md","author":{"name":"Lucian Vuc","url":"https://github.com/luciVuc"},"license":"MIT","devDependencies":{"@babel/cli":"^7.4.4","@babel/core":"^7.4.5","@babel/preset-env":"^7.4.5","@babel/preset-react":"^7.0.0","mocha":"^6.2.0","sinon":"^7.3.2","uglify-js":"^3.6.0"},"dependencies":{},"gitHead":"1970a7c1fe262b65b3ec92bcf70d0bcf7be362b2","bugs":{"url":"https://github.com/luciVuc/browser-cjs/issues"},"_id":"browser-cjs@1.0.2","_nodeVersion":"8.11.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-xJEYZ7pbVxxh6ytQO9oGtTiKoeQlIk5d4X9e/gyNMrQwj8x9T0hvH5VR4nlBAmN3f+wllHSDiD8ZYlDk66ZVrA==","shasum":"3509f5b0bd7fb3563042f3f452d1a59bc8cef44b","tarball":"https://registry.npmjs.org/browser-cjs/-/browser-cjs-1.0.2.tgz","fileCount":27,"unpackedSize":77594,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdP/yDCRA9TVsSAnZWagAAhggP/jU466PF2yORO+qoxYbF\n+UMHd/0dvSiqgeiT5MCBmWCpXizC5cCDwW5/54V+XZw3uVfwb4OiVa4f6v2i\neBNLbm/FIDHh5ThQwKGgBtRAkZtgsubknzey1wbeXZ9VeYICvXFf5c1Qr15A\nwQPPbim69EWKVCpjHLgnIyhiAHdS+vnOicWkZnhwXa/rPN+P7wm1mRfylQHm\nf++vKNMo6DFX1vl5ZrSIdWd2PuqO1h9ux0opZlYN8pEg2bCou1QnTkHbmAbj\nYkNh0FsIcBU1snEbuI9fR0g+GMZU6h9Fb16BF/Z6EA3Sus8qhiGP+uhsuElu\n9cZ61PQs27HZkIipxROPnZXexxNhQGXT+hJxxqU58N3S2Tnb+UIKZ3cc3xYn\nToAbPQ70EoCIz9Wr8JKzJWTeuGzML6BcTPuiVuBGpM5aINDcFNVQxMQJ0HHT\nPIgDYC3LSE+OJ51g8R4E4vgo3MxJOOQ1a5JQBZKom4EiH9YsABdDhjfBX74s\nXJldNWFhZe+PVhuRXgHWZCNz8bW36F2zJ/IQfdVENgAf3+NTQJSzZgj378DB\nttWPkP7SR3J+jaw7nqlt7CU1q6TD3+4mLGRfEa42zy2x6yp8+YJASvLz/j4C\ndjzB3jjYA4sMTd0cfW+V9KoqEyLuH04B8FtH9g+ArivzLxdwSYi6oa+I7KdW\nKQk6\r\n=SQp3\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHDMO8wr+DC5ZKxnLiTZvsknrcv4keO3EDF9N7+5b42cAiEA+kOQF6WPu8OT5l6chWBUjHGrhUVIXJm/t+/nnc3g0YU="}]},"maintainers":[{"name":"lucivuc","email":"lucian.vuc@gmail.com"}],"_npmUser":{"name":"lucivuc","email":"lucian.vuc@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/browser-cjs_1.0.2_1564474498774_0.20359713276413438"},"_hasShrinkwrap":false},"1.0.3":{"name":"browser-cjs","version":"1.0.3","description":"A minimal CommonJS-compatible module loader for the browser environment.","main":"require.js","scripts":{"deploy":"npm run minify && npm run build:demo:eventList && bash scripts/deployChromeServer.sh","build":"babel --presets @babel/env src/require.es6 --out-file require.js","build:watch":"babel --presets @babel/env --watch src/require.es6 --out-file require.js","minify":"npm run build && uglifyjs require.js -o require.min.js","build:demo:eventList":"babel --presets @babel/env,@babel/react ./demo/EventListApp/src --out-dir ./demo/EventListApp/dist","build:watch:demo:eventList":"npm run build && babel --presets @babel/env,@babel/react --watch ./demo/EventListApp/src --out-dir ./demo/EventListApp/dist"},"keywords":["require","js","browser","commonjs","cjs","module loader","nodejs"],"repository":{"type":"git","url":"git+https://github.com/luciVuc/browser-cjs.git"},"homepage":"https://github.com/luciVuc/browser-cjs#readme.md","author":{"name":"Lucian Vuc","url":"https://github.com/luciVuc"},"license":"MIT","devDependencies":{"@babel/cli":"^7.4.4","@babel/core":"^7.4.5","@babel/preset-env":"^7.4.5","@babel/preset-react":"^7.0.0","mocha":"^6.2.0","sinon":"^7.3.2","uglify-js":"^3.6.0"},"dependencies":{},"gitHead":"09b229d2e9ca0e03e6fdefbdebed6555e38bead1","bugs":{"url":"https://github.com/luciVuc/browser-cjs/issues"},"_id":"browser-cjs@1.0.3","_nodeVersion":"8.11.2","_npmVersion":"6.9.0","dist":{"integrity":"sha512-3Hd0PFtFs4jP+d1I4sAc0y7U/bOKsLRjWoz33sACEoO9nFO5T+fEjYE0mD30eXX5HzziqE/N0yLtPHFJqhwm5w==","shasum":"e479f780e6c57d47f8e3ab797737cc0b697c2ed7","tarball":"https://registry.npmjs.org/browser-cjs/-/browser-cjs-1.0.3.tgz","fileCount":27,"unpackedSize":77615,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdQUTZCRA9TVsSAnZWagAA+ewP+QHtUBsY2CoanPJo9qgR\ngIGdQkcVfamldA20XWBHopWqbYJQwHaEIMOtOTU1FsqwE8U9dlAkg49n4kpn\n6J4SAnoWwEs0/v7+5DTBkNMnwOhN1LYskXel/TF15SG/WKHVEd/PA6f4Hg5z\n/Zfsq24YD4ckrPS1A3yw+SO6UqjrGLEd1hzWFLuHT4uHFoav/eXMvf2W18to\nRc3uceMDY3yEWeWCcZPm+0luJN19DjxRpMlSoNl4bwvpUeJuTLSoJeI3i8i7\nx81mXKE/uN/ntnlH/qJ7FRBFlVbZcoCca+YA59KrqPJObILxVHW8ycyeILAZ\nupZUJTlk1qRe2Li8QYlh4xI2JRK9TzPsanotu6kHQ4NlbsyZqOjAHyl+uGnz\noVDuFixl6ciLl4+usJHyIf3x5+0MMS/QhPLAapg8crpgJCozTy/H6L6KWB5G\njlBZEHfACPzJ/pz4DWAIPGLvpvyVOr/GQ2qLUYMYu29TZbEXumHi7uRm4iyn\njsVTd8ttZd70qXbYdxbkJRTjeJivhl0UX1uVLkkcRWHTbAtE47CMlObTztn1\nlR2vdQu5BaC5lYh/C5gfTcE7mirWSAMG6ru9AdrflrwLUlSqgRCD8rUdfocL\nEvAWUq2pfEz9gdv2R/Bq/p9P+ylgImklSCo4F6jX7NRDzZv6N1jvKMxpXMNJ\ngDN3\r\n=dav4\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIETJB1eQQMJ74kIKK/mvySq30TW42mOp/5DCz97K4yxdAiARVlMlIvKaMpnrA994sxBgTOULC78xAy4QT+9vfPuVig=="}]},"maintainers":[{"name":"lucivuc","email":"lucian.vuc@gmail.com"}],"_npmUser":{"name":"lucivuc","email":"lucian.vuc@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/browser-cjs_1.0.3_1564558553035_0.8353571147185086"},"_hasShrinkwrap":false}},"time":{"created":"2019-07-01T07:47:52.467Z","1.0.0":"2019-07-01T07:47:52.603Z","modified":"2022-04-12T04:28:34.697Z","1.0.1":"2019-07-08T09:14:37.370Z","1.0.2":"2019-07-30T08:14:58.950Z","1.0.3":"2019-07-31T07:35:53.209Z"},"maintainers":[{"name":"lucivuc","email":"lucian.vuc@gmail.com"}],"description":"A minimal CommonJS-compatible module loader for the browser environment.","keywords":["require","js","browser","commonjs","cjs","module loader","nodejs"],"author":{"name":"Lucian Vuc","url":"https://github.com/luciVuc"},"license":"MIT","readme":"# [browser-cjs](#browser-cjs)\r\n\r\n> A minimal [*CommonJS*](http://eng.wealthfront.com/2015/06/16/an-introduction-to-commonjs/)-like module loader for the browser environment.\r\n\r\nAs a client-side [*CommonJS*](http://eng.wealthfront.com/2015/06/16/an-introduction-to-commonjs/) module loader, **[browser-cjs](#browser-cjs)** aims to implement a [Node.js](https://nodejs.org/)-like module loading utility in the browser environment. In other words, it defines in the global scope of the browser a utility function called `require`, whose role is to **synchronously** load (without the need of a JS bundler, such as [Webpack](http://webpack.github.io/) or [Browserify](http://browserify.org/)) JS modules defined with to the [*CommonJS*](http://eng.wealthfront.com/2015/06/16/an-introduction-to-commonjs/) module syntax.\r\n\r\n**Note:**\r\nIn a case when the runtime environment already supports the `require` utility function (such as the [ElectronJS](https://electronjs.org) environment, or the [NWJS](https://nwjs.io/) environment), **[browser-cjs](#browser-cjs)** will not override or replace the existing `require` function; instead, it will reuse it as-is.\r\n\r\n## Installation\r\n\r\nTo give **[browser-cjs](#browser-cjs)** a try install it with `npm`, using\r\n\r\n```sh\r\nnpm install browser-cjs\r\n```\r\n\r\nor\r\n\r\n```sh\r\nnpm install --save browser-cjs\r\n```\r\n\r\nand load it in your page from its installation package using an HTML `script` tag, as shown in the following example:\r\n\r\n```html\r\n<script src=\"/node_modules/browser-cjs/require.js\"></script>\r\n```\r\n\r\nAs an alternative, you may download a copy locally or reference it directly from [**unpkg**](`https://unpkg.com/browser-cjs/require.js`):\r\n\r\n```html\r\n// For production\r\n<script src=\"https://unpkg.com/browser-cjs/require.min.js\"></script>\r\n\r\n// For development\r\n<script src=\"https://unpkg.com/browser-cjs/require.js\"></script>\r\n```\r\n\r\n## Usage\r\n\r\nOnce the **[browser-cjs](#browser-cjs)** module loader is fully loaded, and its `require` utility function available in the browser's global scope, it is ready for loading content, which includes [CommonJS](http://eng.wealthfront.com/2015/06/16/an-introduction-to-commonjs/) modules and `JSON` data files.\r\n\r\n### Loading [CommonJS](http://eng.wealthfront.com/2015/06/16/an-introduction-to-commonjs/) modules\r\n\r\n[CommonJS](http://eng.wealthfront.com/2015/06/16/an-introduction-to-commonjs/) modules, or Javascript files in [CommonJS](http://eng.wealthfront.com/2015/06/16/an-introduction-to-commonjs/) module format, are files that expose JS functionality typically using the `module.exports` syntax. Here is an example of such a module:\r\n\r\n```js\r\nmodule.exports = 'This is a string';\r\n```\r\n\r\nTo use **[browser-cjs](#browser-cjs)** for loading and evaluating JS files in [CommonJS](http://eng.wealthfront.com/2015/06/16/an-introduction-to-commonjs/) module format, simply call the globally available function `require` with the name of the module file given as argument (as it's done in [`Node.js`](https://nodejs.org/)).\r\n\r\nFor instance, to load a module called `moduleName.js`:\r\n\r\n```html\r\n<script>\r\n  const moduleName = require(\"/path/to/moduleName.js\");\r\n  // ...\r\n  // The rest of the code goes here...\r\n</script>\r\n```\r\n\r\n**Important:**\r\n\r\n**It is necessary to specify the extension of the file (`.es6`, `.js`, etc.), because without the extension, **[browser-cjs](#browser-cjs)** will assume that `moduleName` is a directory and it will try to load the `/path/to/nodeModule/<package.main>` file, where `<package.main>` is the file `main` specified in the `package.json` (e.g.: `main: \"./index.js\"`).** (Please refer to the [Limitations](#limitations) section).\r\n\r\n### `JSON` data files\r\n\r\nIn addition to [*CommonJS*](http://eng.wealthfront.com/2015/06/16/an-introduction-to-commonjs/) modules, **[browser-cjs](#browser-cjs)** supports loading plain `JSON` files as well. However, it is important to keep in mind that **[browser-cjs](#browser-cjs)** loads content synchronously, and in most cases a synchronous operation is not the desired or recommended way of loading this type of files (unless there is a specific reason for that, such as loading configuration files, or other special cases in which a synchronous operation is acceptable, or even preferred over an asynchronous operation).\r\n\r\nThus, to let **[browser-cjs](#browser-cjs)** know that the content it has to load is not a module, but a `JSON` data file, the file name must end with the `.json` extension. Here are some examples of loading JSON files with **[browser-cjs](#browser-cjs)**'s `require` utility:\r\n\r\n```js\r\nconst config = require(\"/path/to/file/config.json\");\r\nconst package = require(\"/package.json\");\r\n```\r\n\r\n## Options\r\n\r\nTo allow the user to modify its default configuration, **[browser-cjs](#browser-cjs)** supports a set of options (or parameters), which includes:\r\n\r\n* `scripts` - a comma separated list of prerequisite non-CommonJS Javascript files,\r\n* `styles` - a comma separated list of stylesheets,\r\n* `base_dir` - the base URL (URI) to automatically prepend to all relative links. The default option is `base_dir=\"/\"`, and\r\n* `main` - the module with entry point role (the module to load and run first). The default value of `main` is `null`, in which case no module will be automatically loaded and executed.\r\n\r\nThese options can be passed as data attributes (using the `data-` prefix) to the `script` tag that loads the library as in the following example:\r\n\r\n```html\r\n<script\r\n  src=\"/node_modules/browser-cjs/require.js\"\r\n  data-base_dir=\"./dist\"\r\n  data-styles=\"./css/style.css\"\r\n  data-scripts=\"https://unpkg.com/react@16/umd/react.production.min.js, https://unpkg.com/react-dom@16/umd/react-dom.production.min.js, https://unpkg.com/prop-types@15.6/prop-types.min.js\"\r\n  data-main=\"./dist/index.js\">\r\n</script>\r\n```\r\n\r\nIn the example above the `script` tag, in addition to loading the `require.js` file, specifies the base URL for all relative links, specifies also a stylesheet and some pre-requisite (probably non-CommonJS compatible) scripts to load, and indicates the file to load and execute first as the main entry point of the application.\r\n\r\n### Example\r\n\r\nNext is a sample app that uses **[browser-cjs](#browser-cjs)**' `require` function to load the `package.json` file of this package and display the package `name`, `description` and `version` of the package, as well as the `version` of the preloaded `jquery` library.\r\n\r\n```html\r\n<!DOCTYPE html>\r\n<html>\r\n  <head>\r\n    <meta charset=\"utf-8\">\r\n    <title>Browser-CJS Example</title>\r\n\r\n    <!-- load the <b>browser-cjs</b> library -->\r\n    <script src=\"../../../../require.js\" data-scripts=\"https://unpkg.com/jquery@3.3.1/dist/jquery.js\">\r\n    </script>\r\n\r\n    <!-- the main script -->\r\n    <script>\r\n      window.addEventListener(\"load\", () => {\r\n        const package = require(\"./package.json\");\r\n        $(\"#root\").html(`<div>\r\n          <h2>${package.name}</h2>\r\n          <p>${package.description}</p>\r\n          <div>Version: <span>${package.version}</span></div>\r\n          <hr />\r\n          <div>jQuery version: <span>${$.fn.jquery}</span></div>\r\n        </div>`);\r\n      });\r\n    </script>\r\n  </head>\r\n\r\n  <body>\r\n    <div id=\"root\"></div>\r\n  </body>\r\n</html>\r\n```\r\n\r\n## Limitations\r\n\r\nSince this library is not designed for the [`Node.js`](https://nodejs.org/) environment, but rather for the browser environment, it will behave slightly different than the module loader of [`Node.js`](https://nodejs.org/), and the main reason is that the browser's limitations and constrains still apply.\r\n\r\nOne major difference is that the `require()` function of **[browser-cjs](#browser-cjs)**, unlike the `require()` function of [`Node.js`](https://nodejs.org/), resolves the path to a given module relative to the current directory, the root directory or the `data-base_dir` script attribute, if provided.\r\n\r\nFor this reason, modules located inside `npm` packages must be requested by their full path relative to the `node_modules` directory, as in the following examples:\r\n\r\n```js\r\nconst atob = require(\"/node_modules/atob\");\r\nconst use = require(\"/node_modules/use\");\r\nconst wrappy = require(\"/node_modules/wrappy\");\r\n```\r\n\r\nacknowledging that due to the client-side limitations and constrains there is no guarantee that all [`Node.js`](https://nodejs.org/) modules will be able to run, or run correctly, in the browser environment.\r\n\r\n## Version\r\n\r\n1.0.3\r\n\r\n## Demo Apps\r\n\r\nHere is a list of sample demo apps that use **[browser-cjs](#browser-cjs)** as a module loader:\r\n\r\n* [EventListDemo](./demo/EventListApp/readme.md#eventlistdemo) App - A simple ReactJS app, that displays a list of upcoming events, uses browser-cjs as a module loader for the custom ReactJS Components it is built with.\r\n","readmeFilename":"README.md","homepage":"https://github.com/luciVuc/browser-cjs#readme.md","repository":{"type":"git","url":"git+https://github.com/luciVuc/browser-cjs.git"},"bugs":{"url":"https://github.com/luciVuc/browser-cjs/issues"}}