(
ctx: Rollup.PluginContext,
id: string,
loadOpts?: Parameters<Extract<Plugin['load'], Function>>[1]
)
| 602 | |
| 603 | let loadCount = 0; |
| 604 | const load = async ( |
| 605 | ctx: Rollup.PluginContext, |
| 606 | id: string, |
| 607 | loadOpts?: Parameters<Extract<Plugin['load'], Function>>[1] |
| 608 | ): Promise<Rollup.LoadResult> => { |
| 609 | if (id === '\0editor') { |
| 610 | // This doesn't get used, but we need to return something |
| 611 | return '"opening in editor"'; |
| 612 | } |
| 613 | if (id.startsWith('\0') || id.startsWith('/@fs/')) { |
| 614 | return; |
| 615 | } |
| 616 | const count = loadCount++; |
| 617 | const isServer = getIsServer(loadOpts); |
| 618 | |
| 619 | // Virtual modules |
| 620 | if (opts.resolveQwikBuild && id === QWIK_BUILD_ID) { |
| 621 | debug(`load(${count})`, QWIK_BUILD_ID, opts.buildMode); |
| 622 | return { |
| 623 | moduleSideEffects: false, |
| 624 | code: getQwikBuildModule(isServer, opts.target), |
| 625 | }; |
| 626 | } |
| 627 | if (id === QWIK_CLIENT_MANIFEST_ID) { |
| 628 | debug(`load(${count})`, QWIK_CLIENT_MANIFEST_ID, opts.buildMode); |
| 629 | return { |
| 630 | moduleSideEffects: false, |
| 631 | code: await getQwikServerManifestModule(isServer), |
| 632 | }; |
| 633 | } |
| 634 | |
| 635 | // QRL segments |
| 636 | const parsedId = parseId(id); |
| 637 | id = normalizePath(parsedId.pathId); |
| 638 | const outputs = isServer ? serverTransformedOutputs : clientTransformedOutputs; |
| 639 | if (devServer && !outputs.has(id)) { |
| 640 | // in dev mode, it could be that the id is a QRL segment that wasn't transformed yet |
| 641 | const parentId = parentIds.get(id); |
| 642 | if (parentId) { |
| 643 | const parentModule = devServer.moduleGraph.getModuleById(parentId); |
| 644 | if (parentModule) { |
| 645 | // building here via ctx.load doesn't seem to work (no transform), instead we use the devserver directly |
| 646 | debug(`load(${count})`, 'transforming QRL parent', parentId); |
| 647 | // We need to encode it as an absolute path |
| 648 | await devServer.transformRequest(parentModule.url); |
| 649 | // The QRL segment should exist now |
| 650 | if (!outputs.has(id)) { |
| 651 | debug(`load(${count})`, `QRL segment ${id} not found in ${parentId}`); |
| 652 | return null; |
| 653 | } |
| 654 | } else { |
| 655 | console.error(`load(${count})`, `${parentModule} does not exist!`); |
| 656 | } |
| 657 | } |
| 658 | } |
| 659 | |
| 660 | const transformedModule = outputs.get(id); |
| 661 |
nothing calls this directly
no test coverage detected
searching dependent graphs…