Giter Club home page Giter Club logo

trailpack-autoreload's Introduction

trailpack-autoreload

NPM version Build status Dependency Status Code Climate

This Trailpack will automatically reload your Trails application on code changes. It listens for changes in api/ and config/.

Install

$ npm install --save trailpack-autoreload

Configure

// config/main.js
module.exports = {
  packs: [
    // ... other trailpacks
    require('trailpack-autoreload')
  ]
}

This trailpack offers significant performance advantages over other solutions such as nodemon, which restarts the entire node process. This trailpack detects the file(s) in which the change occured, evicts those modules from the require cache, and reloads the Trails application (via app.start()). Moreover, the application will continue running in its current state if a syntax error is written into a watched file; Trails will inform you of the error, and carry on.

The synchronous node require statement incurs non-negligible boot-time overhead. We avoid these costs by evicting only the affected module(s).

trailpack-autoreload's People

Contributors

tjwebb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

trailpack-autoreload's Issues

"Cannot assign to read only property ..." errors on reload in trailpacks

Following errors occur on reload in my current trails set up:

error: 
 TypeError: Cannot assign to read only property 'server' of object '#<Object>'
    at HapiTrailpack.configure (node_modules/trailpack-hapi/index.js:38:22)
    at app.after.then (node_modules/trails/lib/trailpack.js:63:26)
error: 
 TypeError: Cannot assign to read only property 'orm' of object '#<Object>'
    at BookshelfTrailpack.configure (index.js:100:5)
    at app.after.then (node_modules/trails/lib/trailpack.js:63:26)

package.json:

...
    "trailpack": "^1.0.2",
    "trailpack-autoreload": "^1.0.2",
    "trailpack-core": "1.0.0-beta-6",
    "trailpack-datastore": "^1.0.1",
    "trailpack-footprints": "^1.0.0",
    "trailpack-hapi": "^1.0.1",
    "trailpack-repl": "^1.0.6",
    "trailpack-router": "^1.0.2",
    "trailpack-webpack": "0.0.4",
    "trails": "^1.0.0",
    "trails-controller": "^1.0.0-beta-2",
    "trails-model": "^1.0.0-beta-2",
    "trails-policy": "^1.0.2",
    "trails-service": "^1.0.0-beta-2",
...

Autoreload not work

Not work for me
node 4.4.4, express 4

When I change text I have message in console, but web page does not change. Nodemon work fine
index(req, res) { res.send('Text') }
trails > info: App reloaded with changes in api/controllers/TestController.js

Changes not applied when reloading

So get this message in the console:

trails > info: App reloaded with changes in api/controllers/TransactionsController.js

But the changes are not applied, I still get the same response from the server, even I changed it. I tried manually changing the package in node_modules and setting usePolling: true but still doesn't work. Any ideas?

Information:

{
    "app": "0.0.0",
    "node": "v8.1.3",
    "libs": {
        "http_parser": "2.7.0",
        "node": "8.1.3",
        "v8": "5.8.283.41",
        "uv": "1.12.0",
        "zlib": "1.2.11",
        "ares": "1.10.1-DEV",
        "modules": "57",
        "openssl": "1.0.2l",
        "icu": "59.1",
        "unicode": "9.0",
        "cldr": "31.0.1",
        "tz": "2017b"
    },
    "trailpacks": [
        {
            "name": "repl",
            "version": "2.1.0"
        },
        {
            "name": "router",
            "version": "2.1.0"
        },
        {
            "name": "hapi",
            "version": "2.2.0"
        },
        {
            "name": "sequelize",
            "version": "2.0.0"
        },
        {
            "name": "footprints",
            "version": "2.0.0"
        },
        {
            "name": "autoreload",
            "version": "1.0.2"
        }
    ]
}

Error

With the npm version 1.0.1 I have this error when sources are reloaded :

TypeError: Cannot redefine property: inspect
    at Function.defineProperty (native)
    at Object.configureApp (/Users/jaumard/Downloads/testTrails/node_modules/trailpack-repl/lib/inspect.js:65:12)
    at REPL.configure (/Users/jaumard/Downloads/testTrails/node_modules/trailpack-repl/index.js:17:17)
    at /Users/jaumard/Downloads/testTrails/node_modules/trails/lib/trailpack.js:56:26
    at process._tickDomainCallback (node.js:407:9)

reload + waterline issue

Enable autoreload in main.js packs with waterline-sqlite3 display error : " Cannot read property 'identity' of undefined"

TypeError: Cannot read property 'identity' of undefined
    at _.mapValues.store (/home/workplace/trails/node_modules/trailpack-waterline/lib/transformer.js:53:31)
    at /home/workplace/trails/node_modules/lodash/lodash.js:13303:38
    at /home/workplace/trails/node_modules/lodash/lodash.js:4917:15
    at baseForOwn (/home/workplace/trails/node_modules/lodash/lodash.js:2979:24)
    at Function.mapValues (/home/workplace/trails/node_modules/lodash/lodash.js:13302:7)
    at Object.transformConnections (/home/workplace/trails/node_modules/trailpack-waterline/lib/transformer.js:51:14)
    at WaterlineTrailpack.initialize (/home/workplace/trails/node_modules/trailpack-waterline/index.js:46:40)
    at app.after.then (/home/workplace/trails/node_modules/trails/lib/trailpack.js:58:26)

how to reproduce :

  • install trails yo trails
  • install waterline-sqlite3 npm install --save waterline-sqlite3
  • install autoreload npm install --save trailpack-autoreload
  • enable dev connexion in database.js
  • enable autoreload in main.js require('trailpack-autoreload')
  • run server npm start
  • edit file to trigger reload ( like config/routes.js by adding 'POST' to /api/v1/default/info )

Informations:

  • npm -v => 3.10.8
  • node -v => 6.7.0

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.