Giter Site home page Giter Site logo

sails-hook-babel's Introduction

## SANE Stack [![Bountysource][bounty-badge]][bounty-badge-url] [![Gitter][gitter-badge]][gitter-badge-url]

Build Status Build status Dependency Status npm

NOTE: This project, while exciting, is still an early prototype. While being mostly stable it is still being iterated with feature changes and improvements fairly regularly.

Sane - A Javascript fullstack and cli that uses two of the best frameworks, Sails and Ember, so you can rapidly create production-ready web applications. It takes away all the hassle setting up the full backend and frontend environment, embracing convention-over-configuration all the way, so you can focus just on shipping your app. Additionally this cli also supports Docker, using Docker Compose, to automatically install dependencies such as your database and will make deployment easier.

Quickstart:

  • npm install -g sails sane-cli
  • sane new project creates a local project with sails-disk. To install with Docker and production databases see Options.
  • sane generate resource user name:string age:number to generate a new API on the backend and models on the frontend
  • sane up to start the sails server on localhost:1337 as well as the ember dev server on localhost:4200.
  • To work on your frontend-app you work as you would normally do with ember-cli on localhost:4200.
  • You are now good to go.

Note: If you use Docker, make sure you have Docker Compose installed.

On Mac or Windows Docker Toolbox is required. This will install all of the necessary Docker tooling, including VirtualBox.

For Linux see: https://docs.docker.com/installation/ubuntulinux/

Documentation

The full documentation is available at: http://sanestack.com/

Development

sane-cli is developed with ES6/7 functionality, using traceur to provide a cleaner code as well as a nice experience for us the developers. To get started:

  • git clone https://github.com/artificialio/sane.git
  • cd sane && npm install to install the dependencies
  • npm link to make sure you can test the master version globally
  • If you add a new feature an according test would be appreciated
  • npm test to run the test-suite

Thanks

Thanks to mphasize for creating sails-generate-ember-blueprints which overwrites the default SailsJS JSON response to the one that Ember Data's RESTAdapter and RESTSerializer expects. Thanks to sails for that great backend framework Thanks to ember-cli contributors for all the great effort that has gone into this product and from which I have taken a lot of inspiration and code, especially in regards to testing.

License

SANE Stack is MIT Licensed.

Built by

Built with love by Artificial Labs and contributors <3

sails-hook-babel's People

Contributors

codymorrison avatar dangreen avatar globegitter avatar hellowin avatar pahan35 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sails-hook-babel's Issues

Couldn't find preset "es2015" relative to directory

after installing the hook and tring to lift getting this error im on sails 12.0.1
some problems with the paths

