Registry / devops / y-src-pack

y-src-pack

JSON →
library1.0.15jsnpmunverified

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.

npm install y-src-pack
INSTALL
IMPORT
SIG · Y-SRC-PACK
Y
y-src-pack
devopsjavascriptv1.0.15
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

YSrcPack
const YSrcPack = require('y-src-pack');
import YSrcPack from 'y-src-pack';
The library primarily uses CommonJS `require` for its main export in v1.x.
YSrcPack.process
const YSrcPack = require('y-src-pack'); YSrcPack.process({...});
new YSrcPack().process({...});
The `process` method is a static method on the YSrcPack class, not an instance method.
YSrcPack.WebpackPlugin
const YSrcPack = require('y-src-pack'); plugins: [ new YSrcPack.WebpackPlugin({...}) ];
Used as a Webpack plugin, instantiated within the Webpack configuration.

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.

const YSrcPack = require('y-src-pack'); const path = require('path'); const projectRoot = process.cwd(); const jsname = 'myBundledResources'; // Or true for JSON, falsy for Node.js module YSrcPack.process({ // Collect files from a single directory dir: path.resolve(projectRoot, 'src/assets'), // Or use glob patterns for more specific file selection glob: [ { dir: path.resolve(projectRoot, 'src/data'), glob: ['*.json', '**/*.txt'] }, { dir: path.resolve(projectRoot, 'src/images'), glob: '**/*.{png,jpg,svg}' } ], tgtFile: path.resolve(projectRoot, 'dist/bundled-resources.js'), jsName: jsname }); console.log('Bundling process initiated. Check dist/bundled-resources.js');
Debug
Known issues
breakingThe 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(...)`.
fix
Migrate to the static `YSrcPack.process(options)` method, passing all configuration as an options object.
affects: <2.0.0
gotchaThe `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.
fix
Exercise caution when relying on TypeScript API generation for production. Thoroughly test output and monitor release notes for updates related to this feature.
affects: >=1.0.0
gotchaIncorrect 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.
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.
affects: >=1.0.0
Errors
Common errors & fixes
Error: At least one of dir or glob must be set
The `dir` or `glob` option (or both) were not provided in the options object to `YSrcPack.process`.
fix
Ensure that the `options` object passed to `YSrcPack.process` includes at least one non-empty `dir` or `glob` property.
ReferenceError: YSrcPack is not defined
The `y-src-pack` module was not correctly required or imported before use.
fix
Add `const YSrcPack = require('y-src-pack');` at the top of your file to import the module.
TypeError: YSrcPack.process is not a function
Attempted to call `process` on an instance of `YSrcPack` (e.g., `new YSrcPack().process(...)`) instead of directly on the `YSrcPack` class.
fix
Call `process` as a static method directly on the class: `YSrcPack.process({...});`.
Upgrade
Version history
1.0.15latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
10
Amazon
2
Resources
y-src-pack — npm install y-src-pack · libregistry