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

Always resolve relative urls relative to package.json #47

Open
xkr47 opened this issue Dec 1, 2016 · 0 comments
Open

Always resolve relative urls relative to package.json #47

xkr47 opened this issue Dec 1, 2016 · 0 comments

Comments

@xkr47
Copy link

xkr47 commented Dec 1, 2016

note that using the browserify API, './shims/d3.js' will be resolved against the current working directory.

and separately:

configDir - An absolute path to resolve relative paths against. If you're using package.json, this will automatically be filled in for you with the directory containing package.json. If you're using a .js file for configuration, set this to __dirname.

In my opinion it would make sense to always resolve against package.json (except of course when file-relative operation is enabled through {relative: "replacement"}). Especially it would allow one to use aliasify for package-relative paths in package.json like this:

{
  "name": "mypkg",
  "browserify": {
    "transform": [
      [
        "aliasify",
        {
          "aliases": {
            "jquery": "./jquery.custom"
          } 
        }
      ]
    ]
  }
}

.. where jquery.custom is in the same directory as the package.json file. Then it would still "just work" even when somebody else depends on mypkg.

I understand that you might not want to break backwards compatibility with existing implementations that have implemented paths based on how they work now; it would require a major release. But perhaps you could introduce a config option to enable the new behaviour until then?

        {
          "aliases": {
            "jquery": "./jquery.custom"
          },
          "usePackageRelativePaths": true
        }

There are plenty of npm packages available to figure out the associated package.json file location. For example this looks decent: https://www.npmjs.com/package/pkg-up

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

No branches or pull requests

1 participant