Skip to content
This repository has been archived by the owner on Sep 15, 2023. It is now read-only.

Add console warn if module is missing instead of break #568

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/javascripts/modules/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@

const moduleElements = document.querySelectorAll('[data-module]')

for (var i = 0; i < moduleElements.length; i++) {
const el = moduleElements[i]
const name = el.getAttribute('data-module')
const Module = require(`./${name}`).default
new Module(el)
for (let i = 0; i < moduleElements.length; i += 1) {
const el = moduleElements[i];
const name = el.getAttribute("data-module");
try {
const Module = require(`./${name}`).default;
new Module(el);
} catch (err) {
console.warn(`Cannot find module ./${name}.`);
}
}

/*
Expand Down