(tmps, notFoundKey)
| 52 | onReloadTemplates.listeners = [] |
| 53 | |
| 54 | export const registerTemplates = async (tmps, notFoundKey) => { |
| 55 | Object.keys(templatesByPath).forEach(key => { |
| 56 | delete templatesByPath[key] |
| 57 | }) |
| 58 | Object.keys(templateErrorByPath).forEach(key => { |
| 59 | delete templateErrorByPath[key] |
| 60 | }) |
| 61 | Object.keys(templates).forEach(key => { |
| 62 | delete templates[key] |
| 63 | }) |
| 64 | Object.keys(tmps).forEach(key => { |
| 65 | templates[key] = tmps[key] |
| 66 | if (!templates[key]) { |
| 67 | console.warn( |
| 68 | `Template registered without default export: ${key.replace( |
| 69 | /__react_static_root__\//, |
| 70 | '' |
| 71 | )}` |
| 72 | ) |
| 73 | } |
| 74 | }) |
| 75 | templatesByPath[PATH_404] = templates[notFoundKey] |
| 76 | |
| 77 | if ( |
| 78 | process.env.NODE_ENV === 'development' && |
| 79 | typeof document !== 'undefined' |
| 80 | ) { |
| 81 | await prefetch(window.location.pathname) |
| 82 | } |
| 83 | |
| 84 | onReloadTemplates.listeners.forEach(fn => fn()) |
| 85 | |
| 86 | if ( |
| 87 | typeof document !== 'undefined' && |
| 88 | process.env.REACT_STATIC_SILENT !== 'true' |
| 89 | ) { |
| 90 | console.log('React Static: Templates Reloaded') |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | export const registerTemplateForPath = (path, template) => { |
| 95 | path = getRoutePath(path) |
no test coverage detected
searching dependent graphs…