Registry / devops / yyl-sugar-webpack-plugin

yyl-sugar-webpack-plugin

JSON →
library1.0.10jsnpmunverified

Webpack plugin (v1.0.10, stable) for YYL sugar processing during compilation. Integrates with webpack >=5 and exposes beforeSugar, afterSugar, and emit hooks for custom transformations. Ships TypeScript types. Used in YYL-based workflows; requires careful version matching with webpack.

npm install yyl-sugar-webpack-plugin
INSTALL
IMPORT
SIG · YYL-SUGAR-WEBPACK-
Y
yyl-sugar-webpack-plugin
devopsjavascriptv1.0.10
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

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

YylSugarWebpackPlugin
const YylSugarWebpackPlugin = require('yyl-sugar-webpack-plugin')
import YylSugarWebpackPlugin from 'yyl-sugar-webpack-plugin'
Package uses CommonJS; require is required for correct import; no default ESM export provided.
getHooks
import { getHooks } from 'yyl-sugar-webpack-plugin'
const { getHooks } = require('yyl-sugar-webpack-plugin')
Actually, getHooks is accessed via the imported plugin class (IPlugin.getHooks(compilation)), not a separate import. Common mistake: trying to import getHooks directly.
getName
YylSugarWebpackPlugin.getName()
new YylSugarWebpackPlugin().getName()
getName is a static method on the class, not an instance method.

Shows basic usage of YylSugarWebpackPlugin as a webpack plugin with CJS require and an example of hooking into beforeSugar.

const YylSugarWebpackPlugin = require('yyl-sugar-webpack-plugin'); const path = require('path'); const webpackConfig = { plugins: [ new YylSugarWebpackPlugin({ basePath: __dirname }) ] }; module.exports = webpackConfig; // To extend with hooks: const PLUGIN_NAME = 'ExtPlugin'; class ExtPlugin { apply(compiler) { compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => { YylSugarWebpackPlugin.getHooks(compilation).beforeSugar.tapAsync(PLUGIN_NAME, (obj, done) => { console.log('beforeSugar', obj); done(null, obj); }); }); } }
Debug
Known issues
gotchaRequire is the only supported import method; ESM import will fail
fix
Use const P = require('yyl-sugar-webpack-plugin') instead of import.
affects: >=1.0.0
deprecatedWebpack 4 is not supported; peer dependency requires webpack >=5
fix
Upgrade webpack to version 5 or later.
affects: >=1.0.0
gotchaMissing basePath option causes runtime error
fix
Always pass basePath when instantiating the plugin.
affects: >=1.0.0
breakingHooks API uses tapAsync, not tap or tapPromise; incorrect usage will not trigger callbacks
fix
Use tapAsync for hook registration with (obj, done) callback.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: YylSugarWebpackPlugin is not a constructor
ESM import used instead of require; package only provides CJS export.
fix
Replace import with const YylSugarWebpackPlugin = require('yyl-sugar-webpack-plugin')
Error: Cannot find module 'yyl-sugar-webpack-plugin'
Package not installed or incorrect path; also occurs when using ESM in environment that expects module resolution.
fix
Run npm install yyl-sugar-webpack-plugin and use require()
TypeError: Cannot read properties of undefined (reading 'beforeSugar')
getHooks called without compilation object or before hooks are set up.
fix
Ensure getHooks is called inside a compilation hook (e.g., compiler.hooks.compilation.tap) and that compilation is not null.
Upgrade
Version history
1.0.10latest on npm
Audit
Dependencies
webpackrequiredPeer dependency required for plugin functionality; must be >=5.0.0
Agent activity
20 hits · last 30 days
node
18
Resources
yyl-sugar-webpack-plugin — npm install yyl-sugar-webpack-plugin · libregistry