D:\projects\myproject\web-server\node_modules\sails-hook-babel\node_modules\babel-register\node_modules\babel-core\lib\transformation\file\options\o
ption-manager.js:364
    return presets.map(function (val) {
                   ^
Error: Couldn't find preset "es2015" relative to directory "D:\\projects\\myproject\\web-server\\api\\responses"
    at D:\projects\myproject\web-server\node_modules\sails-hook-babel\node_modules\babel-register\node_modules\babel-core\lib\transformation\file\op
tions\option-manager.js:372:17
    at Array.map (native)
    at OptionManager.resolvePresets (D:\projects\myproject\web-server\node_modules\sails-hook-babel\node_modules\babel-register\node_modules\babel-c
ore\lib\transformation\file\options\option-manager.js:364:20)
    at OptionManager.mergePresets (D:\projects\myproject\web-server\node_modules\sails-hook-babel\node_modules\babel-register\node_modules\babel-cor
e\lib\transformation\file\options\option-manager.js:348:10)
    at OptionManager.mergeOptions (D:\projects\myproject\web-server\node_modules\sails-hook-babel\node_modules\babel-register\node_modules\babel-cor
e\lib\transformation\file\options\option-manager.js:307:14)
    at OptionManager.init (D:\projects\myproject\web-server\node_modules\sails-hook-babel\node_modules\babel-register\node_modules\babel-core\lib\tr
ansformation\file\options\option-manager.js:465:10)
    at compile (D:\projects\myproject\web-server\node_modules\sails-hook-babel\node_modules\babel-register\lib\node.js:81:45)
    at loader (D:\projects\myproject\web-server\node_modules\sails-hook-babel\node_modules\babel-register\lib\node.js:126:14)
    at Object.require.extensions.(anonymous function) [as .js] (D:\projects\myproject\web-server\node_modules\sails-hook-babel\node_modules\babel-re
gister\lib\node.js:136:7)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at D:\projects\myproject\web-server\node_modules\include-all\index.js:129:29
    at Array.forEach (native)
    at requireAll (D:\projects\myproject\web-server\node_modules\include-all\index.js:44:9)

Can't make this to work, filename error

I'm trying to make this hook to work but I keep getting an error:


info: Starting app...

/Users/Me/Workspace/project/server/node_modules/source-map-support/source-map-support.js:415
      var hasStack = (arguments[1] && arguments[1].stack);
                                                  ^

TypeError: Cannot read property 'filename' of undefined

My package.json looks like this:

{
  "name": "demo-server",
  "version": "1.0.0",
  "description": "Demo server",
  "keywords": [],
  "dependencies": {
    "ejs": "^2.5.2",
    "include-all": "^1.0.0",
    "rc": "1.0.1",
    "sails": "~0.12.9",
    "sails-disk": "~0.10.9",
    "sails-hook-babel": "^6.0.1"
  },
  "scripts": {
    "start": "babel-node app.js"
  },
  "main": "app.js",
  "author": "Alex",
  "license": "MIT",
  "repository": {},
  "devDependencies": {
    "eslint": "^3.9.1",
    "eslint-plugin-import": "^2.1.0"
  }
}

I did a fresh install of sails, added a few dependencies, and since I added sails-hook-babel and it doesn't work anymore.

Exports seems broken with 0.11.5 and 0.12

See balderdashy/sails#3576

I have tracked down the errors when I try to lift my existing app with either 0.11.5 or 0.12.0 to some changing in how the export keyword handling, in particular, is interacting with the controller registration.

Has anyone else run into oddness with controller actions not being found because of exporting a default object instead of each function out of a controller module?

I can work around that but in doing so, am seeing something else odd that I hope someone else has seen and fixed, that my controller modules are getting clobbered with what looks like some policy configuration.

All routes hanging

In upgrading from 5.x to 6.x, I've come across and have solved most of the usual Babel issues. Now that I'm not getting anymore errors though, I'm still unable to use my app. Any page/route I try to go to hangs. That is, the request is sent but a response is never received. --silly confirms my routes are being binded properly so not really sure what to make of this.

This is the classic symptom of res.send(...) or res.view(...) not being called. Haven't messed with any application logic in the port though so I'm kind of stumped as to what to look at next. Only global-ish change I made was adding the Babel plugin "transform-strict-mode".

It appears my policies are working though as a restricted page will return a 302 redirect to /login. But /login and other public routes just hang.

Any ideas? Thanks.

`filename` of undefined error when used with mocha

I am getting TypeError: Cannot read property 'filename' of undefined from node-source-map-support when running mocha. By manually going into that package and doing a console.trace(), I get this stack trace below:

> PORT=9999 NODE_ENV=testing mocha --compilers js:babel-register ./test/bootstrap.test.js ./test/unit/*.test.js ./test/unit/**/*.test.js --timeout 20000
warn: Sails' built-in layout support only works with the `ejs`, `handlebars`, `ractive` view engines.
warn: You're using `jade`.
warn: Ignoring `sails.config.views.layout`...
Trace
    at Object.exports.install (/Users/austinmao/Sites/aditive-backend/node_modules/source-map-support/source-map-support.js:426:11)
    at Hook.configure (/Users/austinmao/Sites/aditive-backend/node_modules/sails-hook-babel/index.js:43:28)
    at Hook.bound [as configure] (/Users/austinmao/Sites/aditive-backend/node_modules/sails/node_modules/lodash/dist/lodash.js:729:21)
    at /Users/austinmao/Sites/aditive-backend/node_modules/sails/lib/app/private/loadHooks.js:176:18
    at /Users/austinmao/Sites/aditive-backend/node_modules/sails/node_modules/async/lib/async.js:122:13
    at _each (/Users/austinmao/Sites/aditive-backend/node_modules/sails/node_modules/async/lib/async.js:46:13)
    at Object.async.each (/Users/austinmao/Sites/aditive-backend/node_modules/sails/node_modules/async/lib/async.js:121:9)
    at Object.async.series.configure (/Users/austinmao/Sites/aditive-backend/node_modules/sails/lib/app/private/loadHooks.js:174:17)
    at /Users/austinmao/Sites/aditive-backend/node_modules/sails/node_modules/async/lib/async.js:620:25
    at iterate (/Users/austinmao/Sites/aditive-backend/node_modules/sails/node_modules/async/lib/async.js:146:13)
    at /Users/austinmao/Sites/aditive-backend/node_modules/sails/node_modules/async/lib/async.js:157:25
    at /Users/austinmao/Sites/aditive-backend/node_modules/sails/node_modules/async/lib/async.js:626:21
    at done (/Users/austinmao/Sites/aditive-backend/node_modules/sails/node_modules/async/lib/async.js:132:19)
    at /Users/austinmao/Sites/aditive-backend/node_modules/sails/node_modules/async/lib/async.js:32:16
    at doNTCallback0 (node.js:407:9)
    at process._tickCallback (node.js:336:13)
/Users/austinmao/Sites/aditive-backend/node_modules/mocha-clean/index.js:45
  if (!e.stack) return e;
        ^

TypeError: Cannot read property 'filename' of undefined
npm ERR! Test failed.  See above for more details.

The weird thing is that this doesn't happen in Codeship. The problem goes away when I downgrade to package v6.0.0 (without node-source-map-support).

I'm not so familiar with these two packages, so would you know how to fix this so I can actually get source map support back?

compile assets

Hello, quite straight forward title, can I use the hook to compile client code ?

Cheers

Doesn't seem to be working for me

Hi,

I did npm install sails-hook-babel all went well and it installed,

then I go and make

assets/js/main.js

Then to test it out I ran:

(() =>
  console.log('Hi')
)();

But I just get an error. It compiles just fine on the babel website so I'm not sure what I'm doing wrong.

Production?

Does anyone have an elegant solution for building a sails app with babel for production?

Track current bable or warn about a hard dependency on 5.0.9

I installed babel-runtime and babel-loader so I could use the babel-parser in my mocha tests. That generated a peer dependency warning in npm 3. When I explicitly installed babel to satisfy the warning, it installed 5.8.23. When trying to run my tests, I then started seeing:

     Uncaught Error: only one instance of babel/polyfill is allowed

I had to remove the explicit dependency and basically re-install my dependency graph from scratch. It would be nice to have a documented warning about sticking to the supported version in the hook or tracking a more current version for folks using babel in the same project but outside of the hook, too.

source-map-support breaks sails lift

My application uses sails with sails-hook-babel. Sadly sails lift breaks with the following errors:

application/node_modules/sails-hook-babel/node_modules/source-map-support/source-map-support.js:411
      var hasStack = (arguments[1] && arguments[1].stack);
                                                  ^

TypeError: Cannot read property 'filename' of undefined

Anyone else having this issue / solution?

Aurelia.io + Sails + Babel

Hi,

I was wondering if you would have some time to spare to answer a simple question.

I'm doing something none-standard with sails. I'm trying to have it serve an Aurelia app.
However I would like to use ECMA6 or 7 and for that I'll need babel. By default Aurelia uses Gulp with babel. Which works out of the box.

As you might have guessed I'm having some trouble getting babel/sails set up to transpile the aurelia code.

Currently I'm using a folder called "views" in the "assets" folder to house the ECMA7 code. I would like to transpile that before/during the copying to the .tmp/public folder.

Does your hook cover that? Or do I need to adjust something in order to get this working?

Thanks in advance, Robert.

@Globegitter

Unable to use book in unit testing using mocha

Hello, Great work! The hook works perfectly when I do a sails lift on the console, but while running unit tests through mocha, it fails with a syntax error,

"before all" hook:

Uncaught /Users/salmanhasratkhan/Desktop/es6_trial/api/controllers/TestController.js:4
        console.log(__.ifNot(s => s == 2, 2));
                               ^^
Unexpected token =>

this is the way I lift sails in mocha

console.log('bootstrap before');
    Sails.lift({
        //configuration for testing purposes
        hooks: {
            // Load the hook
            "babel": require('../../../'),
            // Skip grunt
            "grunt": false
        },
        log: {
            level: "error"
        }

    });

Any ideas what is preventing it from working correctly? Thanks

ReferenceError: regeneratorRuntime is not defined

After installing sails-hook-babel, I cannot launch sails app. I receive error ReferenceError: regeneratorRuntime is not defined on each sails helper function.

I created a config/babel.js file with polyfill: true and teh app launches, but then it gives me a new error of cannot read success of undefined when trying to return a value in exits.success in an actions2 action.

Using:
Sails 1.0
Node 10

Error after installing sails-hook-babel and trying to launch sails app:

--
error: Attempted to require('/Users/charlesw/Code/goodnature-api-sails/api/helpers/get-matching-contacts.js'), but an error occurred:
ReferenceError: regeneratorRuntime is not defined
at /Users/charlesw/Code/goodnature-api-sails/api/helpers/get-matching-contacts.js:29:5
at Object. (/Users/charlesw/Code/goodnature-api-sails/api/helpers/get-matching-contacts.js:29:5)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Module._compile (/Users/charlesw/Code/goodnature-api-sails/node_modules/pirates/lib/index.js:99:24)
at Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Object.newLoader [as .js] (/Users/charlesw/Code/goodnature-api-sails/node_modules/pirates/lib/index.js:104:7)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at /Users/charlesw/Code/goodnature-api-sails/node_modules/include-all/lib/help-include-all-sync.js:293:33
at Array.forEach ()
at _recursivelyIncludeAll (/Users/charlesw/Code/goodnature-api-sails/node_modules/include-all/lib/help-include-all-sync.js:178:11)
at includeAll (/Users/charlesw/Code/goodnature-api-sails/node_modules/include-all/lib/help-include-all-sync.js:317:5)
at helpBuildDictionary (/Users/charlesw/Code/goodnature-api-sails/node_modules/include-all/lib/help-build-dictionary.js:46:13)
at Function.module.exports.optional (/Users/charlesw/Code/goodnature-api-sails/node_modules/include-all/index.js:67:10)
at loadHelpers (/Users/charlesw/Code/goodnature-api-sails/node_modules/sails/lib/hooks/helpers/private/load-helpers.js:24:14)
at Hook.initialize (/Users/charlesw/Code/goodnature-api-sails/node_modules/sails/lib/hooks/helpers/index.js:285:7)
at Hook.wrapper [as initialize] (/Users/charlesw/Code/goodnature-api-sails/node_modules/@sailshq/lodash/lib/index.js:3282:19)
at /Users/charlesw/Code/goodnature-api-sails/node_modules/sails/lib/hooks/index.js:122:20
at /Users/charlesw/Code/goodnature-api-sails/node_modules/async/dist/async.js:421:16

How to polyfill

Sorry, I'm not a Sails pro. I just need to enable babel-polyfill. I can't figure out where to stick the file or what config to set. The README is a bit too terse for me to understand.

Thanks

SyntaxError: Unexpected reserved word for import

Even after installing this hook I am facing the same issue. I am using nodejs and having the default configs specified for this hook.
Following is the stack trace.
SyntaxError: Unexpected reserved word
at Module._compile (module.js:439:25)
at Module._extensions..js (module.js:474:10)
at Object.require.extensions.(anonymous function) as .js
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/home/jabong/projects/INDFAS/Jiesenberg/api/services/TestInterpreter.js:1:19)
at Module._compile (module.js:456:26)
at normalLoader (/home/jabong/projects/INDFAS/Jiesenberg/node_modules/sails-hook-babel/node_modules/babel/node_modules/babel-core/lib/api/register/node.js:199:5)
at Object.require.extensions.(anonymous function) as .js
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at /usr/lib/node_modules/sails/node_modules/include-all/index.js:129:29

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.