Skip to content

Use package location if one is specified #591

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

Closed
wants to merge 1 commit into from
Closed

Use package location if one is specified #591

wants to merge 1 commit into from

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
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy