Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Looking for files in all the wrong places #26

Open
jbnv opened this issue Dec 8, 2016 · 9 comments
Open

Looking for files in all the wrong places #26

jbnv opened this issue Dec 8, 2016 · 9 comments

Comments

@jbnv
Copy link

jbnv commented Dec 8, 2016

Getting this error as I attempt to start up my application from the CLI:

Tracing aurelia-chart...
{ uid: 10,
  name: 'writeBundles',
  branch: false,
  error:
   { [Error: ENOENT: no such file or directory, open '/Users/mac/Projects/SongChartAurelia2/src/observers/model-observer.js']
     errno: -2,
     code: 'ENOENT',
     syscall: 'open',
     path: '/Users/mac/Projects/SongChartAurelia2/src/observers/model-observer.js',
     moduleTree: [ 'aurelia-chart' ],
     fileName: '/Users/mac/Projects/SongChartAurelia2/node_modules/aurelia-chart/dist/commonjs/index.js' },
  duration: [ 217, 485490417 ],
  time: 1481168967221 }

Aurelia is trying to find observers/model-observer.js in the application's root src directory, not the one for aurelia-chart. I added both aurelia-chart and chart.js through NPM. How can I resolve this problem?

@grofit
Copy link
Owner

grofit commented Dec 8, 2016

It could be related to #21 #25, it seems depending on how you are consuming it there could be problems, the "core" logic in this plugin is sound, and has been since inception, almost all issues that plague it are down to the tooling around consuming modules so I have said in previous issues I don't have the capacity currently to fix it as the package.json main is hooked up to the right file so it should just work.

Hopefully someone can do a PR who knows the current tooling and approaches for Aurelia and then everyone can be happy until the next tooling change occurs :(

One other thing to mention is that you should load these plugins up as a plugin not a feature which some people use as a hack around, you may also need to consult the CLI docs to see if you need to add any custom properties to your package.json to imply what should be bundled.

@jbnv
Copy link
Author

jbnv commented Dec 8, 2016

I'm at my day job right now and the project is a personal project, so I can't look into it further at the moment but will do so later. I am pretty sure that I am loading it as a plugin, but I will double-check.

@jbnv
Copy link
Author

jbnv commented Dec 9, 2016

I set my aurelia.json per hozn's post in #25. Now my code compiles and runs at the command line, but throws undefined 'exports' on the first line of the code block below. Is this one of the variations of aurelia-chart?

Object.defineProperty(exports, "__esModule", {
    value: true
});
exports.configure = configure;

var _observersModelObserver = require("./observers/model-observer");

function configure(aurelia) {
    aurelia.globalResources("./elements/chart-element", "./attributes/chart-attribute");

    aurelia.container.registerTransient(_observersModelObserver.ModelObserver);
}

@jbnv
Copy link
Author

jbnv commented Dec 10, 2016

Changed the code in aurelia.json to this:

          {
            "name": "chart.js",
            "path": "../node_modules/chart.js/dist",
            "main": "Chart.min"
          },
          {
            "name": "aurelia-chart",
            "path": "../node_modules/aurelia-chart/dist/amd",
            "main": "index"
          },

Now I'm getting the h.load error when I include .plugin('aurelia-chart').

@grofit
Copy link
Owner

grofit commented Dec 10, 2016

Do they still have a plugins skeleton app? as it may be worth someone just grabbing that, putting these files in there and building off that, as so far 99% of the problems I receive are just trying to load the plugin in, there is rarely a problem once the plugin has been successfully loaded.

@jbnv
Copy link
Author

jbnv commented Dec 10, 2016

Yes. You can generate one with the new Aurelia CLI.

@jbnv
Copy link
Author

jbnv commented Dec 10, 2016

I created a shell application with the modifications and uploaded it to GitHub. The first commit is the unmodified shell application; the second commit are the changes that trigger the bug.

@grofit
Copy link
Owner

grofit commented Dec 12, 2016

is it the package.json changes or the aurelia.json changes which primarily cause it? or is it just when both are there?

@obust
Copy link

obust commented Dec 23, 2016

With this aurelia.json config

          {
            "name": "chart.js",
            "path": "../node_modules/chart.js/dist",
            "main": "Chart.min"
          },
          {
            "name": "aurelia-chart",
            "path": "../node_modules/aurelia-chart/dist/amd",
            "main": "index",
            "resources": [
              "elements/chart-element.js",
              "elements/chart-element.html",
              "attributes/chart-attribute.js"
            ]
          },

The aurelia-cli can run the app, but the console outputs two errors:
Uncaught Error: Mismatched anonymous define() module: function (exports, _aureliaFramework, _observersModelObserver, _chartJs)

Each one is caused respectively by elements/chart-element.js and attributes/chart-attribute.js (aka if i dont load these resources, i don't get the error but i can't use the package...)

This is highly related to jbnv's comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants