Node-Webkit, ES6, AMD, and CommonJS [resolved!]

My mistake, the shim is in there - I had inadvertently included it twice, and only removed it once… :smile:

Edit, since I’m a new user I can’t reply any more - thanks @dogawaf, if I run into any more issues I’ll let you know! :slight_smile:

Hi

I recently build for one of our customers a full project on node-webkit and ember-cli. The app can run offline (with ember-indexeddb-adapter), and soon also online, with the standard rest adapter. I only modified the index.html and tests/index.html to introduce the node_require alias and the proper base tag, and to configure the main window of the app. The node-webkit app is packaged for linux and windows with grunt-node-webkit-builder. I will be happy to share my experience by answering to some questions.

Cheers. Rémy.

Hi @dogawaf,

could you please post the steps needed to build ember-cli for node-webkit? I’m a big noobie and can’t figure out how to do it. I tried to use the example of mr. Emerson, but I must be missing something.

Would you be so kind to post description of what to edit/add to make ember cli (0.46 ) ember build work with current node-webkit?

Thank you!

Hi

With the latest release of ember-cli (not tested), I think you just need to put in public/ the package.json needed by node-webkit, and to configure the baseUrl in config/environment.js to app://whatever/index.html. Then you can run (or build) the node-webkit app with the files in dist/

Thank you for your reply @dogawaf. I’ve updated my project:

  • added package.json with webkit config to /public/, with ‘main’: ‘index.html’
  • modifed config/environment.js ENV.baseURL to ‘app://appname/webkit-dist/index.html’ (i have build for webkit-dev environment with webkit-dist/ output)

But when I run ‘nw /Projects/appname/webkit-dist/’ (with alias nw), I get the following error

Uncaught Error: Cannot find module ‘appname/app’", source: module.js (338)

I don’t know if I’m missing something or if there are any steps needed besides this or if I’m just blind (ehm stupid cough)… Sorry and thank you.

In the same boat… @dogawaf we would appreciate your advice on this.

using ember cli 0.1.1 public/package.json has “main”: “index.html”

and in config/environment baseURL: ‘app://myapp’

But no luck…

Hey guys

I finally took the time to create a test repo: https://github.com/dogawaf/ember-nw-app. I hope you will find in it some hints.

Cheers

2 Likes

Thanks a ton! Going through this now :smile:

I just cloned and ran your repo. The app launches fine :smile:

But I think the require is still broken, I get this error in console when I try to go to ‘os’ route

Error while processing route: os" "Cannot find module 'my-node-module'

Any ideas?

@dogawaf

Thank you so much for the example, it was extremely helpful and I was able to solve the problem. Everything works perfectly now. Please have my virtual hat :]

Cheers!

Thank you. This repo is awesome.

However, I still have a bug when I try to use Ember Simple Auth (GitHub - simplabs/ember-simple-auth: A library for implementing authentication/authorization in Ember.js applications.).

To reproduce:

 $ npm install --save-dev ember-cli-simple-auth
 $ ember generate ember-cli-simple-auth

Launch NW and you’ll get the following errors:

Uncaught Error: Cannot find module 'ember'
Uncaught Error: Could not find module simple-auth/configuration 

Do you have an idea where does it come from?

It seems that amd distribution of simple-auth use global instead of window… See: https://github.com/simplabs/ember-simple-auth/blob/master/packages/ember-simple-auth/wrap/amd.end

So, require is not the window’s require, but node’s require…

Edit: I opened an issue at simple-auth: https://github.com/simplabs/ember-simple-auth/issues/323

Simpleauth should now be fixed: https://github.com/simplabs/ember-simple-auth/pull/325

Can’t we just delete window.global ?

<head>
   ...
    <script type="text/javascript">
      delete window.global;
    </script>

    {{content-for 'head'}}
   ...
</head>

Hi, i made an article explaining how to use ember-cli and node-webkit together with live-reload and some additional stuff:

http://examplelab.com.ar/usando-ember-cli-con-node-webkit/

it’s has a project template in github too.