rolldown
Version:
Fast JavaScript/TypeScript bundler in Rust with Rollup-compatible API.
41 lines (39 loc) • 1.3 kB
JavaScript
;
const require_chunk = require('../shared/chunk-qZFfknuJ.cjs');
const require_src = require('../shared/src-dFNL8gOq.cjs');
const require_parse_ast_index = require('../shared/parse-ast-index-C8v5UEr2.cjs');
const node_worker_threads = require_chunk.__toESM(require("node:worker_threads"));
//#region src/parallel-plugin-worker.ts
const { registryId, pluginInfos, threadNumber } = node_worker_threads.workerData;
(async () => {
try {
const plugins = await Promise.all(pluginInfos.map(async (pluginInfo) => {
const pluginModule = await import(pluginInfo.fileUrl);
const definePluginImpl = pluginModule.default;
const plugin = await definePluginImpl(pluginInfo.options, { threadNumber });
return {
index: pluginInfo.index,
plugin: require_src.bindingifyPlugin(
plugin,
{},
{},
// TODO need to find a way to share pluginContextData
new require_src.PluginContextData(),
[],
() => {},
"info"
)
};
}));
(0, require_parse_ast_index.import_binding.registerPlugins)(registryId, plugins);
node_worker_threads.parentPort.postMessage({ type: "success" });
} catch (error) {
node_worker_threads.parentPort.postMessage({
type: "error",
error
});
} finally {
node_worker_threads.parentPort.unref();
}
})();
//#endregion