* Runner chunk should only import local dependencies to stay lightweight
( this: PluginContext, chunk: RenderedChunk, importBindings: ImportBindings[], )
| 207 | * Runner chunk should only import local dependencies to stay lightweight |
| 208 | */ |
| 209 | function validateRunnerChunk( |
| 210 | this: PluginContext, |
| 211 | chunk: RenderedChunk, |
| 212 | importBindings: ImportBindings[], |
| 213 | ) { |
| 214 | for (const { id, bindings } of importBindings) { |
| 215 | if ( |
| 216 | !id.startsWith('./') && |
| 217 | !id.startsWith('../') && |
| 218 | !id.startsWith('#') && |
| 219 | // index and moduleRunner have a common chunk |
| 220 | !id.startsWith('chunks/') && |
| 221 | !id.startsWith('types.d') |
| 222 | ) { |
| 223 | this.warn( |
| 224 | `${chunk.fileName} imports "${bindings.join(', ')}" from "${id}" which is not allowed`, |
| 225 | ) |
| 226 | process.exitCode = 1 |
| 227 | } |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | /** |
| 232 | * Validate that chunk imports do not import dev deps |