Skip to content
This repository has been archived by the owner on Mar 26, 2018. It is now read-only.

Loading multimodule package does not work #27

Open
feklee opened this issue Nov 27, 2014 · 2 comments
Open

Loading multimodule package does not work #27

feklee opened this issue Nov 27, 2014 · 2 comments

Comments

@feklee
Copy link

feklee commented Nov 27, 2014

I installed my own package ptp.js. From bower.json:

"dependencies": {
    "ptp.js": "2.x",
    "requirejs": "2.x"
},

From Gruntfile.js:

bower: {
    target: {
        rjsConfig: 'package/config.js'
    }
},

Resulting config.js:

require.config({
  shim: {

  },
  paths: {
    ptp: "bower_components/ptp.js/scripts/ptp",
    requirejs: "bower_components/requirejs/require"
  },
  packages: [

  ]
});

Now, to load ptp.js, the app's main module has:

defined(['ptp'], function (ptp) {
    // …
}

ptp.js loads fine, but not any modules that it depends on. To fix this, I modify config.js to match what @jrburke does in his template for a simple one-page app:

  paths: {
    ptp: "bower_components/ptp.js/scripts",

Then to load the module, I use:

defined(['ptp/ptp'], function (ptp) {
    // …
}

Now, the dependencies load. The trick is to set the path to the directory containing the main module of the package to be loaded. If loaded as ptp/ptp, then relative paths work fine, otherwise not.

I think there is design issue that needs to be discussed, or there is something that I don't understand.

What do you think?

@morficus
Copy link

Looking at your ptp component, you need to fix the main reference in your bower.json file (https://github.com/feklee/ptp.js/blob/master/bower.json#L8). It should be pointing to a file (or multiple), not a directory. So that could be causing some of your problems.

Try changing it to this:
"main": "scripts/ptp.js"

@feklee
Copy link
Author

feklee commented Jan 11, 2015

Pointing "main" to "scripts/ptp.js" causes the issue that relative paths are not found. Pointing it to a directory is the only workaround that I found.

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

No branches or pull requests

2 participants