davis / plugin-hbs

Handlebars template loader plugin for SystemJS
MIT License
21 stars 9 forks source link

"Cross origin request" error when importing a second module #14

Closed tjaartvdwalt closed 8 years ago

tjaartvdwalt commented 8 years ago

Hi, I am sure this is a total n00b question.

I have a modular app that I want to port to Systemjs. When I try to import a view module into my main module I get the the error below on the handlebars runtime

system.src.js:1056 XMLHttpRequest cannot load file:///home/tjaart/hbs-test/jspm_packages/github/components/handlebars.js@4.0.5/handlebars.runtime.js. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.

This time I have created a test application to illustrate the problem :) https://github.com/tjaartvdwalt/hbs-test

The procedure I followed is documented in the README

davis commented 8 years ago

Ah - actually I think I've run into this issue myself before. I'll write a patch for this in a bit.

tjaartvdwalt commented 8 years ago

great, thank you!

davis commented 8 years ago

Hey @tjaartvdwalt, can you try using this branch and let me know if that fixes your issue? https://github.com/davis/plugin-hbs/tree/get-canonical-name

tjaartvdwalt commented 8 years ago

Ok great, we made progress :)

Unfortunately now, I get a 404 error on handlebars:

http://localhost:8080/handlebars/handlebars.runtime.js 404 (Not Found)

Not sure if this might be a config issue on my side? I had a look, but as far as I can see everything seems OK. I updated the test repo to reflect my current configuration

davis commented 8 years ago

Hey @tjaartvdwalt, was trying your test repo, but I found a couple issues -

  1. In your test repo https://github.com/tjaartvdwalt/hbs-test/blob/master/src/j-test.js you're trying to import 'handlebars' directly - it won't be available because we only have handlebars as a dependency of hbs-plugin. If you want handlebars to be directly available you'll need to do a jspm install handlebars in the repo.
  2. Also in that file you're trying to do an import for ./template.hbs!, however there is no template.hbs in that directory, so this import will fail.
  3. Also in that file you're trying to import external dependency tjaartvdwalt/hbs-test-view however if you take a look: https://github.com/tjaartvdwalt/hbs-test-view/blob/master/src/j-test.js, it's not exporting anything, so this import will be undefined.

I made fixes to those in my cloned version of your repo, but could you try using just your hbs-test-view repo and plugin-hbs and let me know if it works? I'm about to push one more change to plugin-hbs which I think should solve the underlying issue!

davis commented 8 years ago

Could you try the latest version of that branch and let me know if it works? Thanks!

tjaartvdwalt commented 8 years ago

@davis I can confirm that this is working for me!

Thank you for the fix. I will leave it to you to close the issue.

davis commented 8 years ago

Awesome!