• Stars
    star
    142
  • Rank 258,495 (Top 6 %)
  • Language
    JavaScript
  • License
    Other
  • Created almost 9 years ago
  • Updated about 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Hot Module Replacement for Meteor; in your app, with react, with build plugins

meteor-hmr

This project is no longer maintained

Interested in taking it over? See Info for potential maintainers. I regret that I simply do not have the resources to continue this project at this point in time.

Past Info

Hot Module Replacement (HMR) for Meteor

NB: This README refers to the upcoming release. Although it's experimental, you're encouraged to try it out, since that's the direction we're going in. More details in #51. Otherwise, you can find the old README here.

gadicc:[email protected] is the last release for Meteor 1.3.2.4; later releases and the 2.0.0 final will target Meteor 1.3.3, using Meteor's new official babelrc support, and no longer includes our own babel-compiler-babelrc which we no longer support.

Since Meteor 1.3.3 we use Meteor's native babelrc support. You should npm rm --save-dev babel-preset-meteor and remove the meteor preset from your .babelrc.

  • Edit your react components and see changes instantly, while maintaining state.
  • Catch react render() errors and show on your screen rather than crashing your app.
  • Add your own .babelrc plugins and presets, like jsx-control-statements.

screencast

Copyright (c) 2016 by Gadi Cohen <[email protected]>, released under the MIT License. Note: this code includes / republishes additions to core Meteor packages that are Copyright MDG and released under the same license.

Discussion: https://forums.meteor.com/t/help-test-react-hotloading-in-native-meteor-i-e-no-webpack/17523/

How to Use

If upgrading from an earlier version, please see Upgrading.

What follows are step-by-step instructions to add meteor-hmr to an existing project. You can also see the Boilerplates & Examples section of the docs.

Hotloading is provided on a per-build-plugin basis. We provide a replacement ecmascript-hot loader to hotload your *.js and *.jsx files:

  1. meteor remove ecmascript
  2. meteor add gadicc:ecmascript-hot

If you're trying a non-stable release, you need to explicitly provide the @version (or @=version if it's not picked up correctly) in the second step.

Note, your code needs to be hot-module-replacement (HMR) aware. For instuctions on how to add hot loading for React, please see the React Hotloading docs. For general instructions, see the Handling Updates. If you're a build-plugin author, see the Build Plugin docs. Other build plugins HMR support are list below:

Other Notes:

  1. We use an extra port for communication with the client. By default this is Meteor's port + 2 (i.e., right after mongo), but you can override it with the HOT_PORT environment variable.

  2. For Mantra style apps, skim over the React Hotloading docs above and then read this diff for an example on how to add hotloading to the mantra-sample-blog-app (or just clone the repo). You may also find more info in #60.

List of HMR-aware Build Plugins

  • gadicc:ecmascript-hot - .js and .jsx files (core, part of this project)
  • gadicc:node-modules-hot - compilation & hot updates of local node-modules (core, see docs)

Build plugin authors, please submit a PR to add your HMR-aware build plugin to this list. For more info, see the Build Plugin docs.

Where this works and doesn't work

Hot Module Replacement (HMR) only works with "pure" modules that use import and export. Any reliance on Meteor's old method of api.use(), api.export() and globals will absolutely not work properly, ever.

Forced Refresh

Just do a browser refresh like normal (ctrl-R, etc).

If you experience the need to do this frequently, please report on GitHub.

Note, errors thrown in your app can break Meteor's HCP system, requiring a browser refresh regardless... we can't help with that.

Settings (in package.json)

Hotloading is disabled by default for packages that can be hot loaded, unless the package explicitly forces hotloading, like ecmascript-hot and node-modules-hot which should simply be removed to disable hotloading. You can enable hotloading for other packages as follows:

{
  // Besides for "-hot" packages which are always enabled,
  // enable hotloading for all other packages that support it.
  "enabled": true
  // Or, we can specify an array of names
  "enabled": [ "author:packageName", "etc" ]
}

Please note that the old ecmascript-hot section is no longer used and should be removed.

Packages

If you replace the api.use('ecmascript') in the package.js file with the gadicc:ecmascript-hot@<currentVersion>, you'll be able to use the hotloading while developing local packages, with one caveat:

This only works for "new style" 1.3 module packages. That means any reference inside of a file should refer to the local scope only, i.e. any dependencies should be imported via the import X from Y; syntax, and your code should not expect them to "just be available" because of Meteor's linker code.

Note, at time of writing (2016-05-07), Meteor doesn't allow for the hot.accept() check to flow from packages back down to the app, so you need to do this per package. BUT, we have a PR open for this in meteor#6391.

Troubleshooting

Please see the Troubleshooting docs. The first entry there is called Is this even working?. Otherwise, see if anyone else has experienced your problem by searching in issues and if not, please open a new one.

How this works

Brace yourself for reading this and recall the project goals.

  1. Build plugins that use gadicc:hot-build (like gadicc:ecmascript-hot) will be loaded a 2nd time in a forked process. They will watch all the same files, and on update, will recompile only changed files and send this update directly to the client.

  2. This above bundle resembles Meteor's linker output but also bypasses it, so this will only work with "pure" modules that use import/export and don't rely at all on Meteor's old method of api.use() and api.export().

  3. The accelerator also runs an http server (to serve bundles) and a websocket server (to notify the client of new bundles ids). The client requests said bundles by inserting a script tag into the HEAD (so it will be loaded in the correct context).

  4. We patch meteorInstall's root, delete previous exports, climb the tree, and reevaluate. This happens before the HCP, so if everything succeeded, we skip the next HCP.

  5. We skip HCPs by wrapping autoupdate's observe()'s changed callback, to not fire the original callback in cases we want to skip.

Changes from original core packages

