aurelia / cli

The Aurelia 1 command line tool. Use the CLI to create projects, scaffold components, and bundle your app for release.
MIT License
407 stars 134 forks source link

Installing normal Aurelia plugins, what Im I doing wrong? #212

Closed vegarringdal closed 8 years ago

vegarringdal commented 8 years ago

Is there anything special wee need to do to make normal plugins work in aurleia-cli This is what I tried`:

{
            "name": "aurelia-skeleton-plugin",
            "path": "../node_modules/aurelia-skeleton-plugin/dist/amd",
            "main": "index"
          },

But this didnt go very well, I get

Uncaught TypeError: h.load is not a function

and

Unhandled rejection Error: Load timeout for modules: template-registry-entry!aurelia-skeleton-plugin/hello-world.html_unnormalized2,template-registry-entry!aurelia-skeleton-plugin/hello-world.html,text!aurelia-skeleton-plugin/hello-world.html_unnormalized3,text!aurelia-skeleton-plugin/hello-world.html http://requirejs.org/docs/errors.html#timeout

Im sure there is a easy fix for this, so any hints would be great.

EisenbergEffect commented 8 years ago

Being that is is an alpha, there are still certain scenarios which are not yet supported. One of those is plugins which contain html templates. We have a plan to address this similar to the way we are with Webpack.

adriatic commented 8 years ago

I would suggest to make this restriction more pronounced - I completely missed it and we as a team spent a lot more time trying to make our bridges to work with RequireJS.

Now, speaking of RequireJS: why was that chosen as the leading actor in aurelia-cli? Other than knowing that GistRun was developed that way, there were no hints about RequireJS so far.

Why asking this? Because aurelia-cli became the greatest hit in no time, and now all our bridge users keep asking why is it that we did not deliver aurelia-cli based creation of apps that use these bridges. Pretty unenviable position, I might say with a does of humor :-)

EisenbergEffect commented 8 years ago

@adriatic The CLI is still in a very alpha state. We are planning to support Webpack and hopefully SystemJS as well. The work you are doing to support Webpack (the new resources section of package json) was also designed to be used by the CLI for use with other module loaders (such as RequireJS).

As far as our choice of RequireJS first: in our experience it's the most stable, performant and cross-browser loader available today. Frankly, it was also the easiest to get working for the CLI. The CLI is designed to support multiple loaders and the design is being expanded to support multiple build systems as well.

adriatic commented 8 years ago

As far as our choice of RequireJS first: in our experience it's the most stable, performant and cross-browser loader available today.

This indicates how we should step up our effort to provide RequireJS based bridges - so far, with limited efforts and not being aware of your view of RequireJS, we failed miserably :-(

Thanks for this information

doktordirk commented 8 years ago

@EisenbergEffect is it supposed to work now with 16.1? i tried:

          {
          "name": "aurelia-orm",
          "path": "../node_modules/aurelia-orm/dist/amd",
          "main": "aurelia-orm",
          "resources": [
            "component/association-select.js",
            "component/association-select.html",
            "component/paged.js",
            "component/paged.html"
          ]},

but still get Unhandled rejection Error: Load timeout for modules: template-registry-entry!aurelia-orm/component/association-select.html_unnormalized2,template-registry-entry!aurelia-orm/component/association-select.html,template-registry-entry!aurelia-orm/component/paged.html,text!aurelia-orm/component/association-select.html_unnormalized3,text!aurelia-orm/component/association-select.html,text!aurelia-orm/component/paged.html http://requirejs.org/docs/errors.html#timeout

EisenbergEffect commented 8 years ago

It should. How can I reproduce this and test it out myself?

doktordirk commented 8 years ago

@EisenbergEffect unfortunatelly, i don't get that far anymore (ithink after making double sure i have 16.1).

now i might have that window path problem: so i have in my plugin follwoing files: component/association-select1.js component/association-select2.js

  {
          "name": "aurelia-orm",
          "path": "../node_modules/aurelia-orm/dist/amd",
          "main": "aurelia-orm",
          "resources": [
            "component/association-select-no_there.js",
          ]
}

-> as expected

Starting 'configureEnvironment'...
events.js:154
      throw er; // Unhandled 'error' event
      ^

Error: File not found with singular glob: C:\Users\dirk\aurelia\aurelia-orm-loopback-sample\client-cli-es2015\node_modules\aurelia-orm\dist\amd\component\association-select_not_there.js

now trying the one's that are there

  {
          "name": "aurelia-orm",
          "path": "../node_modules/aurelia-orm/dist/amd",
          "main": "aurelia-orm",
          "resources": [
            "component/association-select1.js",
          ]
}

->

Tracing aurelia-orm\component\association-select1...
{ uid: 10,
  name: 'writeBundles',
  branch: false,
  error:
   { [Error: ENOENT: no such file or directory, open 'C:\Users\dirk\aurelia\aurelia-orm-loopback-sample\client-cli-es2015\src\aurelia-orm\component\association-select.1js']
     errno: -4058,
     code: 'ENOENT',
     syscall: 'open',
     path: 'C:\\Users\\dirk\\aurelia\\aurelia-orm-loopback-sample\\client-cli-es2015\\src\\aurelia-orm\\component\\association-select.js1' },
  duration: [ 8, 450258429 ],
  time: 1468826250969 }

and to make sure it's that place, the same with 2

  {
          "name": "aurelia-orm",
          "path": "../node_modules/aurelia-orm/dist/amd",
          "main": "aurelia-orm",
          "resources": [
            "component/association-select2.js",
          ]
}

->

Tracing aurelia-orm\component\association-select2...
{ uid: 10,
  name: 'writeBundles',
  branch: false,
  error:
   { [Error: ENOENT: no such file or directory, open 'C:\Users\dirk\aurelia\aurelia-orm-loopback-sample\client-cli-es2015\src\aurelia-orm\component\association-select2.js']
     errno: -4058,
     code: 'ENOENT',
     syscall: 'open',
     path: 'C:\\Users\\dirk\\aurelia\\aurelia-orm-loopback-sample\\client-cli-es2015\\src\\aurelia-orm\\component\\association-select2.js' },
  duration: [ 8, 450258429 ],
  time: 1468826250969 }

windows 10

node -v v5.7.0

au -v 0.16.1

JeroenVinke commented 8 years ago

I may have made some progress in this area. Whenever an .html file of a plugin gets loaded, it gets loaded twice (once with the template-registry-entry plugin and once with the text plugin). The request with the template-registry-entry plugin works fine, but the text plugin throws an error in requirejs. On this line requirejs tries to call a load function on an empty object (the text plugin). The text plugin is an empty object because of https://github.com/aurelia/cli/blob/master/lib/build/amodro-trace/write/stubs.js#L25, which seems to override a functioning text plugin. The Load timeout for modules: template-registry-entry! error is a side effect, because nothing loads after the plugin.load is not a function error.

By changing the "stub" property in aurelia.json to false:

        {
          "name": "text",
          "extensions": [
            ".html",
            ".css"
          ],
          "stub": false
        }

everything started to work.

image

EisenbergEffect commented 8 years ago

Are you trying to dynamically load views outside the bundle?

JeroenVinke commented 8 years ago

Yes

  <require from="aurelia-kendoui-bridge/grid/grid"></require>
  <require from="aurelia-kendoui-bridge/grid/col"></require>

I have a repro here: https://github.com/JeroenVinke/kendo-aureliacli

if you change "stub" back to true then the error occurs.

adarshpastakia commented 8 years ago

I have the same issue when trying to use my framework with the cli. i tried every suggestion but cannot get it to work.

if stub: true error is Load timeout for modules if stub: false error is src/../scripts/app-bundle.html HTTP status: 404

the project repo: https://github.com/adarshpastakia/aurelia-ui-framework/archive/skeleton-cli.zip

the readme file explain how its setup, basically i create an aurelia app using the cli, the update the contents of src folder and index.html from the skeleton project

vegarringdal commented 8 years ago

Tried setting stub to false, like @JeroenVinke and now my grid can be used in aurleia cli..

How I install it : docs

vegarringdal commented 8 years ago

@EisenbergEffect You can close this issue if having the "stub" set to false wont break anything..

EisenbergEffect commented 8 years ago

Nope. There's no problem with that. Setting stub to true just doesn't embed the full text loader. If you need to dynamically require text, you will just want to set that to false. It's absolutely supported both ways. Our HUB actually sets stub to false.

vegarringdal commented 8 years ago

@EisenbergEffect Great, just glad I finally have my grid working in the CLI too :smile:

adarshpastakia commented 8 years ago

@EisenbergEffect

Thanks to @JeroenVinke, we figured out the issue.

In one of the custom element view-model i also have a generic class that exposes static properties, and the entry point file had this

function configure(aurelia, configCallback) {
aurelia.globalResources('./components/ui-chart');
}
export {UIChart} from './components/ui-chart';

Once i moved the static properties to different file and changed the export statement everything worked just fine.

krig commented 7 years ago

Just wanted to note that I'm trying to follow the Contact Manager Tutorial in the documentation, and hit this same issue. setting stub: false resolved the problem. Not sure if I missed a step somewhere, or if this is a problem that actually affects the tutorial.

hozn commented 7 years ago

FWIW, I was also experiencing this error ("plugin.load is not a function") following the contact-manager on my Mac. This was puzzling because I just followed this tutorial last weekend on my laptop and do not remember having this issue, so I cleared out my entire node/npm environment and re-installed aurelia-cli and recreated project and now it works without the error. Were I more of a scientist, I would have stored my previous globally installed packages tree. The now-working system is using following versions:

➜  contact-manager git:(master) ✗ npm -v
3.8.9
➜  contact-manager git:(master) ✗ node -v
v6.2.0
➜  contact-manager git:(master) ✗ au -v
0.23.0

Hopefully this is helpful to someone.

Edit -- Actually (after getting home to my linux laptop), I think the problem is sporadic. And the issue for me was ultimately resolved by https://github.com/aurelia/bundler/issues/92