* @param {string} module * @param {string} bazelTarget * @return {!Function}
(module, bazelTarget)
| 46 | * @return {!Function} |
| 47 | */ |
| 48 | function requireAtom(module, bazelTarget) { |
| 49 | try { |
| 50 | return require('./atoms/' + module) |
| 51 | } catch (ex) { |
| 52 | try { |
| 53 | const file = bazelTarget.slice(2).replace(':', '/') |
| 54 | log_.log(`../../../bazel-bin/${file}`) |
| 55 | return require(path.resolve(`../../../bazel-bin/${file}`)) |
| 56 | } catch (ex2) { |
| 57 | log_.severe(ex2) |
| 58 | throw new Error( |
| 59 | `Failed to import atoms module ${module}. If running in dev mode, you` + |
| 60 | ` need to run \`bazel build ${bazelTarget}\` from the project` + |
| 61 | `root: ${ex}`, |
| 62 | { cause: ex2 }, |
| 63 | ) |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | /** |
| 69 | * Converts a headers map to a HTTP header block string. |