Giter VIP home page Giter VIP logo

babel-watch's People

Contributors

algrant avatar chibiblasphem avatar coreyleelarson avatar cromwellryan avatar dsokal avatar embraser01 avatar imalyugin avatar jacdebug avatar kmagiera avatar kurounin avatar laggingreflex avatar mendenhallmagic avatar mrsimonemms avatar pfhayes avatar puchm avatar romain-faust avatar stevemao avatar strml avatar supremetechnopriest avatar tmartensen avatar vladimirpal avatar yoshi415 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

babel-watch's Issues

Readline simply doesnt work with babel-watch

Since the watched app runs in a seperate process readline doesn't work, also no stdin is available for the process.

Would it be possible to forward the stdin to the sub process?

Thanks.

add --require for preload module

some syntax require babel-polyfill which can be added via --require for node cmd

-r, --require module to preload (option can be repeated)

babel-watch --present env index.js not work

throw following error:

$ ./node_modules/.bin/babel-watch --presets env server.js

/Users/tangmonk/Documents/mygit/nodejs/hotel_didi_car/server/api/index.js:9
        handler: async (request, reply) => {
        ^
ReferenceError: regeneratorRuntime is not defined

If i try to use multi presents:

$  ./node_modules/.bin/babel-watch --presets es2015 stage-3 server.js

Error: Cannot find module '/Users/tangmonk/Documents/mygit/nodejs/hotel_didi_car/stage-3'
    at Function.Module._resolveFilename (module.js:470:15)

babel-watch can't find "./package.json"

In node_modules/.bin/babel-watch line 38
const pkg = require('./package.json');

My docker image can't run babel-watch because it cant find ./package.json
and there is no ./package.json file in .bin directory.

But I tried to run it in my local and I can find it when I console.log(pkg)
So when exactly is this package.json made???

Problem with autowatch !?

Ok so, the second problem I encountered which can be easily workaround but still deserves an issue I think is that the autowatch doesn't work more than once per file.

With the same setup than in this issue: #42

So when I save a file, say index.js, the app restarts twice in a row as mentioned in the issue above. But then, if I change the same file, index.js (by changing the console.log text for instance) it does not restart.

Then if I go just save aFileToRequire.js, the app restarts (even wihtout any modif)... at least the first time. The second time I save, with or without modifs, nothing happens.

Since there's no more file in this small project, I can't restart it without 'rs' from there.

The workaround is using the babel-watch --watch . and then it works as expected.

Am I doing something wrong ?

Let me know you need more info :)

Crashes after restart: First argument must be file descriptor

