unplugin-typegpu
Version:
Build plugins for TypeGPU, enabling seamless JavaScript -> WGSL transpilation and improved debugging.
39 lines (37 loc) • 1.43 kB
JavaScript
const require_common = require('./common-ddv56_tk.cjs');
const require_factory = require('./factory-BgweY_8-.cjs');
let defu = require("defu");
defu = require_common.__toESM(defu);
//#region src/bun.ts
var bun_default = (rawOptions) => {
const options = (0, defu.default)(rawOptions, require_common.defaultOptions);
const include = options.include;
if (!(include instanceof RegExp)) throw new Error(`Unsupported 'include' options in Bun plugin. Please provide a single regular expression`);
if (options.exclude) throw new Error(`Unsupported 'exclude' option in Bun plugin`);
const rawPlugin = require_factory.unpluginFactory(rawOptions, { framework: "bun" });
return {
name: "unplugin-typegpu",
setup(build) {
build.onLoad({ filter: include }, async (args) => {
var _result$code;
const codeIn = await Bun.file(args.path).text();
if (require_common.earlyPruneRegex.every((pattern) => !pattern.test(codeIn))) return {
contents: codeIn,
loader: args.loader
};
const result = rawPlugin.transform.handler.apply({}, [codeIn, args.path]);
return {
contents: (_result$code = result === null || result === void 0 ? void 0 : result.code) !== null && _result$code !== void 0 ? _result$code : codeIn,
loader: args.loader
};
});
}
};
};
//#endregion
Object.defineProperty(exports, 'bun_default', {
enumerable: true,
get: function () {
return bun_default;
}
});