LoadMainModule loads a main module and resolves all it dependencies checking for any linking issues. It does not run any javascript code, just compiling it and resolving module dependencies.
(pwd *url.URL, specifier string, data []byte)
| 217 | // LoadMainModule loads a main module and resolves all it dependencies checking for any linking issues. |
| 218 | // It does not run any javascript code, just compiling it and resolving module dependencies. |
| 219 | func (mr *ModuleResolver) LoadMainModule(pwd *url.URL, specifier string, data []byte) error { |
| 220 | if _, err := mr.resolveLoaded(pwd, specifier, data); err != nil { |
| 221 | return err |
| 222 | } |
| 223 | |
| 224 | mod, err := mr.resolve(pwd, specifier) |
| 225 | if err != nil { |
| 226 | return err |
| 227 | } |
| 228 | if err = mod.Link(); err != nil { |
| 229 | return err |
| 230 | } |
| 231 | _, ok := mod.(sobek.CyclicModuleRecord) |
| 232 | if !ok { |
| 233 | panic("somehow running source data for " + specifier + " didn't produce a cyclic module record") |
| 234 | } |
| 235 | |
| 236 | if len(mr.unknownModules) > 0 { |
| 237 | return newUnknownModulesError(mr.unknownModules) |
| 238 | } |
| 239 | return nil |
| 240 | } |
| 241 | |
| 242 | // ModuleSystem is implementing an ESM like module system to resolve js modules for k6 usage |
| 243 | type ModuleSystem struct { |
no test coverage detected