The bases for babel-compiler and ecmascript began from 1.3-modules-beta.5 and are upgraded as necessary, in their own commits (look out for commit messages update package bases to 1.3-beta.11 (<SHA>) etc).

More Repositories

1

node-yahoo-finance2

Unofficial API for Yahoo Finance
HTML
381
star
2

meteor-famous-views

Famous, the Meteor Way (with Reactive Blaze Templates/Views)
JavaScript
332
star
3

meteor-sitemaps

Quickly create dynamic ("real-time") sitemaps using your own functions.
JavaScript
87
star
4

meteor-headers

Access HTTP headers on both server and client. Client IP with proxy support.
JavaScript
61
star
5

meteor-blaze-react-component

<Blaze template="itemsList" items={items} />
JavaScript
61
star
6

meteor-messageformat

MessageFormat i18n support for Meteor, with reactive templates
JavaScript
54
star
7

meteor-reactive-window

Reactive functions for window properties; width, scroll, etc
JavaScript
29
star
8

meteor-phantomjs

Smart package to ensure PhantomJS is automatically installed
JavaScript
25
star
9

fview-flex

IjzerenHein's famous-flex for famous-views (Meteor)
JavaScript
23
star
10

meteor-blaze-virtual-dom

An experiment to use Blaze with a virtual dom
JavaScript
16
star
11

mongodb-rest-relay

Relay mongodb queries over HTTP REST. Great for Edge.
TypeScript
14
star
12

meteor-robots.txt

Serves a robot.txt which can be modified programatically
JavaScript
10
star
13

espruino-gc-meteor

JavaScript
10
star
14

fview-lab

Real-time playground for meteor famous-views
JavaScript
9
star
15

famin

JavaScript
9
star
16

meteor-usermap

A map of Meteor users
JavaScript
8
star
17

node-hosts-so-easy

Safe, parallel API for manipulating /etc/hosts.
JavaScript
8
star
18

redalert

Hackathon related stuff, mostly Tzeva Adom related
JavaScript
6
star
19

meteor-extensions

Add support for extensions (hooks, plugins) to your app
JavaScript
6
star
20

phantomjs-remote

Run phantomjs on a remote server (e.g. if no binary is available locally)
JavaScript
5
star
21

magickli

open source magick stuff....
TypeScript
5
star
22

wmd

JavaScript
5
star
23

meteor-doingthiswith

Anybody doing this [technology/framework/sitetype] with Meteor?
JavaScript
5
star
24

fview-quickstart

Fresh meteor project using quickstart instructions from famous-views
CSS
4
star
25

meteor-famous

Temporary package for Famo.us Mixed Mode v0.5.0
JavaScript
4
star
26

meteor-prism

Prism Syntax Highlighter, integrated with Meteor
JavaScript
4
star
27

fview-lagometer

IjzerenHein's lagometer packaged for famous-views
JavaScript
4
star
28

meteor-spiderable-remote

Like spiderable, but runs phantomjs via phantomjs_remote
JavaScript
4
star
29

fview-sizeconstraint

set renderable scale, padding, max-size, min-size and aspect-ratio
HTML
4
star
30

mink

Mink - Meteor integration for INK File Picker
JavaScript
3
star
31

fview-timbre

Famous Timbre demo using famous-views
JavaScript
3
star
32

fview-demo

Demo of simple app using famous-views
CoffeeScript
2
star
33

meetup-fview-london

Slides for Meteor London meetup 2015-06-25
HTML
2
star
34

meteor-rest-test

Quick and dirty code to make HTTP.call's of different types and check request/response
JavaScript
2
star
35

meteor-accounts-merge

Let user login to and add multiple services to one account
JavaScript
2
star
36

meteor-snippets

Code snippets with highlighting and lang conversion
JavaScript
2
star
37

meteor-cross-domain-login

User remains logged in on same site across multiple domains
JavaScript
2
star
38

async-composable-tasks

Composable async tasks designed for await/sync and arrow functions, with progress and parallelism.
JavaScript
2
star
39

meteor-jquery2

jQuery 2.x packaged for Meteor
JavaScript
1
star
40

meteor-modules

Minimalist require support, with glslify hack.
JavaScript
1
star
41

meteor-react-container-efficiency

One autorun vs isolated autoruns in react
JavaScript
1
star
42

meteor-modal-bs3ui

bootstrap 3 modals, the Meteor way (for Meteor UI)
JavaScript
1
star
43

discourse2

Complete Discourse API, strongly typed
TypeScript
1
star
44

rtr-utils

Helpful utilities for react-three-render
JavaScript
1
star
45

meetup-fview-tlv

Meteor TLV Meetup 2015-06-14
HTML
1
star
46

meteor-mongo-stream

Live streaming of (recorder) streams (stdout/stderr/anything) to the browser
JavaScript
1
star
47

repro-ranjeev

https://forums.meteor.com/t/how-to-make-blaze-templates-reactive/21027
JavaScript
1
star
48

esphome-render

Live editor with realtime previews of esphome display component
TypeScript
1
star
49

meteor-jade-client

Wrapper for mquandalle:jade to use client-side
JavaScript
1
star
50

contributors-svg

Code for Contributors SVG service
JavaScript
1
star
51

meteor-json5

Meteor wrapper for json5 npm package
JavaScript
1
star
52

blaze-content

Minimal reproduction showing that content overrides .content in current context
JavaScript
1
star
53

redux-router-state

Store router state in Redux and route via redux
JavaScript
1
star
54

squid-ssl-zero

Zero-config squid caching proxy with SSL intercept (sslbump)
Shell
1
star
55

shadowlang

TypeScript
1
star
56

meetup-fview-ottawa

HTML
1
star
57

fetch-mock-cache

Caching mock fetch implementation for all JS runtimes and frameworks.
TypeScript
1
star