(module: SourceModule)
| 60 | } |
| 61 | |
| 62 | const callsIn = (module: SourceModule): PluginCall[] => { |
| 63 | const result: PluginCall[] = [] |
| 64 | // where a module loads an entry, in case none of its calls can be followed |
| 65 | let loaded: Node | undefined |
| 66 | let called = false |
| 67 | walk(module.program, node => { |
| 68 | if (node.type === "ObjectExpression") { |
| 69 | const options = turbopackOptionsOf(node) |
| 70 | if (options) { |
| 71 | result.push({ |
| 72 | position: module.positionOf(node), |
| 73 | label: `the ${turbopackLoader} loader`, |
| 74 | ...optionsOf(options, module) |
| 75 | }) |
| 76 | } |
| 77 | } |
| 78 | if (node.type === "ImportDeclaration") { |
| 79 | if ( |
| 80 | node.source.value in entries && |
| 81 | node.importKind !== "type" && |
| 82 | node.specifiers.some( |
| 83 | specifier => |
| 84 | specifier.type !== "ImportSpecifier" || |
| 85 | specifier.importKind !== "type" |
| 86 | ) |
| 87 | ) |
| 88 | loaded ??= node |
| 89 | return true |
| 90 | } |
| 91 | if (entryOf(node) !== undefined) loaded ??= node |
| 92 | if (node.type !== "CallExpression") return true |
| 93 | const read = entryReadOf(node.callee, module) |
| 94 | if ( |
| 95 | !read || |
| 96 | read[1][0] !== entries[read[0]] || |
| 97 | read[1].length > (read[0] === "@ark/aot/unplugin" ? 2 : 1) |
| 98 | ) |
| 99 | return true |
| 100 | called = true |
| 101 | if (!node.arguments.length) return true |
| 102 | result.push({ |
| 103 | position: module.positionOf(node), |
| 104 | label: `${module.textOf(unwrapExpression(node.callee))}()`, |
| 105 | ...optionsOf(node.arguments[0], module) |
| 106 | }) |
| 107 | return true |
| 108 | }) |
| 109 | // e.g. a call through a variable, whose options the build may be passed |
| 110 | if (loaded && !called) { |
| 111 | result.push({ |
| 112 | position: module.positionOf(loaded), |
| 113 | label: "the plugin", |
| 114 | options: {}, |
| 115 | unread: ["*"] |
| 116 | }) |
| 117 | } |
| 118 | return result |
| 119 | } |
no test coverage detected