-
Notifications
You must be signed in to change notification settings - Fork 2
Project Design
Here's a bit of info on some of the design decisions that were made for this generator and my reasoning behind them.
Skate.js and its dependencies could easily be pulled into the application through Webpack, so that you would do something like this:
import { Component, h } from 'skatejs';
instead of this:
const { Component, h } = skatejs;
However, my use case with Skate.js is such that we will likely include multiple different bundles from multiple projects that all use this generator within a page. If every bundle were to include their own version of skate, it would be a little easier to set up...
<script src="/assets/header-with-all-deps.bundle.min.js"></script>
<script src="/assets/footer-with-all-deps.bundle.min.js"></script>
...but at the expense of including those dependencies twice even though that isn't necessary. Instead, I would rather do a tiny bit more setup:
<script src="/assets/skate-and-deps.min.js"></script>
<script src="/assets/header-only.bundle.min.js"></script>
<script src="/assets/footer-only.bundle.min.js"></script>
but avoid forcing my users to pay the price of downloading the library multiple times, no matter how small it is.
If you find yourself in a situation where you would rather bundle everything into a single file, it's easy to do!
- Remove the links
unpkg.com
fromdemo/index.html
- Install Skate and the other dependencies
yarn add skatejs skatejs-web-components
- Import
skatejs-web-components
insrc/index.js
- Replace usage of Skate.js as a global with an import instead
An example src/index.js
might look like this:
import 'skatejs-web-components';
import { define } from 'skatejs';
import MyComponent from './components/my-component/component.js';
define(MyComponent);
You'll need to replace the reference to skate
as a global in each of your component.js
files, plus src/index.js
and src/util/style.js
(and anywhere else you might have used it).