visionmedia / page.js

Micro client-side router inspired by the Express router

Home Page:http://visionmedia.github.com/page.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use dynamic import in page.js?

kresnasatya opened this issue · comments

Hi, just curious do you have example how to implement dynamic import in page.js?

I have implemented dynamic import with page.js and webpack v4 like below. It has worked well.

  page('/account', function () {
    import(
      /* webpackChunkName: "account-view" */
      '../components/Account'
    )
      .then(function (moduleWrap) {
        var accountView = moduleWrap.default;
        render(accountView);
      })
      .catch(importErrorHandler);
  });

For details, see Georap at GitHub (previously Tresdb) and search for router files under /client/js/routes/.