Node version: 6.9.5
Platform: Linux (running in docker through this image: https://hub.docker.com/_/node/)
babel-watch version: 2.0.5

I can start babel watch and it works fine, will restart on changes successfully a few times and then when it tries to restart for the 2-6ish time, it will crash with the error:

/app/node_modules/babel-watch/babel-watch.js:298
          throw error;
          ^

 TypeError: First argument must be file descriptor
    at TypeError (native)
    at Object.fs.writeSync (fs.js:786:20)
    at error (/app/node_modules/babel-watch/babel-watch.js:289:12)
    at handleFileLoad (/app/node_modules/babel-watch/babel-watch.js:172:7)
    at ChildProcess.app.on (/app/node_modules/babel-watch/babel-watch.js:283:5)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at process.nextTick (internal/child_process.js:719:12)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

I can then restart it and it will work fine again for a bit, rinse and repeat.

I have been using babel-watch for a while now and never had this problem before.

Cannot read property 'list' of undefined when using with Babel 7

Callstack:
TypeError: Cannot read property 'list' of undefined at Object.<anonymous> (/Users/txie/Reizo/editor/node_modules/babel-watch/babel-watch.js:30:56) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.runMain (module.js:604:10) at run (bootstrap_node.js:394:7) at startup (bootstrap_node.js:149:9) at bootstrap_node.js:509:3

Not sure if this is Babel 7 specific issue, has babel-watch been tested against babel-core 7 alpha?

"Error: Cannot find module" with .jsx files

Trying to replace nodemon + babel-node with babel-watch, running with babel-watch gives an error when babel-node does not. I don't think the --extension option affects this but I threw it on just in case.

babel-core v6.14.0

should work, but does not:

$ node_modules/.bin/babel-watch src/index.js -e .js,.jsx
Error: Cannot find module './views/appFactory'

babel-node works:

$ node_modules/.bin/babel-node src/index.js
[18:18:23] Running server at 0.0.0.0:8000

Renaming appFactory.jsx to appFactory.js makes the error go away, but then I'd have to find all of them and this isn't my code.

CPU usage is through the roof

Something in babel-watch is being very greedy.

screen shot 2017-02-03 at 14 53 16

Platform info:

Darwin 16.3.0 x64
Node.JS 7.4.0
V8 5.4.500.45
NODE_ENV=production
Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz ร— 8

New files are not watched

I noticed that when i am adding a new file to the source, it doesn't really detect them. Any idea how to make it work?

[Enhancement] Offer to help fix Windows issues

It states in your documentation:

(It doesn't work on Windows as it uses unix named pipes, if you want to help with getting that fixed, feel free to contact me)

I'd be willing to help fix this issue :)

error babel-watch

node_modules/babel-watch/runner.js:34
  if (filename.charAt(0) !== '/') {
              ^

TypeError: Cannot read property 'charAt' of undefined
    at process.<anonymous> (node_modules/babel-watch/runner.js:34:15)
    at emitTwo (events.js:100:13)
    at process.emit (events.js:185:7)
    at handleMessage (internal/child_process.js:718:10)
    at Pipe.channel.onread (internal/child_process.js:444:11)

failing in docker container

I've gone ahead and added the -L option to babel-watch.

I seem to get the following error once I change a JS file

webrtc.server.1 | >>> RESTARTING <<<
webrtc.server.1 | Debugger listening on port 9229.
webrtc.server.1 | Warning: This is an experimental feature and could change at any time.
webrtc.server.1 | To start debugging, open the following URL in Chrome:
webrtc.server.1 | chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:9229/b18dea6d-3597-4911-a03d-991793729cf4
webrtc.server.1 | (node:18) DeprecationWarning: Calling an asynchronous function without callback is deprecated.
webrtc.server.1 |
webrtc.server.1 | /app/node_modules/depd/index.js:25
webrtc.server.1 | var basePath = process.cwd()
webrtc.server.1 | ^
webrtc.server.1 | Error: ENOENT: no such file or directory, uv_cwd
webrtc.server.1 | at Object. (/app/node_modules/depd/index.js:25:24)
webrtc.server.1 | at Module._compile (module.js:571:32)
webrtc.server.1 | at Module._extensions..js (module.js:580:10)
webrtc.server.1 | at Object.require.extensions.(anonymous function) [as .js] (/app/node_modules/babel-watch/runner.js:63:7)
webrtc.server.1 | at Module.load (module.js:488:32)
webrtc.server.1 | at tryModuleLoad (module.js:447:12)
webrtc.server.1 | at Function.Module._load (module.js:439:3)
webrtc.server.1 | at Module.require (module.js:498:17)
webrtc.server.1 | at require (internal/module.js:20:19)
webrtc.server.1 | at Object. (/app/node_modules/http-errors/index.js:15:17)

I am not able to find much online and the babel-watch documentation makes it think this should work.

main missing from `package.json`

I was working with babel-watch for a watch utility for the build tools I was making.

I noticed I couldn't do:

let moduleName = 'babel-watch';
let pathToWatch = require.resolve(moduleName);

To resolve the path so I can call it from shell, due to the packages.json is missing a main.

{
    "main": "babel-watch.js"
}

This could be very helpful if it was added into the package.json for developers who are consuming the module for utility use.

Does not honor .babelrc

babel-watch does not seem to honor my .babelrc

Currently:

{
  "presets": ["latest", "react", "stage-0"],
  "plugins": ["transform-decorators-legacy"]
}

Running my code with babel-watch and this error is thrown: regeneratorRuntime is not defined
While babel-node I am good to go

Option --debug-brk doesn't work

Hello.
If specify --debug-brk then app stop running:

node_modules/.bin/babel-watch src/server.js -I --debug-brk

If only --inspect option - all fine:

node_modules/.bin/babel-watch src/server.js -I

In babel-node options -I --debug-brk works well.

Node version: 7.9.0

run babel/node with a flag

Thank you this is exactly what we need but we are having a problem trying to run babel/node with a flag. Can you point us on how to achieve that with babel-watch. Thanks

with node: i can do this

node --harmony-async-await  server.js

with babel node:

babel-node --harmony-async-await  server.js

with nodemon:

nodemon --exec babel-node --harmony-async-await server.js

"Unexpected token import" when running babel-watch

Hey @kmagiera

Thanks for creating this package. It seems very useful!
Unfortunately I wasn't able to make it work so far. I have used the following command:

babel-watch --presets es2015 --watch src webpack/production.js

as well as other variations like these:

babel-watch --presets "es2015" --watch src webpack/production.js
babel-watch --presets=es2015 --watch src webpack/production.js
babel-watch --presets="es2015" --watch src webpack/production.js

I am getting the following error message:

C:\repos\my_repo\webpack\production.js:1
(function (exports, require, module, __filename, __dirname) { import webpack from 'webpack';
                                                              ^^^^^^
SyntaxError: Unexpected token import
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:404:25)
    at Module._extensions..js (module.js:432:10)
    at loader (C:\repos\my_repo\node_modules\babel-watch\runner.js:14:5)
    at Object.require.extensions.(anonymous function) [as .js] (C:\repos\my_repo\node_modules\babel-watch\runner.js:22:7)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Function.Module.runMain (module.js:457:10)
    at process.<anonymous> (C:\repos\my_repo\node_modules\babel-watch\runner.js:38:21)
    at emitTwo (events.js:87:13)

The file in question starts like this:

import webpack from 'webpack';

I also have a .babelrc-file but it doesn't seem to pick it up.

Any idea how I can get it to work?
I'm currently using nodemon with the following command (and yes, the performance is pretty bad):

nodemon --exec babel-node --debug webpack/production.js --watch webpack/production.js

stdout redirect and rewrite

Config: "start": "babel-watch script.js > out.txt".

When i run npm start, I want the output from script.js to rewrite to instead of appending to out.txt whenever the script is re-run.

I tried "babel-watch script.js >! out.txt" as well as >|, both don't work.

Perhaps I can config babel-watch such that it runs rm out.txt before running script.js?

babel watch internal/child_process.js:374

>>> RESTARTING <<<
internal/child_process.js:374
      throw errnoException(err, 'kill');
      ^

Error: kill ENOSYS
    at exports._errnoException (util.js:874:11)
    at ChildProcess.kill (internal/child_process.js:374:13)
    at killApp (C:\Users\wange\Desktop\dev\breaky\node_modules\babel-watch\babel-watch.js:201:14)
    at prepareRestart (C:\Users\wange\Desktop\dev\breaky\node_modules\babel-watch\babel-watch.js:218:5)
    at restartApp (C:\Users\wange\Desktop\dev\breaky\node_modules\babel-watch\babel-watch.js:224:3)
    at FSWatcher.handleChange (C:\Users\wange\Desktop\dev\breaky\node_modules\babel-watch\babel-watch.js:154:5)
    at emitTwo (events.js:87:13)
    at FSWatcher.emit (events.js:172:7)
    at FSWatcher.<anonymous> (C:\Users\wange\Desktop\dev\breaky\node_modules\chokidar\index.js:176:15)
    at FSWatcher._emit (C:\Users\wange\Desktop\dev\breaky\node_modules\chokidar\index.js:218:5)

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\wange\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v4.2.0
npm ERR! npm  v3.9.5
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: `cross-env NODE_ENV=development babel-watch server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script 'cross-env NODE_ENV=development babel-watch server'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the react-boilerplate package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     cross-env NODE_ENV=development babel-watch server
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs react-boilerplate
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls react-boilerplate
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\wange\Desktop\dev\breaky\npm-debug.log

This error occurs with babel-watch, requires multiple tries and it'll work again. Only on windows.

Seeking Maintainer?

Is this project actively being maintained? It looks like there are several open PRs that offer significant improvements to the codebase.

babel-watch stuck on >>> RESTARTING <<<

I have a task in my package.json which does the following:

scripts: {
  "watch": "babel-watch tests/run-jasmine.js --presets es2015 --watch",
}

This used to work, but nowadays (in any 2.0.x version), the task stalls on >>> RESTARTING <<<. No significant cpu usage as far as I can tell. The only major change we did to our project recently was upgrade from Node 4.5 to Node 6.9/6.10, the latest LTS versions.

Changes in views are not being watched

First off, great library (thank you)!

I'm having some trouble getting this to work when a change is made in one of my view files. I'm using express and nunjucks (html) templates. If I change a .js file, it restarts lightning fast, but if I change one of my .html template files it doesn't restart.

I've tried playing around with the extensions flag, but haven't had any luck.

Any help would be great. Thanks

DeprecationWarning: Calling an asynchronous function without callback is deprecated.

I've added babel-watch to my project.

I've created a very simple index.js file :

// very simple code, just to test
console.log('ok')

I've started babel-watch index.js with an npm run script and I get this in the console when I save some change in my index.js file :

>>> RESTARTING <<<
(node:36053) DeprecationWarning: Calling an asynchronous function without callback is deprecated.
ok

Can you tell me how to hide this warning ?
I wonder if it's generated by the babel-watch code.

System files get generated

I'm using babel-watch (v2.0.2) with NodeJS (v6.5) and Docker compose (1.8.0) on a Mac and it works great - thanks.

The only issue I'm getting is that every time I run a command with babel-watch is that it generates a series of systems files in the root of my project. These files appear to be sequential with the number increasing by one each day. I've done quite a bit of investigation as I believe that babel-watch is what's creating them and it only happens on a Docker container.

These are the files generated today (from an ls -la command)

prw-rw-rw-  1 semms  staff  0 21 Sep 09:57 116821-28-g6kgm4.l65h9cc8fr
prw-rw-rw-  1 semms  staff  0 21 Sep 10:00 116821-28-oxs06c.dkqtm1v2t9
prw-rw-rw-  1 semms  staff  0 21 Sep 09:35 116821-29-1n7nvjh.6lej0pb9
prw-rw-rw-  1 semms  staff  0 21 Sep 09:59 116821-29-60yxjk.smwxbf0f6r
prw-rw-rw-  1 semms  staff  0 21 Sep 10:01 116821-29-kzs2k9.ru65p9o1or
prw-rw-rw-  1 semms  staff  0 21 Sep 09:42 116821-54-z1ahkg.1d5onljtt9

I'm ok with babel-watch creating them, but I'd like to add the removal to my cleanup script. How is the file name generated so I can add a cleaner way of deleting them other than rm 1168*?

Restarts twice

Hi there !

First of all, I love what you did :)

Now, I don't know why but when I change a file, babel-watch restarts my app twice. This is pretty fast so it wouldn't be much of a problem if it wasn't for the app not finding a module... (this issue in fact: #37)

I thought maybe I have something in my project that is probably messing with babel-watch since there's no issues about it here so I made this simple test case:

index.js

const someText = require('./aFileToRequire')
console.log(someText)

aFileToRequire.js

module.exports = "banana"

babel-watch ./index.js

When saving either file, it restarts twice.

I tried with node 6.9.2 ans 7.4.0.

Anybody with the same problem ?

Using breakpoints doesn't work when debugging

My npm script is as follows:

{
  ...
  "scripts": {
    "start": "babel-watch --debug 5859 src/backend/index.js",
    ...
  },
  ...
}

I get the Debugger listening on [::]:5859 message and my debugger is able to connect on port 5859, but putting breakpoints in my IDE (JetBrains WebStorm) appears to do nothing, making debugging effectively useless.

Using the --debug-brk option also screws up the debugging process, making it break on the underlying runner.js file instead of the script we want it to run on.

Any ideas how to make breakpoints work?

babel-watch version is 2.0.6

Debugging

Is it possible to pass the --debug and --debug-break arguments? That would allow using babel-watch with debugging tools like node-inspector or VS Code. Both node and babel-node accept these arguments.

Syntax error in a file crashes babel-watch

Not only it crashes but also triggers a bug in Node.js making it gets stuck at 100% cpu usage.

I get infinite of this in dtrace of the process with 100% cpu usage

dtrace: error on enabled probe ID 2134 (ID 318: syscall::read:return): invalid kernel access in action #12 at DIF offset 92

I also get this in my log

Error: Cannot find module 'our-storage'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/steel/w/d/triangle/packages/container/lib/projects.js:3:1)
    at Module._compile (module.js:570:32)
    at babelWatchLoader (/Users/steel/w/d/triangle/node_modules/babel-watch/runner.js:50:13)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/steel/w/d/triangle/node_modules/babel-watch/runner.js:61:7)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
fs.js:786
    return binding.writeBuffer(fd, buffer, offset, length, position);
                   ^

Error: EPIPE: broken pipe, write
    at Error (native)
    at Object.fs.writeSync (fs.js:786:20)
    at handleFileLoad (/Users/steel/w/d/triangle/node_modules/babel-watch/babel-watch.js:273:27)
    at handleFileLoad (/Users/steel/w/d/triangle/node_modules/babel-watch/babel-watch.js:170:7)
    at ChildProcess.app.on (/Users/steel/w/d/triangle/node_modules/babel-watch/babel-watch.js:263:5)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at process.nextTick (internal/child_process.js:744:12)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

I'm on macOS Sierra, with Node v6.9.1 and babel-watch v2.0.3

Sometimes process can fail to restart

I've noticed that when many restarts are triggered in quick succession (for example, by running a git pull), then an error can come up and the watch process will stop monitoring.

Error: Cannot find module './express/app'
    at Function.Module._resolveFilename (module.js:455:15)
    at Function.Module._load (module.js:403:25)
    at Module.require (module.js:483:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/patrick/project/js/config/main.js:7:17)
    at Module._compile (module.js:556:32)
    at babelWatchLoader (/Users/patrick/project/node_modules/babel-watch/runner.js:50:13)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/patrick/project/node_modules/babel-watch/runner.js:61:7)
    at Module.load (module.js:473:32)
    at tryModuleLoad (module.js:432:12)
fs.js:786
    return binding.writeBuffer(fd, buffer, offset, length, position);
                   ^

Error: EPIPE: broken pipe, write
    at Error (native)
    at Object.fs.writeSync (fs.js:786:20)
    at handleFileLoad (/Users/patrick/project/node_modules/babel-watch/babel-watch.js:279:30)
    at handleFileLoad (/Users/patrick/project/node_modules/babel-watch/babel-watch.js:172:7)
    at ChildProcess.app.on (/Users/patrick/project/node_modules/babel-watch/babel-watch.js:273:5)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at process.nextTick (internal/child_process.js:744:12)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

Normally there is no problem with importing ./express/app - it appears to just be a transient error while the filesystem is changing. However, after this error comes up I need to kill babel-watch and restart it in order for monitoring to continue

Error on process kill when babel-watch is run using npm

node v6.11.1
npm v5.3.0
babel-watch v2.0.7

This doesn't appear to cause any problems, but it's quite annoying.

When I run babel-watch with npm run serve:watch and kill the process with CTRL+C, I get the following error:

package.json

{
  scripts: {
    "serve:watch": "cross-env NODE_ENV=development babel-watch server/development.js"
  }
}

terminal command run

npm run serve:watch

terminate command with
CTRL+C

terminal output

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] serve:watch: `cross-env NODE_ENV=development babel-watch server/development.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] serve:watch script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/nmcl54/.npm/_logs/2017-08-07T06_09_19_750Z-debug.log

Interestingly, I do not get this error when I run my script with yarn run serve:watch.

Debugging

Here are some notes I put together while trying to get debugging working. I'm looking for suggestions on how to get this to work.

Environment

osx 10.11.2
node v4.4.7
[email protected]
[email protected]
[email protected]

Node command line flag order

Does not work: node ./test.js --debug-brk
Works: node --debug-brk ./test.js

Ref: https://github.com/nodejs/node/blob/master/src/node.cc#L3420

Cannot change order of flags passed to babel-watch

Babel watch thinks that the first argument in babel-watch --debug-brk ./test.js is a file.
The offending three lines begin at https://github.com/kmagiera/babel-watch/blob/master/babel-watch.js#L92

Args passed to babel watch don't seem to influence node arguments on spawned node process (forking the runner.js script)

Am I correct in understanding that in runner.js, runMain just loads the modules?
Ref: https://github.com/nodejs/node/blob/master/lib/module.js#L573
If this is true, then we cannot expect node arguments to be propagated at the point runMain is called.
Ref: https://github.com/kmagiera/babel-watch/blob/master/runner.js#L87

Alternative attempt at passing node arguments to child process

Changing https://github.com/kmagiera/babel-watch/blob/master/babel-watch.js#L240 to
const app = fork(path.resolve(__dirname, 'runner.js'), {execArgv: ['--debug-brk']}); seems to do this to ps

26214   0.0  0.2  3671444  39284 s012  S+   12:51AM   0:00.48 /Users/n/.nvm/versions/node/v4.4.7/bin/node --debug-brk /Users/n/P/node_modules/babel-watch/runner.js
26210   0.0  0.2  3104508  41884 s012  S+   12:51AM   0:00.64 node /Users/n/P/node_modules/.bin/babel-watch ./test.js
26208   0.0  0.5  3121008  82492 s013  S+   12:50AM   0:02.60 node /Users/n/P/node_modules/.bin/node-inspector

But this just stops at module.js:409 and then doesn't even run the test script when unpaused.

This is the closest I've gotten so far.

Ref: https://github.com/nodejs/node/blob/master/lib/child_process.js#L39

Endnote

As an aside, I'm curious why you decided not to read from .babelrc or package.json.

Thanks for putting this together. I find it to be the nicest approach out there for loading transpiled files.

Error about 'import' ...not loading babelrc?

I'm getting the following error

Command babel-watch --watch ./client/src --watch ./webpack ./bin/server.js

/Users/loudwinston/testapp/bin/server.js:1
(function (exports, require, module, __filename, __dirname) { import path from 'path';
                                                              ^^^^^^

SyntaxError: Unexpected reserved word

My .babelrc has "presets": ["react", "es2015", "stage-0"],

Does babel-watch load the .babelrc from the current working directory?

"SyntaxError: Unexpected token import" when running babel-watch

Unfortunately, the issue I mentioned in the PR #2 is still present. The command I'm running is:

babel-watch --watch src --watch toolkit/webpack toolkit/webpack/development.js

This is the error I get is:

D:\_repos\universal-dev-toolkit\src\client\views\AppBody\Component.js:1
(function (exports, require, module, __filename, __dirname) { import React from 'react';
                                                              ^^^^^^

SyntaxError: Unexpected token import
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:404:25)
    at Module._extensions..js (module.js:432:10)
    at loader (D:\_repos\universal-dev-toolkit\node_modules\babel-watch\runner.js:14:5)
    at Object.require.extensions.(anonymous function) [as .js] (D:\_repos\universal-dev-toolkit\node_modules\babel-watch\runner.js:22:7)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (AppBody.js:5:1)
    at Module._compile (module.js:425:26)
    at loader (D:\_repos\universal-dev-toolkit\node_modules\babel-watch\runner.js:12:13)
    at Object.require.extensions.(anonymous function) [as .js] (D:\_repos\universal-dev-toolkit\node_modules\babel-watch\runner.js:22:7)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)

See the corresponding PR.

Cannot change port to different port than 8080

$ babel-watch ./src/index.js --port 8081
Error: listen EADDRINUSE :::8080
    at Object.exports._errnoException (util.js:1022:11)
    at exports._exceptionWithHostPort (util.js:1045:20)
    at Server._listen2 (net.js:1259:14)
    at listen (net.js:1295:10)
    at Server.listen (net.js:1391:5)
    at EventEmitter.listen (/my-app/node_modules/express/lib/application.js:617:24)
    at Object.<anonymous> (/my-app/src/index.js:11:5)
    at Module._compile (module.js:570:32)
    at babelWatchLoader (/my-app/node_modules/babel-watch/runner.js:50:13)
    at Object.require.extensions.(anonymous function) [as .js] (/my-app/node_modules/babel-watch/runner.js:61:7)

babel-watch unexpected token but babel-node works fine

NODE_ENV=production node_modules/.bin/babel-node --presets react,es2015 src/server.js
This command dosent gives me any error (babel node) but

NODE_ENV=production node_modules/.bin/babel-watch --presets react,es2015 src/server.js
This command gives me error (babel-watch)

Undexpected token at

<Route > ...

Source maps problem

Hi, first thanks for this module, it made my restarts much faster ๐Ÿ‘

However, my error stack traces show wrong line numbers. If i run the app with babel-node --source-maps the line numbers are correct. Does anybody else have this issue?

Breaking hotreloading

Thank you very much for the great job with babel-watch.
Our restart time went way down since we started using it.

The problem that we still have is that the autowatch breaks the react-hot-loader in our universal configuration.

// .babelrc
{
  "presets": ["react", "es2015", "stage-0"],
  "plugins": ["react-hot-loader/babel"],
  "env": {
    "production": {
      "presets": ["es2015", "react", "react-optimize", "es2015-native-modules", "stage-0"]
    }
  }
}

// client/index.js - Client entry point

import React from 'react';
import { render } from 'react-dom';
import { AppContainer } from 'react-hot-loader';
import App from './App';
import { configureStore } from './store';

// Initialize store
const store = configureStore(window.__INITIAL_STATE__);
const mountApp = document.getElementById('root');

render(
  <AppContainer>
    <App store={store} />
  </AppContainer>,
  mountApp
);

// For hot reloading of react components
if (module.hot) {
  module.hot.accept('./App', () => {
    // If you use Webpack 2 in ES modules mode, you can
    // use <App /> here rather than require() a <NextApp />.
    const NextApp = require('./App').default; // eslint-disable-line global-require
    render(
      <AppContainer>
        <NextApp store={store} />
      </AppContainer>,
      mountApp
    );
  });
}

If we run the process with just cross-env babel-watch -r dotenv/config index.js dotenv_config_silent=true, when a component is changed, the server restart. This breaks the socket connection of the hot reload (in the console we see: :8000/__webpack_hmr:1 GET http://localhost:8000/__webpack_hmr net::ERR_INCOMPLETE_CHUNKED_ENCODING )

The workaround that we found was adding -D --watch server that watches ONLY the server folder.

This is still less than ideal. Now the server does not restart if a component is changed but only when a file in the /server folder changes. The problem is that in order for the server to reload a component for a full page reload we have to manually Ctrl-C and restart the server.

Ideally when a component is updated, the server set a flag and on the next full page reload, the server is restarted.

I wonder if there is already a way to fix this or if babel-watch could expose a way for the process to detect if a file changes and delay the reload until an event is triggered (i.e. access to a react-router route).

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.