<h2>v2 Migration Guide</h2><p>In advance of the release of version 2, we are releasing this guide in order to give third-party developers a chance to bring their plugins and themes up-to-date. In the successive sections below, we will outline the breaking change or new best-practice, and the steps to migrate, along with a live example.</p><h4>This blog post is the third in a series of posts related to the release of NodeBB v2</h4><p><p><em>We tried to plan out this release in such a way that any breaking changes would be minimized. There is a chance that your theme or plugin will just work out-of-the-box, or with minimal changes.</em></p><p><em>We've tried to list any gotchas and necessary changes in this article, but please do let us know if you encounter one we haven't seen yet.</em></p></p><h3>Migrate AMD modules from <code>scripts</code> and <code>acpScripts</code> to <code>modules</code> (breaking change 🚨)</h3><p>Standard practice in v1.x was to write a page-specific client-side script or admin script as an AMD module, and bundle them with the minified files served to the browser. We now recommend that the files be defined in the <code>modules</code> property in <code>package.json</code> so that they can be bundled as necessary, or dynamically loaded otherwise.</p><p><strong>Note:</strong>These scripts can continue to be written in AMD-style, as it is supported by Webpack.</p><h4>Live example (nodebb-theme-persona)</h4><p>The persona theme contains two page-specific scripts, one loaded on the user settings page, and another loaded in the ACP settings page.</p><ul><li>The <ahref=\"https://github.com/NodeBB/nodebb-theme-persona/pull/545/files#diff-7b32f67ab72ef7b295c60be75ff703b7660e0f7e737e77251e5cc69deb7844aaL12-L22\">scripts are removed from the <code>scripts</code> and <code>acpScripts</code> sections, and added to <code>modules</code></a></li><li>Note that the key for these modules matches the template name, and that it is prepended with <code>../</code> -- this is necessary because they are not added to the modules folder</li><li>Modules can continue to be written in AMD-style, this is handled transparently by Webpack.</li></ul><h3>Migrate third-party modules to use npm dependencies, if available (best practice)</h3><p>Any third-party modules are no longer recommended to be used in the <code>modules</code> section of <code>plugin.json</code>. Instead, install them directly from npm if available, and just import them into your client-side code.</p><p>There are some savings to be had by no longer appending third-party code into the main bundle. Webpack can choose to either bundle it in, or dynamically load it as-needed.</p><p>Additionally, having a dependency maintained in your <code>package.json</code> allows for better version control and updates, without needing to modify copy-pasted code directly in your repository.</p><h4>Live example (nodebb-plugin-markdown)</h4><p>The markdown plugin relies on <code>highlightjs</code> as a dependency in order to highlight code written in code blocks.</p><ul><li>The plugin is now <ahref=\"https://github.com/julianlam/nodebb-plugin-markdown/pull/209/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519L32-R32\">installed directly from npm</a>, instead of the CDN variant, and</li><li>Instead of <code>require</code>-ing them as an AMD module, <ahref=\"https://github.com/julianlam/nodebb-plugin-markdown/pull/209/files#diff-c3eb992fbaa0b603cd6f9ab34aff720e723fbedd4b64065482d463a9a892d7d5L212-R214\">they are now imported in by Webpack</a></li></ul><h4>Live example (nodebb-plugin-2factor)</h4><p>The 2factor plugin relies on <ahref=\"https://github.com/github/webauthn-json\">@github/webauthn-json</a> to properly encode and verify key registrations and challenges.</p><ul><li><ahref=\"https://github.com/NodeBB/nodebb-plugin-2factor/pull/73/files#diff-7b32f67ab72ef7b295c60be75ff703b7660e0f7e737e77251e5cc69deb7844aaL28\">The script is removed from scripts configurat