Skip to content

Conversation

@tgriesser
Copy link

I ran into an issue when trying to use the package config to build a project, where the config is:

({
    baseUrl: ".",
    optimize: 'none',
    cjsTranslate: true,
    paths: {
      lodash: './node_modules/lodash/lodash'
    },
    packages: [{
      name: 'bluebird',
      location: 'node_modules/bluebird',
      main: './js/main/bluebird.js'
    }],
    name: "knex",
    out: "knex-built.js"
})

I was getting the error:

Tracing dependencies for: knex
Error: ENOENT, no such file or directory '/Users/tgriesser/Github/knex/bluebird/js/main/global.js'
In module tree:
    knex
      lib/raw
        lib/common
          lib/promise
            bluebird/js/main/promise

In this case, it was resolving relative package paths relative to the main file, which wasn't using the location to find the correct path. So it was doing:

/Users/tgriesser/Github/knex/bluebird/js/main/global.js

rather than

/Users/tgriesser/Github/knex/node_modules/bluebird/js/main/global.js

This pull request adds a check to see if a location is defined and if so replaces appropriately in the package name.

@jrburke
Copy link
Member

jrburke commented Jan 7, 2014

Thanks for pointing this out. The fix was a bit more involved, and depended on another fix that is landing for 2.1.10, so I could not use this pull request directly. However, it should be fixed for 2.1.10.

jrburke added a commit to requirejs/requirejs that referenced this pull request Jan 7, 2014
jrburke added a commit to requirejs/requirejs that referenced this pull request Jan 7, 2014
jrburke added a commit that referenced this pull request Jan 7, 2014
jrburke added a commit to requirejs/requirejs that referenced this pull request Jan 8, 2014
@jrburke
Copy link
Member

jrburke commented Jan 8, 2014

Turns out there was a larger issue with compatibility with node ID resolution: they treat 'example.js' and 'example' as the same module ID. So instead of the packages-specific fix, there is a new nodeIdCompat config value that if set to true, will treat those IDs as the same. So be sure to set that if using modules installed from npm once 2.1.10 is released.

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

Successfully merging this pull request may close these issues.

2 participants