{"id":12921,"library":"build-modules","title":"UMD Package Builder (Webpack Wrapper)","description":"build-modules is a utility designed to simplify the creation of Universal Module Definition (UMD) packages from CommonJS modules, making them loadable via RequireJS or as traditional browser globals via a <script> tag. It acts as a lightweight wrapper around webpack (specifically webpack 3 as of v2.1.0), abstracting away much of its complexity for straightforward use cases. Its key differentiator is providing a simple API for UMD builds and exposing webpack's 'watch' feature without requiring direct webpack configuration. The current stable version is 2.2.2. The project appears to be no longer actively maintained, with the last commit in 2017, making its release cadence non-existent.","status":"abandoned","version":"2.2.2","language":"javascript","source_language":"en","source_url":"git://github.com/fresheneesz/buildModules","tags":["javascript"],"install":[{"cmd":"npm install build-modules","lang":"bash","label":"npm"},{"cmd":"yarn add build-modules","lang":"bash","label":"yarn"},{"cmd":"pnpm add build-modules","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core bundler dependency, build-modules is a wrapper around webpack (v3 as of 2.1.0).","package":"webpack","optional":false}],"imports":[{"note":"This package is primarily designed for CommonJS (Node.js) environments and does not officially support ESM import syntax.","symbol":"build","correct":"const build = require('build-modules')"},{"note":"The `build` function returns an EventEmitter instance; it is not a direct export from the module itself. Events ('done', 'error', 'warning') are emitted from this instance.","wrong":"import { emitter } from 'build-modules'","symbol":"emitter","correct":"const emitter = build(filepath, options); emitter.on('done', ...)"}],"quickstart":{"code":"const build = require('build-modules');\nconst path = require('path');\nconst fs = require('fs');\n\n// Create a dummy module for demonstration\nconst dummyModulePath = path.join(__dirname, 'rootDirectory', 'myModule.js');\nconst dummyModuleContent = `\nmodule.exports = function() {\n  console.log('Hello from myModule!');\n  return 'UMD bundled content!';\n};\n`;\nconst outputDirPath = path.join(__dirname, 'generatedFile');\nconst outputFilePath = path.join(outputDirPath, 'myModule.umd.js');\n\nfs.mkdirSync(path.dirname(dummyModulePath), { recursive: true });\nfs.writeFileSync(dummyModulePath, dummyModuleContent);\nfs.mkdirSync(outputDirPath, { recursive: true });\n\nconst emitter = build(dummyModulePath, {\n  output: {\n    path: outputDirPath,\n    name: 'myModule.umd.js'\n  },\n  name: 'myModule',\n  minify: false, // For easier inspection\n  sourceMap: false // For simpler output\n});\n\nemitter.on('done', function() {\n  console.log('Build Done!');\n  console.log(`Bundle created at: ${outputFilePath}`);\n  // Clean up dummy files\n  fs.unlinkSync(dummyModulePath);\n  fs.unlinkSync(outputFilePath);\n  fs.rmdirSync(path.dirname(dummyModulePath));\n  fs.rmdirSync(outputDirPath);\n  console.log('Cleaned up dummy files.');\n});\n\nemitter.on('error', function(e) {\n  console.error('Build Error:', e);\n});\n\nemitter.on('warning', function(w) {\n  console.warn('Build Warning:', w);\n});\n","lang":"javascript","description":"This quickstart demonstrates how to use `build-modules` to bundle a simple CommonJS module into a UMD package, handling build completion or errors."},"warnings":[{"fix":"Review the new API for `build(filepath, options)` and adjust parameters accordingly. Previously, it used `browserify` specific options, now it uses `webpack` related options.","message":"Version 2.0.0 introduced significant breaking changes, migrating from Browserify to Webpack as the underlying bundler. This resulted in entirely new parameters for the `build` function and a different architecture for configuring a watching rebuilder.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Consider migrating to a directly maintained bundler like Webpack, Rollup, or esbuild for UMD package creation, as `build-modules` is no longer actively developed.","message":"The module was explicitly deprecated in version 1.0.9 within its changelog. While development continued to version 2.2.2, the 'deprecated' status suggests the original author intended to move away from it. The project appears abandoned since 2017.","severity":"deprecated","affected_versions":">=1.0.9"},{"fix":"Implement logic to ignore the first duplicate 'done' event if exact single-emission behavior is critical for the initial build, or tolerate the duplicate as it only affects the first run.","message":"When using the `watch` option, the 'done' event is emitted twice on the very first successful build. Subsequent rebuilds will emit 'done' only once.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"For modern projects requiring up-to-date bundling features or better compatibility with contemporary JavaScript, it is strongly recommended to use a current version of webpack directly or another actively maintained bundler.","message":"As of v2.1.0, `build-modules` relies on webpack 3. Given webpack's rapid development cycle, this version is significantly outdated. Newer JavaScript features or advanced webpack configurations might not be supported or could lead to unexpected behavior.","severity":"gotcha","affected_versions":">=2.1.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Run `npm install build-modules` or `yarn add build-modules` in your project directory.","cause":"The package has not been installed or is not resolvable in the current environment.","error":"Error: Cannot find module 'build-modules'"},{"fix":"Ensure you are using `const build = require('build-modules')` for importing the module in a CommonJS environment.","cause":"Attempting to use ES module `import` syntax or an incorrect CommonJS `require` pattern for `build-modules`, which is a CommonJS module exporting a function.","error":"TypeError: build is not a function"},{"fix":"Verify the dependency is correctly installed, the path in your `require()` or `import` statement is correct, and consider using the `alias` option in `build-modules` options to resolve non-standard paths.","cause":"Webpack (underlying bundler) is unable to locate a required module within your source files.","error":"Module not found: Error: Can't resolve 'your-dependency'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"build-modules"}