{"id":15943,"library":"y-src-pack","title":"y-src-pack Resource Bundler","description":"y-src-pack is a JavaScript utility designed to bundle various resource files (like media, configuration, or data) into a single JavaScript file, making them synchronously accessible via a generated API. It supports bundling for web applications, Node.js environments, and integration with Webpack. The current stable version is 1.0.15. Unlike traditional bundlers focused primarily on JavaScript and CSS, y-src-pack emphasizes consolidating arbitrary application assets, exposing them through a customizable JavaScript variable or Node.js module. Its primary release cadence is not explicitly stated, but the package is actively maintained with considerations for future major upgrades.","status":"active","version":"1.0.15","language":"javascript","source_language":"en","source_url":"https://github.com/yorgsite/y-src-pack","tags":["javascript","nodejs","node","bundle","medias","ressources","webpack"],"install":[{"cmd":"npm install y-src-pack","lang":"bash","label":"npm"},{"cmd":"yarn add y-src-pack","lang":"bash","label":"yarn"},{"cmd":"pnpm add y-src-pack","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The library primarily uses CommonJS `require` for its main export in v1.x.","wrong":"import YSrcPack from 'y-src-pack';","symbol":"YSrcPack","correct":"const YSrcPack = require('y-src-pack');"},{"note":"The `process` method is a static method on the YSrcPack class, not an instance method.","wrong":"new YSrcPack().process({...});","symbol":"YSrcPack.process","correct":"const YSrcPack = require('y-src-pack');\nYSrcPack.process({...});"},{"note":"Used as a Webpack plugin, instantiated within the Webpack configuration.","symbol":"YSrcPack.WebpackPlugin","correct":"const YSrcPack = require('y-src-pack');\nplugins: [ new YSrcPack.WebpackPlugin({...}) ];"}],"quickstart":{"code":"const YSrcPack = require('y-src-pack');\nconst path = require('path');\n\nconst projectRoot = process.cwd();\nconst jsname = 'myBundledResources'; // Or true for JSON, falsy for Node.js module\n\nYSrcPack.process({\n  // Collect files from a single directory\n  dir: path.resolve(projectRoot, 'src/assets'),\n  // Or use glob patterns for more specific file selection\n  glob: [\n    {\n      dir: path.resolve(projectRoot, 'src/data'),\n      glob: ['*.json', '**/*.txt']\n    },\n    {\n      dir: path.resolve(projectRoot, 'src/images'),\n      glob: '**/*.{png,jpg,svg}'\n    }\n  ],\n  tgtFile: path.resolve(projectRoot, 'dist/bundled-resources.js'),\n  jsName: jsname\n});\n\nconsole.log('Bundling process initiated. Check dist/bundled-resources.js');","lang":"javascript","description":"This example demonstrates how to use `y-src-pack` to bundle resources from multiple directories and glob patterns into a single output file, making them accessible via a global JavaScript variable."},"warnings":[{"fix":"Migrate to the static `YSrcPack.process(options)` method, passing all configuration as an options object.","message":"The instance-based `collect()` and `glob()` methods (referred to as 'with commands' in the documentation) are deprecated and will be removed in the next major version. This affects code using `new YSrcPack().collect(...)` or `new YSrcPack().glob(...)`.","severity":"breaking","affected_versions":"<2.0.0"},{"fix":"Exercise caution when relying on TypeScript API generation for production. Thoroughly test output and monitor release notes for updates related to this feature.","message":"The `typescript` option is marked as 'beta'. Its behavior, stability, and API generation might change in future versions without being classified as a major breaking change.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always use Node.js's `path.resolve(__dirname, 'your/relative/path')` or `path.resolve(process.cwd(), 'your/relative/path')` to ensure absolute paths are provided for all file system related options.","message":"Incorrect or relative paths for `dir`, `glob.dir`, and `tgtFile` options can lead to unexpected behavior, such as files not being found or output being written to unintended locations.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Ensure that the `options` object passed to `YSrcPack.process` includes at least one non-empty `dir` or `glob` property.","cause":"The `dir` or `glob` option (or both) were not provided in the options object to `YSrcPack.process`.","error":"Error: At least one of dir or glob must be set"},{"fix":"Add `const YSrcPack = require('y-src-pack');` at the top of your file to import the module.","cause":"The `y-src-pack` module was not correctly required or imported before use.","error":"ReferenceError: YSrcPack is not defined"},{"fix":"Call `process` as a static method directly on the class: `YSrcPack.process({...});`.","cause":"Attempted to call `process` on an instance of `YSrcPack` (e.g., `new YSrcPack().process(...)`) instead of directly on the `YSrcPack` class.","error":"TypeError: YSrcPack.process is not a function"}],"ecosystem":"npm"}