UNPKG

@lynx-js/react-webpack-plugin

Version:

A webpack plugin for ReactLynx

33 lines 1.44 kB
import { RuntimeGlobals as LynxRuntimeGlobals } from '@lynx-js/webpack-runtime-globals'; export function createLynxProcessEvalResultRuntimeModule(webpack) { return class LynxProcessEvalResultRuntimeModule extends webpack.RuntimeModule { constructor() { super('webpack/runtime/lynx process eval result', webpack.RuntimeModule.STAGE_ATTACH); } generate() { const chunk = this.chunk; const compilation = this.compilation; if (!chunk || !compilation) { return ''; } // Register per-bundle under `globDynamicComponentEntry`; also assign the // deprecated single global for backward compatibility. return ` globalThis.processEvalResult = (${LynxRuntimeGlobals.lynxProcessEvalResultByHost} || (${LynxRuntimeGlobals.lynxProcessEvalResultByHost} = {}))[globDynamicComponentEntry] = function (result, schema) { var chunk = result && result(schema); if (chunk && chunk.ids && chunk.modules) { // We only deal with webpack chunk ${webpack.RuntimeGlobals.externalInstallChunk}(chunk); // TODO: sort with preOrderIndex. See: https://github.com/web-infra-dev/rspack/pull/8588 for (var moduleId in chunk.modules) { ${webpack.RuntimeGlobals.require}(moduleId); } return chunk; } return chunk } `; } }; } //# sourceMappingURL=LynxProcessEvalResultRuntimeModule.js.map