Consistent naming of Mithril.js
This commit is contained in:
parent
7b1fda5b66
commit
885b3f9442
48 changed files with 269 additions and 269 deletions
|
|
@ -10,7 +10,7 @@ Instructions on how to install Mithril.js
|
|||
|
||||
### CDN
|
||||
|
||||
If you're new to JavaScript or just want a very simple setup to get your feet wet, you can get Mithril from a [CDN](https://en.wikipedia.org/wiki/Content_delivery_network):
|
||||
If you're new to JavaScript or just want a very simple setup to get your feet wet, you can get Mithril.js from a [CDN](https://en.wikipedia.org/wiki/Content_delivery_network):
|
||||
|
||||
```html
|
||||
<script src="https://unpkg.com/mithril/mithril.js"></script>
|
||||
|
|
@ -32,7 +32,7 @@ $ npm install @types/mithril --save-dev
|
|||
|
||||
For example usage, to file issues or to discuss TypeScript related topics visit: https://github.com/MithrilJS/mithril.d.ts
|
||||
|
||||
Type definitions for pre-release versions of Mithril (on the `next` branch) align with the `next` branch of the [types development repo](https://github.com/MithrilJS/mithril.d.ts/tree/next). You can install these types with:
|
||||
Type definitions for pre-release versions of Mithril.js (on the `next` branch) align with the `next` branch of the [types development repo](https://github.com/MithrilJS/mithril.d.ts/tree/next). You can install these types with:
|
||||
|
||||
```bash
|
||||
$ npm install -D MithrilJS/mithril.d.ts#next
|
||||
|
|
@ -84,7 +84,7 @@ $ npm start
|
|||
|
||||
7. open `index.html` in a browser
|
||||
|
||||
Optionally, you can include Mithril as a global variable using Webpack's provide plugin, to avoid including `import m from "mithril"` across a large number of files:
|
||||
Optionally, you can include Mithril.js as a global variable using Webpack's provide plugin, to avoid including `import m from "mithril"` across a large number of files:
|
||||
```js
|
||||
plugins: [
|
||||
new webpack.ProvidePlugin({m: "mithril"}),
|
||||
|
|
@ -95,18 +95,18 @@ Then, you could remove the import line from step 4 (don't forget to restart Webp
|
|||
|
||||
#### Step by step
|
||||
|
||||
For production-level projects, the recommended way of installing Mithril is to use npm.
|
||||
For production-level projects, the recommended way of installing Mithril.js is to use npm.
|
||||
|
||||
npm is the default package manager that is bundled w/ Node.js. It is widely used as the package manager for both client-side and server-side libraries in the JavaScript ecosystem. Download and install [Node](https://nodejs.org); npm is bundled with that and installed alongside it.
|
||||
|
||||
To use Mithril via npm, go to your project folder, and run `npm init --yes` from the command line. This will create a file called `package.json`.
|
||||
To use Mithril.js via npm, go to your project folder, and run `npm init --yes` from the command line. This will create a file called `package.json`.
|
||||
|
||||
```bash
|
||||
npm init --yes
|
||||
# creates a file called package.json
|
||||
```
|
||||
|
||||
Then, to install Mithril, run:
|
||||
Then, to install Mithril.js, run:
|
||||
|
||||
```bash
|
||||
npm install mithril --save
|
||||
|
|
@ -152,7 +152,7 @@ The `-d` flag tells webpack to use development mode, which produces source maps
|
|||
|
||||
The `--watch` flag tells webpack to watch the file system and automatically recreate `app.js` if file changes are detected.
|
||||
|
||||
Now you can run the script via `npm start` in your command line window. This looks up the `webpack` command in the npm path, reads `index.js` and creates a file called `app.js` which includes both Mithril and the `hello world` code above. If you want to run the `webpack` command directly from the command line, you need to either add `node_modules/.bin` to your PATH, or install webpack globally via `npm install webpack -g`. It's, however, recommended that you always install webpack locally and use npm scripts, to ensure builds are reproducible in different computers.
|
||||
Now you can run the script via `npm start` in your command line window. This looks up the `webpack` command in the npm path, reads `index.js` and creates a file called `app.js` which includes both Mithril.js and the `hello world` code above. If you want to run the `webpack` command directly from the command line, you need to either add `node_modules/.bin` to your PATH, or install webpack globally via `npm install webpack -g`. It's, however, recommended that you always install webpack locally and use npm scripts, to ensure builds are reproducible in different computers.
|
||||
|
||||
```
|
||||
npm start
|
||||
|
|
@ -193,7 +193,7 @@ var MyComponent = require("./mycomponent")
|
|||
m.mount(document.body, MyComponent)
|
||||
```
|
||||
|
||||
Note that in this example, we're using `m.mount`, which wires up the component to Mithril's autoredraw system. In most applications, you will want to use `m.mount` (or `m.route` if your application has multiple screens) instead of `m.render` to take advantage of the autoredraw system, rather than re-rendering manually every time a change occurs.
|
||||
Note that in this example, we're using `m.mount`, which wires up the component to Mithril.js' autoredraw system. In most applications, you will want to use `m.mount` (or `m.route` if your application has multiple screens) instead of `m.render` to take advantage of the autoredraw system, rather than re-rendering manually every time a change occurs.
|
||||
|
||||
#### Production build
|
||||
|
||||
|
|
@ -224,7 +224,7 @@ You can use hooks in your production environment to run the production build scr
|
|||
|
||||
---
|
||||
|
||||
### Alternate ways to use Mithril
|
||||
### Alternate ways to use Mithril.js
|
||||
|
||||
#### Live reload development environment
|
||||
|
||||
|
|
@ -267,6 +267,6 @@ If you don't have the ability to run a bundler script due to company security po
|
|||
```javascript
|
||||
// index.js
|
||||
|
||||
// if a CommonJS environment is not detected, Mithril will be created in the global scope
|
||||
// if a CommonJS environment is not detected, Mithril.js will be created in the global scope
|
||||
m.render(document.body, "hello world")
|
||||
```
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue