UNPKG

unplugin

Version:

Unified plugin system for build tools

18 lines (16 loc) 817 B
import "../../context-CyqyI0ug.js"; import { createBuildContext$1 as createBuildContext, createContext$1 as createContext } from "../../context-B_3zWGEx.js"; //#region src/rspack/loaders/transform.ts async function transform(source, map) { const callback = this.async(); const { plugin } = this.query; if (!plugin?.transform) return callback(null, source, map); const id = this.resource; const context = createContext(this); const res = await plugin.transform.call(Object.assign({}, this._compilation && createBuildContext(this._compiler, this._compilation, this), context), source, id); if (res == null) callback(null, source, map); else if (typeof res !== "string") callback(null, res.code, map == null ? map : res.map || map); else callback(null, res, map); } //#endregion export { transform as default };