Giter Site home page Giter Site logo

mrfoxpro / solid-rollup-boilerplate Goto Github PK

View Code? Open in Web Editor NEW
11.0 4.0 2.0 1.16 MB

Dev-ready boilerplate for creating modern and truly fast websites with solid-js

JavaScript 46.61% TypeScript 38.90% HTML 10.21% SCSS 4.28%
solid rollup esmodules typescript boilerplate solid-js modern-browsers native-modules solid-js-rollup es-modules

solid-rollup-boilerplate's Introduction

Solid JS ❤ Rollup

Ingredients

🔷 Solid JS
🍣 Rollup
🧼 Babel + Typescript + ESLint + Prettier
📑 Jest
🔃 Routing
📴 PWA Powered
🖍 SCSS modules + assets resolution
🔠 Inline SVG
🛰 Native ES Modules with modulepreload
👨‍💻 CSS Modules assistance

Usage

git clone https://github.com/MrFoxPro/solid-rollup-boilerplate.git && npm i
run npm start and open http://localhost:3000
alt
run npm run build to create optimized build

text from https://philipwalton.com/articles/using-native-javascript-modules-in-production-today/

Why deploy real modules?

If you’re already using a bundler like webpack, and you’re already using granular code splitting and preloading those files (similar to what I describe here), you might be wondering whether it’s worth switching to a strategy that uses real modules. Here are a few reasons why I think you should consider it, and why bundling to real modules is better than using classic scripts with their own module-loading code.

Smaller total code footprint

When using real modules, users on modern browsers don’t have to load any unnecessary module loading or dependency management code. For example the webpack runtime and manifest would not be needed at all if using real modules.

Better preloading

So regardless of how granularly you code-split your app, it’s more performant to load chunks using import statements and modulepreload than it is to load them via classic script tags and regular preload (especially if those tags are dynamically generated and added to the DOM at runtime).
In other words, a Rollup bundle consisting of 20 module chunks will load faster than the same code base bundled to 20 classic-script chunks with webpack (not because it’s webpack, but because it’s not real modules).

HTML2 Plugin explanation

This boilerplate temporary uses fork of rollup-plugin-html2. Check this PR

Thanks to @high1 for jest configuration
Thanks to @philipwalton for great articles about native modules and simple rollup setup

Useful articles

Using Native ES Modules
Preloading modules

TODO

  • Split configuration for modern and legacy browsers.
    This bolierplate is configured with @babel/preset-env to support Edge browser.
    For more modern browsers you could completely remove preset-env and uncomment manualChunks in config

  • Setup tests

  • Add build-time typechecking

  • Create true differential build for modern/legacy browsers

  • Add option to transpile Service Worker to CommonJS due to chromium bug

solid-rollup-boilerplate's People

Contributors

mrfoxpro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

solid-rollup-boilerplate's Issues

Child Routes and Preloading

Hello :)

I tried to add child nodes to my app

const routes = [
  {
    name: 'landing',
    path: '/',
  },
  {
    name: 'home',
    path: '/home',
  },

  {
    name: 'groups',
    path: '/groups',
    children: [
      { name: 'view', path: '/:id<\\d+>' },
      { name: 'list', path: '/list' },
    ],
  },
  {
    name: 'settings',
    path: '/settings',
  },
] as const;

export const { Link, Router, Provider, router } = createSolidRouter(routes, {
  createRouter5: (routes) => {
    const router = createRouter(routes, {
      allowNotFound: true,
      autoCleanUp: true,
      defaultRoute: '/home',
    });
    router.usePlugin(browserPluginFactory({ useHash: false }));
    router.usePlugin(loggerPlugin);
    return router;
  },
});

but when I try to refresh the page with the url localhost:3000/users/123, I get following error msg and the page is not loaded :(

Screenshot 2020-12-08 at 13 40 28

Routing via router.router5.navigate('groups.view', { id: 12 }); works fine, so does refreshing the page with just the path localhost:3000/groups 🤔

Does anyone have an idea, what this is about?

Help would be highly appreciated... since this is delaying my x-mas present ;(
Thank you! :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.