benbria / browserify-transform-tools

Utilities for writing browserify transforms.
MIT License
65 stars 15 forks source link

Configuration can only be set in the top level package #5

Closed majgis closed 9 years ago

majgis commented 9 years ago

I want to use the transform I create with browserify-transform-tools to apply to reusable packages, but configuration can't be set for each package the same way browserify transforms are.

Browserify transforms are defined at the package level, but browserify-transform-tools reads configuration only from the top level package.

For example, I want to create a transform called somethingify. I then want to create a reusable package called reuseMe that uses somethingify and sets it's own configuration.

myProject
    package.json  <----Config for somethingify transform must be set here
    node_modules
        somethingify
        reuseMe
            package.json   <---I should be able to set somethingify config here
            node_modules
                  somethingify

To be consistent with browserify behavior, transform options should not apply to child packages. Each package should be responsible for describing the transforms it uses and the configurations for those transforms.

milotoor commented 9 years ago

I may be wrong but I think this can be achieved by passing the option { fromSourceFileDir: true } when calling the make*Transform function. By default the search for package config begins from the directory the process is running in, not the directory the source file is in (see loadTransformConfig in src/loadConfig.coffee). Passing in the fromSourceFileDir should change that behavior.

jwalton commented 9 years ago

@majgis Does fromSourceFileDir fix this for you? I should have defaulted this flag to true, but I didn't want to break existing libraries. :/

majgis commented 9 years ago

Thanks fir the responses. Yes, it does fix it. Sorry, I didn't read the docs more carefully. I agree it should be the default, maybe if you have other breaking changes in the future and increment major version, you could flip it then.

jwalton commented 9 years ago

Yeah. I just made a change I'm less than happy with in 1.3.3 which I may turn around and break in a few days, so if that happens I will do. :)