{"id":23005,"library":"ycp-rollup-starter-lib","title":"ycp-rollup-starter-lib","description":"A bare-bones example repository demonstrating how to create a JavaScript library using Rollup, including importing a CommonJS module from node_modules. The library 'how-long-till-lunch' uses the 'ms' package to calculate time until lunch. This is a starter template, not a standalone library; version 1.0.16 is active but has no maintainer activity. Key differentiators: it provides CommonJS, ES module, and UMD builds via Rollup, with variations for Babel or Bublé transpilation. Not intended for production use as a dependency.","status":"active","version":"1.0.16","language":"javascript","source_language":"en","source_url":null,"tags":["javascript"],"install":[{"cmd":"npm install ycp-rollup-starter-lib","lang":"bash","label":"npm"},{"cmd":"yarn add ycp-rollup-starter-lib","lang":"bash","label":"yarn"},{"cmd":"pnpm add ycp-rollup-starter-lib","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used in the example library to parse time strings like '2 hours'.","package":"ms","optional":true}],"imports":[{"note":"The library exports a default function.","symbol":"default","correct":"import howLongTillLunch from './how-long-till-lunch';"},{"note":"Use the CommonJS file path for Node.js require.","wrong":"const howLongTillLunch = require('how-long-till-lunch');","symbol":"require","correct":"const howLongTillLunch = require('./how-long-till-lunch.cjs.js');"},{"note":"The UMD build exposes the library as a global variable.","symbol":"script tag","correct":"<script src=\"dist/how-long-till-lunch.umd.js\"></script>"}],"quickstart":{"code":"// Clone and build the library\ngit clone https://github.com/rollup/rollup-starter-lib.git\ncd rollup-starter-lib\nnpm install\nnpm run build\n\n// Create a test file: test.mjs\nimport howLongTillLunch from './dist/how-long-till-lunch.esm.js';\nconsole.log('Lunch in:', howLongTillLunch());\n\n// Run with node\nnode test.mjs","lang":"javascript","description":"Shows how to clone, build, and use the example library with ES module import syntax, demonstrating the standard workflow for this starter."},"warnings":[{"fix":"Clone the GitHub repo instead: git clone https://github.com/rollup/rollup-starter-lib.git","message":"This package is a starter template, not a published library. Do not install it as a dependency (npm install ycp-rollup-starter-lib) expecting a usable library.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Consider using Dependabot or Renovate for dependency updates.","message":"The Greenkeeper badge is outdated. Greenkeeper was acquired by Snyk and the service changed.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"If you use the starter as a base for your own library, move 'ms' to dependencies if your library uses it at runtime.","message":"The 'ms' dependency is a devDependency in the starter, but the example imports it as if it were a runtime dependency. This may confuse beginners.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Run npm install --save ms to add it as a runtime dependency, or ensure you run your application from within the project directory.","cause":"The 'ms' package is installed as a devDependency but your code uses it at runtime. Running the built library outside the project directory fails.","error":"Error: Cannot find module 'ms'"},{"fix":"Run npm install before npm run build.","cause":"Build script fails due to missing rollup or other dev dependencies.","error":"npm ERR! code ELIFECYCLE"},{"fix":"Use Node.js version 13 or later with --experimental-modules flag, or use the CommonJS bundle instead.","cause":"Trying to run the ES module file directly with older Node.js versions (<13) without ESM support.","error":"SyntaxError: Unexpected token 'export'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}