UNPKG

als-require

Version:

A utility for using CommonJS require in the browser and creating bundles.

28 lines (20 loc) 1.25 kB
# als-require `als-require` is a lightweight library for importing, modifying, and executing CommonJS modules in both browser and Node.js environments. It simplifies modular development by supporting dependency resolution, plugins for code transformation, and dynamic bundling. **Capabilities of `als-require`**: - Import and execute CommonJS modules in NodeJs and browser with dependency resolution. - Dynamically bundle modules into a single executable function. - Transform module code using custom plugins before execution. - Support for cyclic dependency detection and flexible logging options. ## In version 3 - code refactoring - improved getting node modules on NodeJs (not in browser) - Changed constructor - Now it has options (`{plugins=[],cyclicDependencies,logger}`) - No `build` and `bundle` methods. `fn` and `stringFn` methods instead - `fn(options = {scriptBefore='', scriptAfter='', parameters=[]}) ` - `stringFn(options = {scriptBefore='', scriptAfter='', parameters=[],name})` - no minifying and minifying options - The goal make it more simple. You can minify it separately - plugins for modifying content - no context - You can add it as parameter to fn and pass as parameter's value