{"id":20548,"library":"shakapacker","title":"Shakapacker","description":"Shakapacker is the official, actively maintained successor to rails/webpacker that integrates Webpack v5+ (or Rspack for 10x faster builds) with Rails for managing app-like JavaScript modules. Version 10.0.0 requires Node >=20 and supports Rspack v2, esbuild, and SWC loaders. Released by ShakaCode with regular cadence (v9.6.2 latest stable, v10.0.0 recent), it provides a robust Ruby gem and npm package for configuration, asset manifest generation, and development server integration. Key differentiators: native Rspack support, semantic config diffing (bin/diff-bundler-config), and compatibility with jsbundling-rails alternatives. Ships TypeScript types.","status":"active","version":"10.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/shakacode/shakapacker","tags":["javascript","typescript"],"install":[{"cmd":"npm install shakapacker","lang":"bash","label":"npm"},{"cmd":"yarn add shakapacker","lang":"bash","label":"yarn"},{"cmd":"pnpm add shakapacker","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core bundler dependency","package":"webpack","optional":false},{"reason":"Required for CLI and dev server","package":"webpack-cli","optional":false},{"reason":"Development server with HMR","package":"webpack-dev-server","optional":true},{"reason":"Generates manifest.json for asset map","package":"webpack-assets-manifest","optional":false},{"reason":"Alternative bundler core for Rspack support","package":"@rspack/core","optional":true}],"imports":[{"note":"Named export, not default. Available in ESM and CommonJS contexts.","wrong":"const shakapacker = require('shakapacker')","symbol":"shakapacker","correct":"import { shakapacker } from 'shakapacker'"},{"note":"Common for deployment scripts; must be imported from 'shakapacker/deployment' subpath.","wrong":null,"symbol":"ShakapackerDeployment","correct":"import { ShakapackerDeployment } from 'shakapacker/deployment'"},{"note":"Config class is separate from main package export. Ensure correct subpath import.","wrong":"import { ShakapackerConfig } from 'shakapacker'","symbol":"ShakapackerConfig","correct":"import { ShakapackerConfig } from 'shakapacker/config'"}],"quickstart":{"code":"// Install: yarn add --dev shakapacker@^10.0.0\n// Then configure webpack.config.js or rspack.config.js\nconst { shakapacker } = require('shakapacker');\n\n// Example: get public output path\nconst publicPath = shakapacker.publicOutputPath;\nconsole.log('Public path:', publicPath);\n\n// For deployment manifest\nconst { ShakapackerDeployment } = require('shakapacker/deployment');\nconst deployment = new ShakapackerDeployment({ manifestPath: './public/packs/manifest.json' });\ndeployment.deploy();\n\n// For configuration reading\nconst { ShakapackerConfig } = require('shakapacker/config');\nconst config = new ShakapackerConfig();\nconsole.log('Dev server enabled:', config.devServer?.enabled);","lang":"javascript","description":"Shows basic imports from shakapacker npm package: main export, deployment, and config subpaths."},"warnings":[{"fix":"Update Node to 20.x or later. Verify with node --version.","message":"Shakapacker v9 dropped support for Node < 20. Upgrade Node.js to 20+ before updating.","severity":"breaking","affected_versions":">=9.0.0 <10"},{"fix":"Replace event-based hooks with direct method overrides in ShakapackerConfig subclass.","message":"Shakapacker v10 removed deprecated event system hooks (pre_event, post_event). Use new hooks API.","severity":"breaking","affected_versions":">=10.0.0"},{"fix":"Switch to import { shakapacker } from 'shakapacker' in ESM context, or use dynamic import() if mixed.","message":"Using 'require('shakapacker')' with CommonJS is deprecated in v10. Use ESM imports.","severity":"deprecated","affected_versions":">=10.0.0"},{"fix":"Add '@rspack/core' to dependencies. If using webpack, ignore this warning.","message":"Rspack support requires peer dependency '@rspack/core' (>=1.0.0 or >=2.0.0-0). Missing this will cause silent fallback to webpack.","severity":"gotcha","affected_versions":">=9.0.0"},{"fix":"Uncomment 'headers' section in config/shakapacker.yml to restore Access-Control-Allow-Origin: *.","message":"DevServer CORS headers are disabled by default since v9.6.0. Cross-origin asset loading breaks if Rails and dev server on different ports.","severity":"gotcha","affected_versions":">=9.6.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run 'yarn add shakapacker@^10.0.0' or 'npm install shakapacker@^10.0.0'.","cause":"Typo or missing dependency; shakapacker npm package not installed.","error":"Module not found: Error: Can't resolve 'shakapacker'"},{"fix":"Replace 'bin/shakapacker --watch' with 'bin/shakapacker-watch --watch' in Procfile or CLI.","cause":"Deprecated --watch flag removed in v10; use 'bin/shakapacker-watch' instead.","error":"Unknown option: '--watch' for shakapacker"},{"fix":"Update webpack config to use cacheGroups instead of chunks. Refer to webpack 5 migration guide.","cause":"webpack v5 removed splitChunks.chunks; use optimization.splitChunks.cacheGroups.","error":"WebpackOptionsValidationError: Invalid configuration object: configuration has an unknown property 'optimization.splitChunks.chunks'"},{"fix":"Upgrade to shakapacker v9.6.1+ which adds defined?(Rails) guard, or manually set RAILS_ENV.","cause":"Calling Shakapacker::Env#current outside of Rails context (e.g., in bin/dev).","error":"Env#current raises NameError: undefined method `env' for nil:NilClass"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}